Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / autofill_options_handler.h
blob79f7c862a152a5aaaaad9fd735b9b0bf26674c51
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/ui/webui/options/options_ui.h"
13 #include "components/autofill/core/browser/personal_data_manager_observer.h"
14 #include "components/sync_driver/sync_service_observer.h"
16 namespace autofill {
17 class AutofillProfile;
18 class PersonalDataManager;
19 } // namespace autofill
21 namespace base {
22 class DictionaryValue;
23 class ListValue;
26 namespace options {
28 class AutofillOptionsHandler : public OptionsPageUIHandler,
29 public autofill::PersonalDataManagerObserver,
30 public sync_driver::SyncServiceObserver {
31 public:
32 AutofillOptionsHandler();
33 ~AutofillOptionsHandler() override;
35 // OptionsPageUIHandler implementation.
36 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
37 void InitializeHandler() override;
38 void InitializePage() override;
39 void RegisterMessages() override;
41 // PersonalDataManagerObserver implementation.
42 void OnPersonalDataChanged() override;
44 // sync_driver::SyncServiceObserver implementation.
45 void OnStateChanged() override;
47 private:
48 FRIEND_TEST_ALL_PREFIXES(AutofillOptionsHandlerTest, AddressToDictionary);
50 // Loads the strings for the address and credit card overlays.
51 void SetAddressOverlayStrings(base::DictionaryValue* localized_strings);
52 void SetCreditCardOverlayStrings(base::DictionaryValue* localized_strings);
54 // Loads Autofill addresses and credit cards using the PersonalDataManager.
55 void LoadAutofillData();
57 // Removes data from the PersonalDataManager.
58 // |args| - A string, the GUID of the address or credit card to remove.
59 void RemoveData(const base::ListValue* args);
61 // Requests profile data for a specific address. Calls into WebUI with the
62 // loaded profile data to open the address editor.
63 // |args| - A string, the GUID of the address to load.
64 void LoadAddressEditor(const base::ListValue* args);
66 // Requests input form layout information for a specific country code. Calls
67 // into WebUI with the layout information.
68 // |args| - A string, the country code to load.
69 void LoadAddressEditorComponents(const base::ListValue* args);
71 // Requests profile data for a specific credit card. Calls into WebUI with the
72 // loaded profile data to open the credit card editor.
73 // |args| - A string, the GUID of the credit card to load.
74 void LoadCreditCardEditor(const base::ListValue* args);
76 // Adds or updates an address, depending on the GUID of the profile. If the
77 // GUID is empty, a new address is added to the WebDatabase; otherwise, the
78 // address with the matching GUID is updated. Called from WebUI.
79 // |args| - an array containing the GUID of the address followed by the
80 // address data.
81 void SetAddress(const base::ListValue* args);
83 // Adds or updates a credit card, depending on the GUID of the profile. If the
84 // GUID is empty, a new credit card is added to the WebDatabase; otherwise,
85 // the credit card with the matching GUID is updated. Called from WebUI.
86 // |args| - an array containing the GUID of the credit card followed by the
87 // credit card data.
88 void SetCreditCard(const base::ListValue* args);
90 // Validates a list of phone numbers. The resulting validated list of
91 // numbers is then sent back to the WebUI.
92 // |args| - an array containing the index of the modified or added number, the
93 // array of numbers, and the country code string set on the profile.
94 void ValidatePhoneNumbers(const base::ListValue* args);
96 // Resets the masked state on the unmasked Wallet card described by the GUID
97 // in args[0].
98 void RemaskServerCard(const base::ListValue* args);
100 // Returns true if |personal_data_| is non-null and loaded.
101 bool IsPersonalDataLoaded() const;
103 // Fills in |address| with the data format that the options js expects.
104 static void AutofillProfileToDictionary(
105 const autofill::AutofillProfile& profile,
106 base::DictionaryValue* address);
108 // The personal data manager, used to load Autofill profiles and credit cards.
109 // Unowned pointer, may not be NULL.
110 autofill::PersonalDataManager* personal_data_;
112 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver>
113 observer_;
115 DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler);
118 } // namespace options
120 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_