| OLD | NEW |
| 1 // Copyright (c) 2012 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_OPTIONS_SYNC_SETUP_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_SYNC_SETUP_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 11 #include "chrome/browser/sync/sync_startup_tracker.h" | 12 #include "chrome/browser/sync/sync_startup_tracker.h" |
| 12 #include "chrome/browser/ui/webui/options/options_ui.h" | |
| 13 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 13 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 14 #include "content/public/browser/web_ui_message_handler.h" |
| 14 | 15 |
| 15 class LoginUIService; | 16 class LoginUIService; |
| 16 class ProfileSyncService; | 17 class ProfileSyncService; |
| 17 class SigninManagerBase; | 18 class SigninManagerBase; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class WebContents; | 21 class WebContents; |
| 22 class WebUI; |
| 21 } | 23 } |
| 22 | 24 |
| 23 class SyncSetupHandler : public options::OptionsPageUIHandler, | 25 namespace settings { |
| 24 public SyncStartupTracker::Observer, | 26 |
| 25 public LoginUIService::LoginUI { | 27 class SyncHandler : public content::WebUIMessageHandler, |
| 28 public SyncStartupTracker::Observer, |
| 29 public LoginUIService::LoginUI { |
| 26 public: | 30 public: |
| 27 SyncSetupHandler(); | 31 SyncHandler(); |
| 28 ~SyncSetupHandler() override; | 32 ~SyncHandler() override; |
| 29 | 33 |
| 30 // OptionsPageUIHandler implementation. | 34 // content::WebUIMessageHandler implementation. |
| 31 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | |
| 32 void RegisterMessages() override; | 35 void RegisterMessages() override; |
| 33 | 36 |
| 34 // SyncStartupTracker::Observer implementation; | 37 // SyncStartupTracker::Observer implementation; |
| 35 void SyncStartupCompleted() override; | 38 void SyncStartupCompleted() override; |
| 36 void SyncStartupFailed() override; | 39 void SyncStartupFailed() override; |
| 37 | 40 |
| 38 // LoginUIService::LoginUI implementation. | 41 // LoginUIService::LoginUI implementation. |
| 39 void FocusUI() override; | 42 void FocusUI() override; |
| 40 void CloseUI() override; | 43 void CloseUI() override; |
| 41 | 44 |
| 42 static void GetStaticLocalizedValues( | |
| 43 base::DictionaryValue* localized_strings, | |
| 44 content::WebUI* web_ui); | |
| 45 | |
| 46 // Initializes the sync setup flow and shows the setup UI. | 45 // Initializes the sync setup flow and shows the setup UI. |
| 47 void OpenSyncSetup(); | 46 void OpenSyncSetup(); |
| 48 | 47 |
| 49 // Shows advanced configuration dialog without going through sign in dialog. | 48 // Shows advanced configuration dialog without going through sign in dialog. |
| 50 // Kicks the sync backend if necessary with showing spinner dialog until it | 49 // Kicks the sync backend if necessary with showing spinner dialog until it |
| 51 // gets ready. | 50 // gets ready. |
| 52 void OpenConfigureSync(); | 51 void OpenConfigureSync(); |
| 53 | 52 |
| 54 // Terminates the sync setup flow. | 53 // Terminates the sync setup flow. |
| 55 void CloseSyncSetup(); | 54 void CloseSyncSetup(); |
| 56 | 55 |
| 57 protected: | 56 protected: |
| 58 friend class SyncSetupHandlerTest; | 57 friend class SyncHandlerTest; |
| 59 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, | 58 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, |
| 60 DisplayConfigureWithBackendDisabledAndCancel); | 59 DisplayConfigureWithBackendDisabledAndCancel); |
| 61 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, HandleSetupUIWhenSyncDisabled); | 60 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, HandleSetupUIWhenSyncDisabled); |
| 62 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SelectCustomEncryption); | 61 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, SelectCustomEncryption); |
| 63 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn); | 62 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn); |
| 64 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SuccessfullySetPassphrase); | 63 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, SuccessfullySetPassphrase); |
| 65 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncEverything); | 64 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncEverything); |
| 66 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncNothing); | 65 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncNothing); |
| 67 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncAllManually); | 66 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncAllManually); |
| 68 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestPassphraseStillRequired); | 67 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestPassphraseStillRequired); |
| 69 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncIndividualTypes); | 68 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TestSyncIndividualTypes); |
| 70 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAll); | 69 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TurnOnEncryptAll); |
| 71 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed); | 70 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, TurnOnEncryptAllDisallowed); |
| 72 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, UnsuccessfullySetPassphrase); | 71 FRIEND_TEST_ALL_PREFIXES(SyncHandlerTest, UnsuccessfullySetPassphrase); |
| 73 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, | 72 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, |
| 74 UnrecoverableErrorInitializingSync); | 73 UnrecoverableErrorInitializingSync); |
| 75 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, | 74 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, |
| 76 GaiaErrorInitializingSync); | 75 GaiaErrorInitializingSync); |
| 77 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleCaptcha); | 76 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, HandleCaptcha); |
| 78 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure); | 77 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, HandleGaiaAuthFailure); |
| 79 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, | 78 FRIEND_TEST_ALL_PREFIXES(SyncHandlerNonCrosTest, |
| 80 SubmitAuthWithInvalidUsername); | 79 SubmitAuthWithInvalidUsername); |
| 81 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin); | 80 FRIEND_TEST_ALL_PREFIXES(SyncHandlerFirstSigninTest, DisplayBasicLogin); |
| 82 | 81 |
| 83 bool is_configuring_sync() const { return configuring_sync_; } | 82 bool is_configuring_sync() const { return configuring_sync_; } |
| 84 | 83 |
| 85 // Called when configuring sync is done to close the dialog and start syncing. | 84 // Called when configuring sync is done to close the dialog and start syncing. |
| 86 void ConfigureSyncDone(); | 85 void ConfigureSyncDone(); |
| 87 | 86 |
| 88 // Helper routine that gets the ProfileSyncService associated with the parent | 87 // Helper routine that gets the ProfileSyncService associated with the parent |
| 89 // profile. | 88 // profile. |
| 90 ProfileSyncService* GetSyncService() const; | 89 ProfileSyncService* GetSyncService() const; |
| 91 | 90 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 146 |
| 148 // Set to true whenever the sync configure UI is visible. This is used to tell | 147 // Set to true whenever the sync configure UI is visible. This is used to tell |
| 149 // what stage of the setup wizard the user was in and to update the UMA | 148 // what stage of the setup wizard the user was in and to update the UMA |
| 150 // histograms in the case that the user cancels out. | 149 // histograms in the case that the user cancels out. |
| 151 bool configuring_sync_; | 150 bool configuring_sync_; |
| 152 | 151 |
| 153 // The OneShotTimer object used to timeout of starting the sync backend | 152 // The OneShotTimer object used to timeout of starting the sync backend |
| 154 // service. | 153 // service. |
| 155 scoped_ptr<base::OneShotTimer> backend_start_timer_; | 154 scoped_ptr<base::OneShotTimer> backend_start_timer_; |
| 156 | 155 |
| 157 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler); | 156 DISALLOW_COPY_AND_ASSIGN(SyncHandler); |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_SYNC_SETUP_HANDLER_H_ | 159 } // namespace settings |
| 160 |
| 161 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ |
| OLD | NEW |