| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_AUTOFILL_OPTIONS_HANDLER2_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_AUTOFILL_OPTIONS_HANDLER2_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "chrome/browser/autofill/personal_data_manager_observer.h" | |
| 12 #include "chrome/browser/ui/webui/options2/options_ui2.h" | |
| 13 | |
| 14 class PersonalDataManager; | |
| 15 | |
| 16 namespace base { | |
| 17 class DictionaryValue; | |
| 18 class ListValue; | |
| 19 } | |
| 20 | |
| 21 namespace options2 { | |
| 22 | |
| 23 class AutofillOptionsHandler : public OptionsPageUIHandler, | |
| 24 public PersonalDataManagerObserver { | |
| 25 public: | |
| 26 AutofillOptionsHandler(); | |
| 27 virtual ~AutofillOptionsHandler(); | |
| 28 | |
| 29 // OptionsPageUIHandler implementation. | |
| 30 virtual void GetLocalizedValues( | |
| 31 base::DictionaryValue* localized_strings) OVERRIDE; | |
| 32 virtual void InitializeHandler() OVERRIDE; | |
| 33 virtual void InitializePage() OVERRIDE; | |
| 34 virtual void RegisterMessages() OVERRIDE; | |
| 35 | |
| 36 // PersonalDataManagerObserver implementation. | |
| 37 virtual void OnPersonalDataChanged() OVERRIDE; | |
| 38 | |
| 39 private: | |
| 40 // Loads the strings for the address and credit card overlays. | |
| 41 void SetAddressOverlayStrings(base::DictionaryValue* localized_strings); | |
| 42 void SetCreditCardOverlayStrings(base::DictionaryValue* localized_strings); | |
| 43 | |
| 44 // Loads Autofill addresses and credit cards using the PersonalDataManager. | |
| 45 void LoadAutofillData(); | |
| 46 | |
| 47 // Removes an address from the PersonalDataManager. | |
| 48 // |args| - A string, the GUID of the address to remove. | |
| 49 void RemoveAddress(const base::ListValue* args); | |
| 50 | |
| 51 // Removes a credit card from the PersonalDataManager. | |
| 52 // |args| - A string, the GUID of the credit card to remove. | |
| 53 void RemoveCreditCard(const base::ListValue* args); | |
| 54 | |
| 55 // Requests profile data for a specific address. Calls into WebUI with the | |
| 56 // loaded profile data to open the address editor. | |
| 57 // |args| - A string, the GUID of the address to load. | |
| 58 void LoadAddressEditor(const base::ListValue* args); | |
| 59 | |
| 60 // Requests profile data for a specific credit card. Calls into WebUI with the | |
| 61 // loaded profile data to open the credit card editor. | |
| 62 // |args| - A string, the GUID of the credit card to load. | |
| 63 void LoadCreditCardEditor(const base::ListValue* args); | |
| 64 | |
| 65 // Adds or updates an address, depending on the GUID of the profile. If the | |
| 66 // GUID is empty, a new address is added to the WebDatabase; otherwise, the | |
| 67 // address with the matching GUID is updated. Called from WebUI. | |
| 68 // |args| - an array containing the GUID of the address followed by the | |
| 69 // address data. | |
| 70 void SetAddress(const base::ListValue* args); | |
| 71 | |
| 72 // Adds or updates a credit card, depending on the GUID of the profile. If the | |
| 73 // GUID is empty, a new credit card is added to the WebDatabase; otherwise, | |
| 74 // the credit card with the matching GUID is updated. Called from WebUI. | |
| 75 // |args| - an array containing the GUID of the credit card followed by the | |
| 76 // credit card data. | |
| 77 void SetCreditCard(const base::ListValue* args); | |
| 78 | |
| 79 // Validates a list of phone numbers. The resulting validated list of | |
| 80 // numbers is then sent back to the WebUI. | |
| 81 // |args| - an array containing the index of the modified or added number, the | |
| 82 // array of numbers, and the country code string set on the profile. | |
| 83 void ValidatePhoneNumbers(const base::ListValue* args); | |
| 84 | |
| 85 // Returns true if |personal_data_| is non-null and loaded. | |
| 86 bool IsPersonalDataLoaded() const; | |
| 87 | |
| 88 // The personal data manager, used to load Autofill profiles and credit cards. | |
| 89 // Unowned pointer, may not be NULL. | |
| 90 PersonalDataManager* personal_data_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler); | |
| 93 }; | |
| 94 | |
| 95 } // namespace options2 | |
| 96 | |
| 97 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_AUTOFILL_OPTIONS_HANDLER2_H_ | |
| OLD | NEW |