Commit f538b1ef authored by isherman@chromium.org's avatar isherman@chromium.org

Revert 112319 - Revert 112305 - Pull the phone library directly. Delete old version.

TEST=unit-tests
BUG=105577
Review URL: http://codereview.chromium.org/8736001

TBR=georgey@chromium.org
Review URL: http://codereview.chromium.org/8759004

TBR=isherman@chromium.org
Review URL: http://codereview.chromium.org/8757005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112324 0039d316-1c4b-4281-b951-d872f2087c98
parent 8bce7075
......@@ -31,6 +31,7 @@ vars = {
"nacl_toolchain_revision": "7258",
"libjingle_revision": "95",
"libphonenumber_revision": "403",
"libvpx_revision": "109236",
"ffmpeg_revision": "112050",
"sfntly_revision": "98",
......@@ -298,6 +299,16 @@ deps = {
"src/third_party/smhasher/src":
(Var("googlecode_url") % "smhasher") + "/trunk@136",
"src/third_party/libphonenumber/src/phonenumbers":
(Var("googlecode_url") % "libphonenumber") +
"/trunk/cpp/src/phonenumbers@" + Var("libphonenumber_revision"),
"src/third_party/libphonenumber/src/test":
(Var("googlecode_url") % "libphonenumber") + "/trunk/cpp/test@" +
Var("libphonenumber_revision"),
"src/third_party/libphonenumber/src/resources":
(Var("googlecode_url") % "libphonenumber") + "/trunk/resources@" +
Var("libphonenumber_revision"),
}
......
......@@ -10,7 +10,7 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_country.h"
#include "third_party/libphonenumber/cpp/src/phonenumberutil.h"
#include "third_party/libphonenumber/src/phonenumber_api.h"
using i18n::phonenumbers::PhoneNumber;
using i18n::phonenumbers::PhoneNumberUtil;
......@@ -108,7 +108,7 @@ bool ParsePhoneNumberInternal(const string16& value,
*city_code = UTF8ToUTF16(area_code);
*country_code = string16();
PhoneNumberUtil::NormalizeDigitsOnly(&number_text);
phone_util->NormalizeDigitsOnly(&number_text);
string16 normalized_number(UTF8ToUTF16(number_text));
// Check if parsed number has country code and it was not inferred from the
// locale.
......@@ -148,7 +148,7 @@ string16 NormalizePhoneNumber(const string16& value,
return string16();
}
std::string result_utf8(UTF16ToUTF8(result));
PhoneNumberUtil::NormalizeDigitsOnly(&result_utf8);
PhoneNumberUtil::GetInstance()->NormalizeDigitsOnly(&result_utf8);
return UTF8ToUTF16(result_utf8);
}
......@@ -176,7 +176,9 @@ bool ConstructPhoneNumber(const string16& country_code,
std::string normalized_number(UTF16ToUTF8(city_code));
normalized_number.append(UTF16ToUTF8(number));
PhoneNumberUtil::NormalizeDigitsOnly(&normalized_number);
PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance();
phone_util->NormalizeDigitsOnly(&normalized_number);
int64 number_int = 0;
if (!base::StringToInt64(normalized_number, &number_int) || !number_int)
......@@ -185,8 +187,6 @@ bool ConstructPhoneNumber(const string16& country_code,
PhoneNumber i18n_number;
i18n_number.set_national_number(static_cast<uint64>(number_int));
PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance();
int country_int = phone_util->GetCountryCodeForRegion(
SanitizeLocaleCode(locale));
if (!country_code.empty() && !base::StringToInt(country_code, &country_int))
......
......@@ -2,7 +2,7 @@ Name: International Phone Number Library
Short Name: libphonenumber
URL: http://libphonenumber.googlecode.com/svn/trunk/
Version: unknown
Revision: 277
Revision: 403
Security Critical: yes
This directory contains the source code of International Phone Number Library
......@@ -17,15 +17,13 @@ This library depends on
Additional files, not in the original library:
libphonenumber.gyp
README.chromium
src/LICENSE # Taken from http://code.google.com/p/libphonenumber.
src/phonenumber_api.h
Until the changes are upstreamed library is included directly, with patches
in patches/version277.patch and patches/version277a.patch applied.
The folders included in our repository for now are
cpp/
resource/
TODO(georgey) : remove following lines when updated to version after 186
cpp/src/phonelibutil.cc made icu::Transliteration member of PhoneUtil
to improve performance, Not needed in recent versions.
The library is mapped through the DEPS file into src/ folder. To update:
1. Get the latest version number from
http://code.google.com/p/libphonenumber/source/list
2. Locally update this file and DEPS.
3. run 'gclient sync'
4. Adjust libphonenumber.gyp if necessary.
5. Verify that all compiles and all of the tests are successfull.
......@@ -8,15 +8,17 @@
'../..', # add it first, so src/base headers are used instead of the ones
# brought with the library as cc files would be taken from the
# main chrome tree as well.
'cpp/src',
'src',
'src/test',
# The libphonenumber source (and test code) expects the
# generated protocol headers to be available with no include
# path, e.g. #include "foo.pb.h".
# generated protocol headers to be available with "phonenumbers" include
# path, e.g. #include "phonenumbers/foo.pb.h".
'<(SHARED_INTERMEDIATE_DIR)/protoc_out/third_party/libphonenumber',
],
'defines': [
'USE_HASH_MAP=1',
'USE_GOOGLE_BASE=1',
'USE_ICU_REGEXP=1',
],
},
'includes': [
......@@ -32,32 +34,36 @@
'../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
],
'sources': [
# 'chrome/regexp_adapter_icuregexp.cc',
'cpp/src/default_logger.cc',
'cpp/src/lite_metadata.cc',
'cpp/src/logger.cc',
'cpp/src/phonenumber.cc',
'cpp/src/phonenumberutil.cc',
'cpp/src/regexp_adapter_icu.cc',
'cpp/src/regexp_cache.cc',
'cpp/src/stringutil.cc',
'cpp/src/utf/rune.c',
'cpp/src/utf/unicodetext.cc',
'cpp/src/utf/unilib.cc',
'resources/phonemetadata.proto',
'resources/phonenumber.proto',
'src/phonenumbers/asyoutypeformatter.cc',
'src/phonenumbers/default_logger.cc',
# Comment next line and uncomment the line after, if complete metadata
# (with examples) is needed.
'src/phonenumbers/lite_metadata.cc',
#'src/phonenumbers/metadata.cc',
'src/phonenumbers/logger.cc',
'src/phonenumbers/phonenumber.cc',
# The following two files should be added on 'as needed' basis.
#'src/phonenumbers/phonenumbermatch.cc',
#'src/phonenumbers/phonenumbermatcher.cc',
'src/phonenumbers/phonenumberutil.cc',
'src/phonenumbers/regexp_adapter_icu.cc',
'src/phonenumbers/regexp_cache.cc',
'src/phonenumbers/stringutil.cc',
'src/phonenumbers/unicodestring.cc',
'src/phonenumbers/utf/rune.c',
'src/phonenumbers/utf/unicodetext.cc',
'src/phonenumbers/utf/unilib.cc',
'src/resources/phonemetadata.proto',
'src/resources/phonenumber.proto',
],
'direct_dependent_settings': {
'include_dirs': [
# The libphonenumber headers expect generated protocol headers
# to be available with no include path, e.g. #include
# "foo.pb.h".
'<(SHARED_INTERMEDIATE_DIR)/protoc_out/third_party/libphonenumber',
],
},
'variables': {
'proto_in_dir': 'resources',
'proto_out_dir': 'third_party/libphonenumber',
'proto_in_dir': 'src/resources',
'proto_out_dir': 'third_party/libphonenumber/phonenumbers',
},
'includes': [ '../../build/protoc.gypi' ],
'conditions': [
......@@ -73,10 +79,16 @@
'type': 'executable',
'sources': [
'../../base/test/run_all_unittests.cc',
'cpp/src/phonenumberutil_test.cc',
'cpp/src/regexp_adapter_test.cc',
'cpp/src/stringutil_test.cc',
'cpp/src/test_metadata.cc',
'src/phonenumbers/test_metadata.cc',
'src/test/phonenumbers/asyoutypeformatter_test.cc',
# The following two files should be added on 'as needed' basis.
#'src/test/phonenumbers/phonenumbermatch_test.cc',
#'src/test/phonenumbers/phonenumbermatcher_test.cc',
'src/test/phonenumbers/phonenumberutil_test.cc',
'src/test/phonenumbers/regexp_adapter_test.cc',
'src/test/phonenumbers/stringutil_test.cc',
'src/test/phonenumbers/test_util.cc',
'src/test/phonenumbers/unicodestring_test.cc',
],
'dependencies': [
'../icu/icu.gyp:icui18n',
......
diff -Naur src-orig/default_logger.h src/default_logger.h
--- src-orig/default_logger.h 2011-07-02 16:27:58.000000000 -0700
+++ src/default_logger.h 2011-07-02 16:28:29.000000000 -0700
@@ -17,6 +17,8 @@
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
+#include <stdio.h>
+
#include <string>
#include "logger.h"
@@ -45,7 +47,7 @@
struct ConvertToString<int> {
static inline string DoWork(const int& n) {
char buffer[16];
- std::snprintf(buffer, sizeof(buffer), "%d", n);
+ snprintf(buffer, sizeof(buffer), "%d", n);
return string(buffer);
}
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment