OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SETTINGS_SYNC_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "chrome/browser/sync/sync_startup_tracker.h" | 15 #include "chrome/browser/sync/sync_startup_tracker.h" |
16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
17 #include "components/signin/core/browser/signin_manager_base.h" | 17 #include "components/signin/core/browser/signin_manager_base.h" |
18 #include "components/sync_driver/sync_service_observer.h" | 18 #include "components/sync_driver/sync_service_observer.h" |
19 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
20 | 20 |
21 class LoginUIService; | 21 class LoginUIService; |
22 class ProfileSyncService; | 22 class ProfileSyncService; |
23 class SigninManagerBase; | 23 class SigninManagerBase; |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 class WebContents; | 26 class WebContents; |
27 class WebUI; | 27 class WebUI; |
28 } | 28 } |
29 | 29 |
30 namespace signin_metrics { | 30 namespace signin_metrics { |
31 enum class AccessPoint; | 31 enum class AccessPoint; |
32 } | 32 } |
33 | 33 |
34 namespace settings { | 34 namespace settings { |
35 | 35 |
36 class SyncHandler : public content::WebUIMessageHandler, | 36 class PeopleHandler : public content::WebUIMessageHandler, |
37 public SigninManagerBase::Observer, | 37 public SigninManagerBase::Observer, |
38 public SyncStartupTracker::Observer, | 38 public SyncStartupTracker::Observer, |
39 public LoginUIService::LoginUI, | 39 public LoginUIService::LoginUI, |
40 public sync_driver::SyncServiceObserver { | 40 public sync_driver::SyncServiceObserver { |
41 public: | 41 public: |
42 explicit SyncHandler(Profile* profile); | 42 explicit PeopleHandler(Profile* profile); |
43 ~SyncHandler() override; | 43 ~PeopleHandler() override; |
44 | 44 |
45 // content::WebUIMessageHandler implementation. | 45 // content::WebUIMessageHandler implementation. |
46 void RegisterMessages() override; | 46 void RegisterMessages() override; |
47 | 47 |
48 // SyncStartupTracker::Observer implementation. | 48 // SyncStartupTracker::Observer implementation. |
49 void SyncStartupCompleted() override; | 49 void SyncStartupCompleted() override; |
50 void SyncStartupFailed() override; | 50 void SyncStartupFailed() override; |
51 | 51 |
52 // LoginUIService::LoginUI implementation. | 52 // LoginUIService::LoginUI implementation. |
53 void FocusUI() override; | 53 void FocusUI() override; |
(...skipping 18 matching lines...) Expand all Loading... |
72 void OpenConfigureSync(); | 72 void OpenConfigureSync(); |
73 | 73 |
74 // Terminates the sync setup flow. | 74 // Terminates the sync setup flow. |
75 void CloseSyncSetup(); | 75 void CloseSyncSetup(); |
76 | 76 |
77 // Returns a newly created dictionary with a number of properties that | 77 // Returns a newly created dictionary with a number of properties that |
78 // correspond to the status of sync. | 78 // correspond to the status of sync. |
79 scoped_ptr<base::DictionaryValue> GetSyncStateDictionary(); | 79 scoped_ptr<base::DictionaryValue> GetSyncStateDictionary(); |
80 | 80 |
81 protected: | 81 protected: |
82 friend class SyncHandlerTest; | 82 friend class PeopleHandlerTest; |
83 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, | 83 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, |
84 DisplayConfigureWithBackendDisabledAndCancel); | 84 DisplayConfigureWithBackendDisabledAndCancel); |
85 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, HandleSetupUIWhenSyncDisabled); | 85 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled); |
86 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, SelectCustomEncryption); | 86 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, SelectCustomEncryption); |
87 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn); | 87 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn); |
88 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, SuccessfullySetPassphrase); | 88 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, SuccessfullySetPassphrase); |
89 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncEverything); | 89 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncEverything); |
90 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncNothing); | 90 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncNothing); |
91 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncAllManually); | 91 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncAllManually); |
92 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestPassphraseStillRequired); | 92 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestPassphraseStillRequired); |
93 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncIndividualTypes); | 93 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncIndividualTypes); |
94 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TurnOnEncryptAll); | 94 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TurnOnEncryptAll); |
95 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TurnOnEncryptAllDisallowed); | 95 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TurnOnEncryptAllDisallowed); |
96 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, UnsuccessfullySetPassphrase); | 96 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, UnsuccessfullySetPassphrase); |
97 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, | 97 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, |
98 UnrecoverableErrorInitializingSync); | 98 UnrecoverableErrorInitializingSync); |
99 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, | 99 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync); |
100 GaiaErrorInitializingSync); | 100 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, HandleCaptcha); |
101 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, HandleCaptcha); | 101 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure); |
102 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, HandleGaiaAuthFailure); | 102 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, |
103 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, | |
104 SubmitAuthWithInvalidUsername); | 103 SubmitAuthWithInvalidUsername); |
105 FRIEND_TEST_ALL_PREFIXES(SyncHandlerFirstSigninTest, DisplayBasicLogin); | 104 FRIEND_TEST_ALL_PREFIXES(PeopleHandlerFirstSigninTest, DisplayBasicLogin); |
106 | 105 |
107 bool is_configuring_sync() const { return configuring_sync_; } | 106 bool is_configuring_sync() const { return configuring_sync_; } |
108 | 107 |
109 // Called when configuring sync is done to close the dialog and start syncing. | 108 // Called when configuring sync is done to close the dialog and start syncing. |
110 void ConfigureSyncDone(); | 109 void ConfigureSyncDone(); |
111 | 110 |
112 // Helper routine that gets the ProfileSyncService associated with the parent | 111 // Helper routine that gets the ProfileSyncService associated with the parent |
113 // profile. | 112 // profile. |
114 ProfileSyncService* GetSyncService() const; | 113 ProfileSyncService* GetSyncService() const; |
115 | 114 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 bool configuring_sync_; | 183 bool configuring_sync_; |
185 | 184 |
186 // The OneShotTimer object used to timeout of starting the sync backend | 185 // The OneShotTimer object used to timeout of starting the sync backend |
187 // service. | 186 // service. |
188 scoped_ptr<base::OneShotTimer> backend_start_timer_; | 187 scoped_ptr<base::OneShotTimer> backend_start_timer_; |
189 | 188 |
190 // Used to listen for pref changes to allow or disallow signin. | 189 // Used to listen for pref changes to allow or disallow signin. |
191 PrefChangeRegistrar profile_pref_registrar_; | 190 PrefChangeRegistrar profile_pref_registrar_; |
192 | 191 |
193 // Manages observer lifetime. | 192 // Manages observer lifetime. |
194 ScopedObserver<ProfileSyncService, SyncHandler> sync_service_observer_; | 193 ScopedObserver<ProfileSyncService, PeopleHandler> sync_service_observer_; |
195 | 194 |
196 DISALLOW_COPY_AND_ASSIGN(SyncHandler); | 195 DISALLOW_COPY_AND_ASSIGN(PeopleHandler); |
197 }; | 196 }; |
198 | 197 |
199 } // namespace settings | 198 } // namespace settings |
200 | 199 |
201 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ | 200 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
OLD | NEW |