Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler.h

Issue 1421893005: Settings Rewrite: Fork SyncSetupHandler for MD-Settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_SYNC_SETUP_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_SYNC_SETUP_HANDLER_H_
7
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer/timer.h"
11 #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"
14
15 class LoginUIService;
16 class ProfileSyncService;
17 class SigninManagerBase;
18
19 namespace content {
20 class WebContents;
21 }
22
23 class SyncSetupHandler : public options::OptionsPageUIHandler,
24 public SyncStartupTracker::Observer,
25 public LoginUIService::LoginUI {
26 public:
27 SyncSetupHandler();
28 ~SyncSetupHandler() override;
29
30 // OptionsPageUIHandler implementation.
31 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
32 void RegisterMessages() override;
33
34 // SyncStartupTracker::Observer implementation;
35 void SyncStartupCompleted() override;
36 void SyncStartupFailed() override;
37
38 // LoginUIService::LoginUI implementation.
39 void FocusUI() override;
40 void CloseUI() override;
41
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.
47 void OpenSyncSetup();
48
49 // Shows advanced configuration dialog without going through sign in dialog.
50 // Kicks the sync backend if necessary with showing spinner dialog until it
51 // gets ready.
52 void OpenConfigureSync();
53
54 // Terminates the sync setup flow.
55 void CloseSyncSetup();
56
57 protected:
58 friend class SyncSetupHandlerTest;
59 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest,
60 DisplayConfigureWithBackendDisabledAndCancel);
61 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, HandleSetupUIWhenSyncDisabled);
62 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SelectCustomEncryption);
63 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn);
64 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SuccessfullySetPassphrase);
65 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncEverything);
66 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncNothing);
67 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncAllManually);
68 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestPassphraseStillRequired);
69 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncIndividualTypes);
70 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAll);
71 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed);
72 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, UnsuccessfullySetPassphrase);
73 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
74 UnrecoverableErrorInitializingSync);
75 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
76 GaiaErrorInitializingSync);
77 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleCaptcha);
78 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure);
79 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
80 SubmitAuthWithInvalidUsername);
81 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin);
82
83 bool is_configuring_sync() const { return configuring_sync_; }
84
85 // Called when configuring sync is done to close the dialog and start syncing.
86 void ConfigureSyncDone();
87
88 // Helper routine that gets the ProfileSyncService associated with the parent
89 // profile.
90 ProfileSyncService* GetSyncService() const;
91
92 // Returns the LoginUIService for the parent profile.
93 LoginUIService* GetLoginUIService() const;
94
95 private:
96 // Callbacks from the page.
97 void OnDidClosePage(const base::ListValue* args);
98 void HandleConfigure(const base::ListValue* args);
99 void HandlePassphraseEntry(const base::ListValue* args);
100 void HandlePassphraseCancel(const base::ListValue* args);
101 void HandleShowSetupUI(const base::ListValue* args);
102 void HandleDoSignOutOnAuthError(const base::ListValue* args);
103 void HandleStartSignin(const base::ListValue* args);
104 void HandleStopSyncing(const base::ListValue* args);
105 void HandleCloseTimeout(const base::ListValue* args);
106 #if !defined(OS_CHROMEOS)
107 // Displays the GAIA login form.
108 void DisplayGaiaLogin();
109
110 // When web-flow is enabled, displays the Gaia login form in a new tab.
111 // This function is virtual so that tests can override.
112 virtual void DisplayGaiaLoginInNewTabOrWindow();
113 #endif
114
115 // Helper routine that gets the Profile associated with this object (virtual
116 // so tests can override).
117 virtual Profile* GetProfile() const;
118
119 // A utility function to call before actually showing setup dialog. Makes sure
120 // that a new dialog can be shown and sets flag that setup is in progress.
121 bool PrepareSyncSetup();
122
123 // Displays spinner-only UI indicating that something is going on in the
124 // background.
125 // TODO(kochi): better to show some message that the user can understand what
126 // is running in the background.
127 void DisplaySpinner();
128
129 // Displays an error dialog which shows timeout of starting the sync backend.
130 void DisplayTimeout();
131
132 // Returns true if this object is the active login object.
133 bool IsActiveLogin() const;
134
135 // If a wizard already exists, return true. Otherwise, return false.
136 bool IsExistingWizardPresent();
137
138 // If a wizard already exists, focus it and return true.
139 bool FocusExistingWizardIfPresent();
140
141 // Display the configure sync UI. If |passphrase_failed| is true, the account
142 // requires a passphrase and one hasn't been provided or it was invalid.
143 void DisplayConfigureSync(bool passphrase_failed);
144
145 // Helper object used to wait for the sync backend to startup.
146 scoped_ptr<SyncStartupTracker> sync_startup_tracker_;
147
148 // 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
150 // histograms in the case that the user cancels out.
151 bool configuring_sync_;
152
153 // The OneShotTimer object used to timeout of starting the sync backend
154 // service.
155 scoped_ptr<base::OneShotTimer> backend_start_timer_;
156
157 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler);
158 };
159
160 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_SYNC_SETUP_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698