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