| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/ui/webui/options/options_ui.h" | 14 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 15 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 15 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 16 #include "components/browser_sync/browser/profile_sync_service.h" | |
| 17 #include "components/sync_driver/sync_service_observer.h" | |
| 18 | 16 |
| 19 namespace autofill { | 17 namespace autofill { |
| 20 class AutofillProfile; | 18 class AutofillProfile; |
| 21 class PersonalDataManager; | 19 class PersonalDataManager; |
| 22 } // namespace autofill | 20 } // namespace autofill |
| 23 | 21 |
| 24 namespace base { | 22 namespace base { |
| 25 class DictionaryValue; | 23 class DictionaryValue; |
| 26 class ListValue; | 24 class ListValue; |
| 27 } | 25 } |
| 28 | 26 |
| 29 namespace options { | 27 namespace options { |
| 30 | 28 |
| 31 class AutofillOptionsHandler : public OptionsPageUIHandler, | 29 class AutofillOptionsHandler : public OptionsPageUIHandler, |
| 32 public autofill::PersonalDataManagerObserver, | 30 public autofill::PersonalDataManagerObserver { |
| 33 public sync_driver::SyncServiceObserver { | |
| 34 public: | 31 public: |
| 35 AutofillOptionsHandler(); | 32 AutofillOptionsHandler(); |
| 36 ~AutofillOptionsHandler() override; | 33 ~AutofillOptionsHandler() override; |
| 37 | 34 |
| 38 // OptionsPageUIHandler implementation. | 35 // OptionsPageUIHandler implementation. |
| 39 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | 36 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; |
| 40 void InitializeHandler() override; | 37 void InitializeHandler() override; |
| 41 void InitializePage() override; | 38 void InitializePage() override; |
| 42 void RegisterMessages() override; | 39 void RegisterMessages() override; |
| 43 | 40 |
| 44 // PersonalDataManagerObserver implementation. | 41 // PersonalDataManagerObserver implementation. |
| 45 void OnPersonalDataChanged() override; | 42 void OnPersonalDataChanged() override; |
| 46 | 43 |
| 47 // sync_driver::SyncServiceObserver implementation. | |
| 48 void OnStateChanged() override; | |
| 49 | |
| 50 private: | 44 private: |
| 51 FRIEND_TEST_ALL_PREFIXES(AutofillOptionsHandlerTest, AddressToDictionary); | 45 FRIEND_TEST_ALL_PREFIXES(AutofillOptionsHandlerTest, AddressToDictionary); |
| 52 | 46 |
| 53 // Loads the strings for the address and credit card overlays. | 47 // Loads the strings for the address and credit card overlays. |
| 54 void SetAddressOverlayStrings(base::DictionaryValue* localized_strings); | 48 void SetAddressOverlayStrings(base::DictionaryValue* localized_strings); |
| 55 void SetCreditCardOverlayStrings(base::DictionaryValue* localized_strings); | 49 void SetCreditCardOverlayStrings(base::DictionaryValue* localized_strings); |
| 56 | 50 |
| 57 // Loads Autofill addresses and credit cards using the PersonalDataManager. | 51 // Loads Autofill addresses and credit cards using the PersonalDataManager. |
| 58 void LoadAutofillData(); | 52 void LoadAutofillData(); |
| 59 | 53 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 99 |
| 106 // Fills in |address| with the data format that the options js expects. | 100 // Fills in |address| with the data format that the options js expects. |
| 107 static void AutofillProfileToDictionary( | 101 static void AutofillProfileToDictionary( |
| 108 const autofill::AutofillProfile& profile, | 102 const autofill::AutofillProfile& profile, |
| 109 base::DictionaryValue* address); | 103 base::DictionaryValue* address); |
| 110 | 104 |
| 111 // The personal data manager, used to load Autofill profiles and credit cards. | 105 // The personal data manager, used to load Autofill profiles and credit cards. |
| 112 // Unowned pointer, may not be NULL. | 106 // Unowned pointer, may not be NULL. |
| 113 autofill::PersonalDataManager* personal_data_; | 107 autofill::PersonalDataManager* personal_data_; |
| 114 | 108 |
| 115 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver> | |
| 116 observer_; | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler); | 109 DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler); |
| 119 }; | 110 }; |
| 120 | 111 |
| 121 } // namespace options | 112 } // namespace options |
| 122 | 113 |
| 123 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_ | 114 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_ |
| OLD | NEW |