OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 #if defined(OS_MACOSX) | 325 #if defined(OS_MACOSX) |
326 { "auxiliaryProfilesEnabled", IDS_AUTOFILL_USE_MAC_ADDRESS_BOOK }, | 326 { "auxiliaryProfilesEnabled", IDS_AUTOFILL_USE_MAC_ADDRESS_BOOK }, |
327 #endif // defined(OS_MACOSX) | 327 #endif // defined(OS_MACOSX) |
328 }; | 328 }; |
329 | 329 |
330 RegisterStrings(localized_strings, resources, arraysize(resources)); | 330 RegisterStrings(localized_strings, resources, arraysize(resources)); |
331 RegisterTitle(localized_strings, "autofillOptionsPage", | 331 RegisterTitle(localized_strings, "autofillOptionsPage", |
332 IDS_AUTOFILL_OPTIONS_TITLE); | 332 IDS_AUTOFILL_OPTIONS_TITLE); |
333 | 333 |
334 localized_strings->SetString("helpUrl", autofill::kHelpURL); | 334 localized_strings->SetString("helpUrl", autofill::kHelpURL); |
| 335 |
| 336 personal_data_ = autofill::PersonalDataManagerFactory::GetForProfile( |
| 337 Profile::FromWebUI(web_ui())); |
| 338 |
335 SetAddressOverlayStrings(localized_strings); | 339 SetAddressOverlayStrings(localized_strings); |
336 SetCreditCardOverlayStrings(localized_strings); | 340 SetCreditCardOverlayStrings(localized_strings); |
337 | 341 |
338 localized_strings->SetBoolean( | 342 localized_strings->SetBoolean( |
339 "enableAutofillWalletIntegration", | 343 "enableAutofillWalletIntegration", |
340 base::CommandLine::ForCurrentProcess()->HasSwitch( | 344 personal_data_->IsExperimentalWalletIntegrationEnabled()); |
341 autofill::switches::kEnableWalletCardImport)); | |
342 localized_strings->SetString( | 345 localized_strings->SetString( |
343 "manageWalletAddressesUrl", | 346 "manageWalletAddressesUrl", |
344 autofill::wallet::GetManageAddressesUrl(0).spec()); | 347 autofill::wallet::GetManageAddressesUrl(0).spec()); |
345 localized_strings->SetString( | 348 localized_strings->SetString( |
346 "manageWalletPaymentMethodsUrl", | 349 "manageWalletPaymentMethodsUrl", |
347 autofill::wallet::GetManageInstrumentsUrl(0).spec()); | 350 autofill::wallet::GetManageInstrumentsUrl(0).spec()); |
348 } | 351 } |
349 | 352 |
350 void AutofillOptionsHandler::InitializeHandler() { | 353 void AutofillOptionsHandler::InitializeHandler() { |
351 // personal_data_ is NULL in guest mode on Chrome OS. | 354 // personal_data_ is NULL in guest mode on Chrome OS. |
352 if (personal_data_) | 355 if (personal_data_) |
353 personal_data_->AddObserver(this); | 356 personal_data_->AddObserver(this); |
354 } | 357 } |
355 | 358 |
356 void AutofillOptionsHandler::InitializePage() { | 359 void AutofillOptionsHandler::InitializePage() { |
357 if (personal_data_) | 360 if (personal_data_) |
358 LoadAutofillData(); | 361 LoadAutofillData(); |
359 } | 362 } |
360 | 363 |
361 void AutofillOptionsHandler::RegisterMessages() { | 364 void AutofillOptionsHandler::RegisterMessages() { |
362 personal_data_ = autofill::PersonalDataManagerFactory::GetForProfile( | |
363 Profile::FromWebUI(web_ui())); | |
364 | |
365 #if defined(OS_MACOSX) && !defined(OS_IOS) | 365 #if defined(OS_MACOSX) && !defined(OS_IOS) |
366 web_ui()->RegisterMessageCallback( | 366 web_ui()->RegisterMessageCallback( |
367 "accessAddressBook", | 367 "accessAddressBook", |
368 base::Bind(&AutofillOptionsHandler::AccessAddressBook, | 368 base::Bind(&AutofillOptionsHandler::AccessAddressBook, |
369 base::Unretained(this))); | 369 base::Unretained(this))); |
370 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 370 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
371 web_ui()->RegisterMessageCallback( | 371 web_ui()->RegisterMessageCallback( |
372 "removeData", | 372 "removeData", |
373 base::Bind(&AutofillOptionsHandler::RemoveData, | 373 base::Bind(&AutofillOptionsHandler::RemoveData, |
374 base::Unretained(this))); | 374 base::Unretained(this))); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 scoped_ptr<base::ListValue> components(new base::ListValue); | 733 scoped_ptr<base::ListValue> components(new base::ListValue); |
734 GetAddressComponents( | 734 GetAddressComponents( |
735 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), | 735 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), |
736 profile.language_code(), | 736 profile.language_code(), |
737 components.get(), | 737 components.get(), |
738 NULL); | 738 NULL); |
739 address->Set(kComponents, components.release()); | 739 address->Set(kComponents, components.release()); |
740 } | 740 } |
741 | 741 |
742 } // namespace options | 742 } // namespace options |
OLD | NEW |