Skip to content

Commit

Permalink
Revert 282726 "Reland "Use upstream libaddressinput in Chrome.""
Browse files Browse the repository at this point in the history
Reverted for merge conflict

> Reland "Use upstream libaddressinput in Chrome."
> 
> Remove static initializer and reland https://crrev.com/282408 which was
> reverted in https://crrev.com/282426.
> 
> TBR=estade@chromium.org,thestig@chromium.org
> BUG=389918
> 
> Review URL: https://codereview.chromium.org/386873002

TBR=rouslan@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282732 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsleevi@chromium.org committed Jul 11, 2014
1 parent a9c6335 commit 889a2bb
Show file tree
Hide file tree
Showing 58 changed files with 902 additions and 2,652 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ vars = {
# to update other nacl_*_revision's.
"nacl_tools_revision": "13077", # native_client/DEPS: tools_rev
"google_toolbox_for_mac_revision": "662",
"libaddressinput_revision": "304",
"libaddressinput_revision": "300",
"libphonenumber_revision": "621",
"libvpx_revision": "280676",
"lss_revision": "26",
Expand Down
35 changes: 0 additions & 35 deletions build/ios/grit_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,41 +591,6 @@ IDS_IMPORT_FROM_FIREFOX
IDS_IMPORT_FROM_ICEWEASEL
IDS_KEYWORD_SEARCH
IDS_LEARN_MORE
IDS_LIBADDRESSINPUT_ADDRESS_LINE_1_LABEL
IDS_LIBADDRESSINPUT_AREA
IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL
IDS_LIBADDRESSINPUT_COUNTY
IDS_LIBADDRESSINPUT_DEPARTMENT
IDS_LIBADDRESSINPUT_DISTRICT
IDS_LIBADDRESSINPUT_DO_SI
IDS_LIBADDRESSINPUT_EMIRATE
IDS_LIBADDRESSINPUT_ISLAND
IDS_LIBADDRESSINPUT_LOCALITY_LABEL
IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_POSTAL_CODE
IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_POSTAL_CODE_URL
IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_ZIP
IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_ZIP_URL
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_OBLAST
IDS_LIBADDRESSINPUT_PARISH
IDS_LIBADDRESSINPUT_POSTAL_CODE_LABEL
IDS_LIBADDRESSINPUT_PO_BOX_FORBIDDEN_VALUE
IDS_LIBADDRESSINPUT_PREFECTURE
IDS_LIBADDRESSINPUT_PROVINCE
IDS_LIBADDRESSINPUT_RECIPIENT_LABEL
IDS_LIBADDRESSINPUT_STATE
IDS_LIBADDRESSINPUT_UNKNOWN_VALUE
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_POSTAL_CODE
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_POSTAL_CODE_EXAMPLE
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_POSTAL_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_ZIP
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_ZIP_CODE_EXAMPLE
IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_ZIP_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_ZIP_CODE_LABEL
IDS_LOGIN_DIALOG_OK_BUTTON_LABEL
IDS_LOGIN_DIALOG_PASSWORD_FIELD
IDS_LOGIN_DIALOG_TITLE
Expand Down
6 changes: 0 additions & 6 deletions chrome/app/address_input_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ limitations under the License.
Island).">
Island
</message>
<message
name="IDS_LIBADDRESSINPUT_OBLAST"
desc="Administrative Area for certain countries (e.g., Russia's
Leningrad).">
Oblast
</message>
<message
name="IDS_LIBADDRESSINPUT_PARISH"
desc="Administrative Area for certain countries (e.g., Andorra's
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ui/autofill/DEPS
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
include_rules = [
'+third_party/libaddressinput/chromium/addressinput_util.h',
'+third_party/libaddressinput/chromium/chrome_address_validator.h',
'+third_party/libaddressinput/chromium/chrome_downloader_impl.h',
'+third_party/libaddressinput/chromium/chrome_storage_impl.h',
'+third_party/libaddressinput/messages.h',
'+third_party/libaddressinput/src/cpp/include/libaddressinput',
'+third_party/libaddressinput/chromium/cpp/include/libaddressinput',
]
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace {

using testing::Return;
using testing::_;
using ::i18n::addressinput::AddressValidator;

void MockCallback(AutofillClient::RequestAutocompleteResult,
const base::string16& message,
Expand Down
65 changes: 31 additions & 34 deletions chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,14 @@
#include "grit/component_scaled_resources.h"
#include "grit/components_strings.h"
#include "grit/generated_resources.h"
#include "grit/libaddressinput_strings.h"
#include "grit/platform_locale_settings.h"
#include "grit/theme_resources.h"
#include "net/cert/cert_status_flags.h"
#include "third_party/libaddressinput/chromium/chrome_downloader_impl.h"
#include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
#include "third_party/libaddressinput/messages.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_problem.h"
#include "ui/base/base_window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/combobox_model.h"
Expand All @@ -101,12 +99,9 @@
using ::i18n::addressinput::AddressData;
using ::i18n::addressinput::AddressField;
using ::i18n::addressinput::AddressProblem;
using ::i18n::addressinput::ADMIN_AREA;
using ::i18n::addressinput::DEPENDENT_LOCALITY;
using ::i18n::addressinput::Downloader;
using ::i18n::addressinput::FieldProblemMap;
using ::i18n::addressinput::Localization;
using ::i18n::addressinput::MISSING_REQUIRED_FIELD;
using ::i18n::addressinput::AddressProblemFilter;
using ::i18n::addressinput::AddressProblems;
using ::i18n::addressinput::AddressValidator;

namespace autofill {

Expand Down Expand Up @@ -861,12 +856,12 @@ void AutofillDialogControllerImpl::Show() {
if (account_chooser_model_->WalletIsSelected())
FetchWalletCookie();

validator_.reset(new AddressValidator(
I18N_ADDRESS_VALIDATION_DATA_URL,
scoped_ptr<Downloader>(
new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())),
scoped_ptr< ::i18n::addressinput::Downloader> downloader(
new autofill::ChromeDownloaderImpl(profile_->GetRequestContext()));
validator_ = AddressValidator::Build(
downloader.Pass(),
ValidationRulesStorageFactory::CreateStorage(),
this));
this);

SuggestionsUpdated();
SubmitButtonDelayBegin();
Expand Down Expand Up @@ -1938,14 +1933,14 @@ base::string16 AutofillDialogControllerImpl::InputValidityMessage(
case CREDIT_CARD_EXP_MONTH:
if (!InputWasEdited(CREDIT_CARD_EXP_MONTH, value)) {
return l10n_util::GetStringUTF16(
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD);
IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD);
}
break;

case CREDIT_CARD_EXP_4_DIGIT_YEAR:
if (!InputWasEdited(CREDIT_CARD_EXP_4_DIGIT_YEAR, value)) {
return l10n_util::GetStringUTF16(
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD);
IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD);
}
break;

Expand Down Expand Up @@ -1977,7 +1972,7 @@ base::string16 AutofillDialogControllerImpl::InputValidityMessage(
}

return value.empty() ? l10n_util::GetStringUTF16(
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD) :
IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD) :
base::string16();
}

Expand All @@ -1998,19 +1993,17 @@ ValidityMessages AutofillDialogControllerImpl::InputsAreValid(
profile, g_browser_process->GetApplicationLocale());
address_data->language_code = AddressLanguageCodeForSection(section);

Localization localization;
localization.SetGetter(l10n_util::GetStringUTF8);
FieldProblemMap problems;
status = GetValidator()->ValidateAddress(*address_data, NULL, &problems);
AddressProblems problems;
status = GetValidator()->ValidateAddress(*address_data,
AddressProblemFilter(),
&problems);
common::AddressType address_type = section == SECTION_SHIPPING ?
common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING;

for (FieldProblemMap::const_iterator iter = problems.begin();
iter != problems.end(); ++iter) {
bool sure = iter->second != MISSING_REQUIRED_FIELD;
base::string16 text = base::UTF8ToUTF16(localization.GetErrorMessage(
*address_data, iter->first, iter->second, true, false));
messages.Set(i18ninput::TypeForField(iter->first, address_type),
for (size_t i = 0; i < problems.size(); ++i) {
const AddressProblem& problem = problems[i];
bool sure = problem.type != AddressProblem::MISSING_REQUIRED_FIELD;
base::string16 text = l10n_util::GetStringUTF16(problem.description_id);
messages.Set(i18ninput::TypeForField(problem.field, address_type),
ValidityMessage(text, sure));
}
}
Expand Down Expand Up @@ -3430,7 +3423,9 @@ void AutofillDialogControllerImpl::GetI18nValidatorSuggestions(
// region of the suggested address:
// ADMIN_AREA > LOCALITY > DEPENDENT_LOCALITY
popup_labels->push_back(base::string16());
for (int field = DEPENDENT_LOCALITY; field >= ADMIN_AREA; --field) {
for (int field = ::i18n::addressinput::DEPENDENT_LOCALITY;
field >= ::i18n::addressinput::ADMIN_AREA;
--field) {
const std::string& field_value =
i18n_validator_suggestions_[i].GetFieldValue(
static_cast<AddressField>(field));
Expand Down Expand Up @@ -3613,7 +3608,7 @@ bool AutofillDialogControllerImpl::RulesAreLoaded(DialogSection section) {
AddressData address_data;
address_data.region_code = CountryCodeForSection(section);
AddressValidator::Status status = GetValidator()->ValidateAddress(
address_data, NULL, NULL);
address_data, AddressProblemFilter(), NULL);
return status == AddressValidator::SUCCESS;
}

Expand Down Expand Up @@ -3665,8 +3660,10 @@ bool AutofillDialogControllerImpl::HasInvalidAddress(
i18n::CreateAddressDataFromAutofillProfile(
profile, g_browser_process->GetApplicationLocale());

FieldProblemMap problems;
GetValidator()->ValidateAddress(*address_data, NULL, &problems);
AddressProblems problems;
GetValidator()->ValidateAddress(*address_data,
AddressProblemFilter(),
&problems);
return !problems.empty();
}

Expand Down
17 changes: 6 additions & 11 deletions chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/ssl_status.h"
#include "third_party/libaddressinput/chromium/chrome_address_validator.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/load_rules_delegate.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/ui_base_types.h"
Expand All @@ -49,12 +50,6 @@ namespace content {
class WebContents;
}

namespace i18n {
namespace addressinput {
struct AddressData;
}
}

namespace autofill {

class AutofillDataModel;
Expand Down Expand Up @@ -84,7 +79,7 @@ class AutofillDialogControllerImpl
public PersonalDataManagerObserver,
public AccountChooserModelDelegate,
public gfx::AnimationDelegate,
public LoadRulesListener {
public ::i18n::addressinput::LoadRulesDelegate {
public:
virtual ~AutofillDialogControllerImpl();

Expand Down Expand Up @@ -223,7 +218,7 @@ class AutofillDialogControllerImpl
virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;

// LoadRulesListener implementation.
// ::i18n::addressinput::LoadRulesDelegate implementation.
virtual void OnAddressValidationRulesLoaded(const std::string& country_code,
bool success) OVERRIDE;

Expand Down Expand Up @@ -254,7 +249,7 @@ class AutofillDialogControllerImpl
virtual PersonalDataManager* GetManager() const;

// Returns an address validation helper. May be NULL during tests.
virtual AddressValidator* GetValidator();
virtual ::i18n::addressinput::AddressValidator* GetValidator();

// Returns the WalletClient* this class uses to talk to Online Wallet. Exposed
// for testing.
Expand Down Expand Up @@ -660,7 +655,7 @@ class AutofillDialogControllerImpl
wallet::WalletClient wallet_client_;

// A helper to validate international address input.
scoped_ptr<AddressValidator> validator_;
scoped_ptr< ::i18n::addressinput::AddressValidator> validator_;

// True if |this| has ever called GetWalletItems().
bool wallet_items_requested_;
Expand Down
29 changes: 17 additions & 12 deletions chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
// found in the LICENSE file.

#include <map>
#include <utility>

#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
Expand Down Expand Up @@ -57,9 +55,8 @@
#include "grit/generated_resources.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libaddressinput/chromium/chrome_address_validator.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"

Expand All @@ -74,7 +71,11 @@ namespace autofill {

namespace {

using ::i18n::addressinput::FieldProblemMap;
using ::i18n::addressinput::AddressData;
using ::i18n::addressinput::AddressProblemFilter;
using ::i18n::addressinput::AddressProblem;
using ::i18n::addressinput::AddressProblems;
using ::i18n::addressinput::AddressValidator;
using testing::AtLeast;
using testing::DoAll;
using testing::Return;
Expand Down Expand Up @@ -1020,9 +1021,11 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesPopInvalidIntoEdit) {
// Now make up a problem and make sure the profile isn't in the list.
Reset();
SwitchToAutofill();
FieldProblemMap problems;
problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE,
::i18n::addressinput::MISMATCHING_VALUE));
AddressProblems problems;
problems.push_back(
AddressProblem(::i18n::addressinput::POSTAL_CODE,
AddressProblem::MISMATCHING_VALUE,
IDS_LEARN_MORE));
EXPECT_CALL(*controller()->GetMockValidator(),
ValidateAddress(CountryCodeMatcher("US"), _, _)).
WillRepeatedly(DoAll(SetArgPointee<2>(problems),
Expand Down Expand Up @@ -1050,9 +1053,11 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesRevalidateAfterRulesLoad) {
EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING));

FieldProblemMap problems;
problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE,
::i18n::addressinput::MISMATCHING_VALUE));
AddressProblems problems;
problems.push_back(
AddressProblem(::i18n::addressinput::POSTAL_CODE,
AddressProblem::MISMATCHING_VALUE,
IDS_LEARN_MORE));
EXPECT_CALL(*controller()->GetMockValidator(),
ValidateAddress(CountryCodeMatcher("US"), _, _)).
WillRepeatedly(DoAll(SetArgPointee<2>(problems),
Expand Down
Loading

0 comments on commit 889a2bb

Please sign in to comment.