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