Commit c3156488 authored by dbeam@chromium.org's avatar dbeam@chromium.org

Build libaddressinput in Chrome for requestAutocomplete().

This CL:
- creates a chromium-specific:
 * third_party/libaddressinput/
  * chromium/util/
   - json.cc (chromium-specific json reader)
   - json.h (matches src/cpp/src/util/json.h's interface)
  - libaddressinput.gyp (chromium-specific .gyp file)
- builds and runs a new test target named libaddressinput_unittests

R=rouslan@chromium.org
BUG=317837

Review URL: https://codereview.chromium.org/68323005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236996 0039d316-1c4b-4281-b951-d872f2087c98
parent f79f811a
......@@ -258,6 +258,7 @@
'../sync/sync.gyp:sync_unit_tests',
'../third_party/WebKit/public/all.gyp:all_blink',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp:webkit_compositor_bindings_unittests',
],
......@@ -678,6 +679,7 @@
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../tools/perf/clear_system_cache/clear_system_cache.gyp:*',
'../ui/ui_unittests.gyp:ui_unittests',
......@@ -711,6 +713,7 @@
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../tools/perf/clear_system_cache/clear_system_cache.gyp:*',
'../ui/ui_unittests.gyp:ui_unittests',
......@@ -732,6 +735,7 @@
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../url/url.gyp:url_unittests',
],
......@@ -765,6 +769,7 @@
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../ui/ui_unittests.gyp:ui_unittests',
'../url/url.gyp:url_unittests',
......@@ -811,6 +816,7 @@
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../tools/perf/clear_system_cache/clear_system_cache.gyp:*',
'../ui/events/events.gyp:events_unittests',
......@@ -872,6 +878,7 @@
'../remoting/remoting.gyp:remoting_unittests',
'../sql/sql.gyp:sql_unittests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../url/url.gyp:url_unittests',
],
......@@ -897,6 +904,7 @@
'../remoting/remoting.gyp:remoting_unittests',
'../sql/sql.gyp:sql_unittests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
'../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests',
'../url/url.gyp:url_unittests',
],
......
......@@ -10,8 +10,8 @@ Security Critical: no
Description:
This library allows users to input their address, and perform validation on this
by talking to an address data server at http://i18napis.appspot.com/address. The
library is used in requestAutocomplete() dialog to enable internationalized
by talking to an address data server at https://i18napis.appspot.com/address.
The library is used in requestAutocomplete() dialog to enable internationalized
address input and validation for payment forms.
Local Modifications:
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "util/json.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
namespace i18n {
namespace addressinput {
Json::Json() {}
Json::~Json() {}
bool Json::ParseObject(const std::string& json) {
dict_.reset();
// |json| is converted to a |c_str()| here because rapidjson and other parts
// of the standalone library use char* rather than std::string.
scoped_ptr<base::Value> parsed(base::JSONReader::Read(json.c_str()));
if (parsed && parsed->IsType(base::Value::TYPE_DICTIONARY))
dict_.reset(static_cast<base::DictionaryValue*>(parsed.release()));
return !!dict_;
}
bool Json::HasStringValueForKey(const std::string& key) const {
base::Value* val = NULL;
dict_->GetWithoutPathExpansion(key, &val);
return val && val->IsType(base::Value::TYPE_STRING);
}
std::string Json::GetStringValueForKey(const std::string& key) const {
std::string result;
dict_->GetStringWithoutPathExpansion(key, &result);
return result;
}
} // namespace addressinput
} // namespace i18n
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This class provides the same interface as ../src/cpp/src/util/json.h but with
// a Chromium-specific JSON parser. This is because it didn't make much sense to
// have 2 JSON parsers in Chrome's code base, and the standalone library opted
// to use rapidjson instead of jsoncpp. See the other file for an explanation of
// what this class does.
#ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_UTIL_JSON_H_
#define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_UTIL_JSON_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
namespace i18n {
namespace addressinput {
class Json {
public:
Json();
~Json();
bool ParseObject(const std::string& json);
bool HasStringValueForKey(const std::string& key) const;
std::string GetStringValueForKey(const std::string& key) const;
private:
scoped_ptr<base::DictionaryValue> dict_;
DISALLOW_COPY_AND_ASSIGN(Json);
};
} // namespace addressinput
} // namespace i18n
#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_UTIL_JSON_H_
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'target_defaults': {
'cflags!': [
'-fvisibility=hidden',
],
'conditions': [
['OS=="mac" or OS=="ios"', {
'xcode_settings': {
'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'NO',
}
}],
],
},
'targets': [
{
'target_name': 'generated_messages',
'type': 'none',
'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/libaddressinput/',
},
'actions': [
{
'action_name': 'generate_messages',
'variables': {
'grit_grd_file': 'src/cpp/res/messages.grd',
},
'includes': [
'../../build/grit_action.gypi',
],
},
],
'includes': [
'../../build/grit_target.gypi',
],
},
{
'target_name': 'libaddressinput',
'type': 'static_library',
'include_dirs': [
'chromium/',
'src/cpp/include/',
'<(SHARED_INTERMEDIATE_DIR)/libaddressinput/',
],
'sources': [
'chromium/util/json.cc',
'chromium/util/json.h',
'src/cpp/include/libaddressinput/address_field.h',
'src/cpp/include/libaddressinput/address_ui_component.h',
'src/cpp/include/libaddressinput/address_ui.h',
'src/cpp/include/libaddressinput/localization.h',
'src/cpp/src/address_field.cc',
'src/cpp/src/address_field_util.cc',
'src/cpp/src/address_field_util.h',
'src/cpp/src/address_ui.cc',
'src/cpp/src/localization.cc',
'src/cpp/src/region_data_constants.cc',
'src/cpp/src/region_data_constants.h',
'src/cpp/src/rule.cc',
'src/cpp/src/rule.h',
],
'dependencies': [
'generated_messages',
'<(DEPTH)/base/base.gyp:base',
],
'direct_dependent_settings': {
'include_dirs': [
'src/cpp/include/',
],
},
},
{
'target_name': 'libaddressinput_unittests',
'type': '<(gtest_target_type)',
'include_dirs': [
'src/cpp/src',
'<(DEPTH)/testing/gtest/include/',
'<(SHARED_INTERMEDIATE_DIR)/libaddressinput/',
],
'sources': [
'src/cpp/test/address_field_util_test.cc',
'src/cpp/test/address_ui_test.cc',
'src/cpp/test/localization_test.cc',
'src/cpp/test/region_data_constants_test.cc',
'src/cpp/test/rule_test.cc',
'src/cpp/test/util/json_test.cc',
],
'dependencies': [
'libaddressinput',
'<(DEPTH)/base/base.gyp:run_all_unittests',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
},
],
}
......@@ -200,6 +200,9 @@
"chrome/browser/resources/sync_file_system_internals_resources.grd": {
"includes": [29000],
},
"third_party/libaddressinput/src/cpp/res/messages.grd": {
"messages": [29050],
},
"components/component_strings.grd": {
"messages": [30000],
},
......
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