Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / autofill_options_handler.h
blob91a45a1a4fdc529f4dc6eb2eb37ae2495125a013
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 #if defined(OS_MACOSX) && !defined(OS_IOS)
58 // The user wants to grant Chrome access to the user's Address Book.
59 // Immediately try to access the Address Book so that the blocking dialog is
60 // shown in context, rather than at a later, surprising time.
61 void AccessAddressBook(const base::ListValue* args);
62 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
64 // Removes data from the PersonalDataManager.
65 // |args| - A string, the GUID of the address or credit card to remove.
66 void RemoveData(const base::ListValue* args);
68 // Requests profile data for a specific address. Calls into WebUI with the
69 // loaded profile data to open the address editor.
70 // |args| - A string, the GUID of the address to load.
71 void LoadAddressEditor(const base::ListValue* args);
73 // Requests input form layout information for a specific country code. Calls
74 // into WebUI with the layout information.
75 // |args| - A string, the country code to load.
76 void LoadAddressEditorComponents(const base::ListValue* args);
78 // Requests profile data for a specific credit card. Calls into WebUI with the
79 // loaded profile data to open the credit card editor.
80 // |args| - A string, the GUID of the credit card to load.
81 void LoadCreditCardEditor(const base::ListValue* args);
83 // Adds or updates an address, depending on the GUID of the profile. If the
84 // GUID is empty, a new address is added to the WebDatabase; otherwise, the
85 // address with the matching GUID is updated. Called from WebUI.
86 // |args| - an array containing the GUID of the address followed by the
87 // address data.
88 void SetAddress(const base::ListValue* args);
90 // Adds or updates a credit card, depending on the GUID of the profile. If the
91 // GUID is empty, a new credit card is added to the WebDatabase; otherwise,
92 // the credit card with the matching GUID is updated. Called from WebUI.
93 // |args| - an array containing the GUID of the credit card followed by the
94 // credit card data.
95 void SetCreditCard(const base::ListValue* args);
97 // Validates a list of phone numbers. The resulting validated list of
98 // numbers is then sent back to the WebUI.
99 // |args| - an array containing the index of the modified or added number, the
100 // array of numbers, and the country code string set on the profile.
101 void ValidatePhoneNumbers(const base::ListValue* args);
103 // Resets the masked state on the unmasked Wallet card described by the GUID
104 // in args[0].
105 void RemaskServerCard(const base::ListValue* args);
107 // Returns true if |personal_data_| is non-null and loaded.
108 bool IsPersonalDataLoaded() const;
110 // Fills in |address| with the data format that the options js expects.
111 static void AutofillProfileToDictionary(
112 const autofill::AutofillProfile& profile,
113 base::DictionaryValue* address);
115 // The personal data manager, used to load Autofill profiles and credit cards.
116 // Unowned pointer, may not be NULL.
117 autofill::PersonalDataManager* personal_data_;
119 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver>
120 observer_;
122 DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler);
125 } // namespace options
127 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_