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

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

Issue 12502017: signin: pull basic SigninManager functionality into new SigninManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deal with new enterprise_platform_keys_private_api Created 7 years, 8 months 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 | Annotate | Revision Log
OLDNEW
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_SYNC_SETUP_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer.h" 10 #include "base/timer.h"
11 #include "chrome/browser/signin/signin_tracker.h" 11 #include "chrome/browser/signin/signin_tracker.h"
12 #include "chrome/browser/ui/webui/options/options_ui.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_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 15
16 class LoginUIService; 16 class LoginUIService;
17 class ProfileManager; 17 class ProfileManager;
18 class ProfileSyncService; 18 class ProfileSyncService;
19 class SigninManager; 19 class SigninManagerBase;
20 20
21 namespace content { 21 namespace content {
22 class WebContents; 22 class WebContents;
23 } 23 }
24 24
25 class SyncSetupHandler : public options::OptionsPageUIHandler, 25 class SyncSetupHandler : public options::OptionsPageUIHandler,
26 public SigninTracker::Observer, 26 public SigninTracker::Observer,
27 public LoginUIService::LoginUI, 27 public LoginUIService::LoginUI,
28 public content::WebContentsObserver { 28 public content::WebContentsObserver {
29 public: 29 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Shows advanced configuration dialog without going through sign in dialog. 64 // Shows advanced configuration dialog without going through sign in dialog.
65 // Kicks the sync backend if necessary with showing spinner dialog until it 65 // Kicks the sync backend if necessary with showing spinner dialog until it
66 // gets ready. 66 // gets ready.
67 void OpenConfigureSync(); 67 void OpenConfigureSync();
68 68
69 // Terminates the sync setup flow. 69 // Terminates the sync setup flow.
70 void CloseSyncSetup(); 70 void CloseSyncSetup();
71 71
72 protected: 72 protected:
73 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, GaiaErrorInitializingSync);
74 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, HandleCaptcha);
75 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, HandleGaiaAuthFailure);
76 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SelectCustomEncryption); 73 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SelectCustomEncryption);
77 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SuccessfullySetPassphrase); 74 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SuccessfullySetPassphrase);
78 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncEverything); 75 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncEverything);
79 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncAllManually); 76 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncAllManually);
80 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestPassphraseStillRequired); 77 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestPassphraseStillRequired);
81 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncIndividualTypes); 78 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TestSyncIndividualTypes);
82 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAll); 79 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, TurnOnEncryptAll);
83 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, 80 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, UnsuccessfullySetPassphrase);
81 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
84 UnrecoverableErrorInitializingSync); 82 UnrecoverableErrorInitializingSync);
85 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, UnsuccessfullySetPassphrase); 83 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
86 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerTest, SubmitAuthWithInvalidUsername); 84 GaiaErrorInitializingSync);
85 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleCaptcha);
86 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure);
87 FRIEND_TEST_ALL_PREFIXES(SyncSetupHandlerNonCrosTest,
88 SubmitAuthWithInvalidUsername);
87 89
88 bool is_configuring_sync() const { return configuring_sync_; } 90 bool is_configuring_sync() const { return configuring_sync_; }
89 bool have_signin_tracker() const { return signin_tracker_; } 91 bool have_signin_tracker() const { return signin_tracker_; }
90 92
91 // Subclasses must implement this to show the setup UI that's appropriate 93 // Subclasses must implement this to show the setup UI that's appropriate
92 // for the page this is contained in. 94 // for the page this is contained in.
93 virtual void ShowSetupUI() = 0; 95 virtual void ShowSetupUI() = 0;
94 96
95 // Overridden by subclasses (like SyncPromoHandler) to log stats about the 97 // Overridden by subclasses (like SyncPromoHandler) to log stats about the
96 // user's signin activity. 98 // user's signin activity.
(...skipping 13 matching lines...) Expand all
110 // Helper routine that gets the ProfileSyncService associated with the parent 112 // Helper routine that gets the ProfileSyncService associated with the parent
111 // profile. 113 // profile.
112 ProfileSyncService* GetSyncService() const; 114 ProfileSyncService* GetSyncService() const;
113 115
114 // Returns the LoginUIService for the parent profile. 116 // Returns the LoginUIService for the parent profile.
115 LoginUIService* GetLoginUIService() const; 117 LoginUIService* GetLoginUIService() const;
116 118
117 private: 119 private:
118 // Callbacks from the page. 120 // Callbacks from the page.
119 void OnDidClosePage(const base::ListValue* args); 121 void OnDidClosePage(const base::ListValue* args);
120 void HandleSubmitAuth(const base::ListValue* args);
121 void HandleConfigure(const base::ListValue* args); 122 void HandleConfigure(const base::ListValue* args);
122 void HandlePassphraseEntry(const base::ListValue* args); 123 void HandlePassphraseEntry(const base::ListValue* args);
123 void HandlePassphraseCancel(const base::ListValue* args); 124 void HandlePassphraseCancel(const base::ListValue* args);
124 void HandleShowErrorUI(const base::ListValue* args); 125 void HandleShowErrorUI(const base::ListValue* args);
125 void HandleShowSetupUI(const base::ListValue* args); 126 void HandleShowSetupUI(const base::ListValue* args);
126 void HandleShowSetupUIWithoutLogin(const base::ListValue* args); 127 void HandleShowSetupUIWithoutLogin(const base::ListValue* args);
127 void HandleDoSignOutOnAuthError(const base::ListValue* args); 128 void HandleDoSignOutOnAuthError(const base::ListValue* args);
128 void HandleStopSyncing(const base::ListValue* args); 129 void HandleStopSyncing(const base::ListValue* args);
129 void HandleCloseTimeout(const base::ListValue* args); 130 void HandleCloseTimeout(const base::ListValue* args);
131 #if !defined(OS_CHROMEOS)
132 void HandleSubmitAuth(const base::ListValue* args);
133
134 // Initiates a login via the signin manager.
135 void TryLogin(const std::string& username,
136 const std::string& password,
137 const std::string& captcha,
138 const std::string& access_code);
139 #endif
130 140
131 // Helper routine that gets the Profile associated with this object (virtual 141 // Helper routine that gets the Profile associated with this object (virtual
132 // so tests can override). 142 // so tests can override).
133 virtual Profile* GetProfile() const; 143 virtual Profile* GetProfile() const;
134 144
135 // Shows the GAIA login success page then exits. 145 // Shows the GAIA login success page then exits.
136 void DisplayGaiaSuccessAndClose(); 146 void DisplayGaiaSuccessAndClose();
137 147
138 // Displays the GAIA login success page then transitions to sync setup. 148 // Displays the GAIA login success page then transitions to sync setup.
139 void DisplayGaiaSuccessAndSettingUp(); 149 void DisplayGaiaSuccessAndSettingUp();
(...skipping 22 matching lines...) Expand all
162 // TODO(kochi): better to show some message that the user can understand what 172 // TODO(kochi): better to show some message that the user can understand what
163 // is running in the background. 173 // is running in the background.
164 void DisplaySpinner(); 174 void DisplaySpinner();
165 175
166 // Displays an error dialog which shows timeout of starting the sync backend. 176 // Displays an error dialog which shows timeout of starting the sync backend.
167 void DisplayTimeout(); 177 void DisplayTimeout();
168 178
169 // Returns true if this object is the active login object. 179 // Returns true if this object is the active login object.
170 bool IsActiveLogin() const; 180 bool IsActiveLogin() const;
171 181
172 // Initiates a login via the signin manager.
173 void TryLogin(const std::string& username,
174 const std::string& password,
175 const std::string& captcha,
176 const std::string& access_code);
177
178 // If a wizard already exists, focus it and return true. 182 // If a wizard already exists, focus it and return true.
179 bool FocusExistingWizardIfPresent(); 183 bool FocusExistingWizardIfPresent();
180 184
181 // Invokes the javascript call to close the setup overlay. 185 // Invokes the javascript call to close the setup overlay.
182 void CloseOverlay(); 186 void CloseOverlay();
183 187
184 // When using web-flow, closes the Gaia page used to collection user 188 // When using web-flow, closes the Gaia page used to collection user
185 // credentials. 189 // credentials.
186 void CloseGaiaSigninPage(); 190 void CloseGaiaSigninPage();
187 191
188 // Returns true if the given login data is valid, false otherwise. If the 192 // Returns true if the given login data is valid, false otherwise. If the
189 // login data is not valid then on return |error_message| will be set to a 193 // login data is not valid then on return |error_message| will be set to a
190 // localized error message. Note, |error_message| must not be NULL. 194 // localized error message. Note, |error_message| must not be NULL.
191 bool IsLoginAuthDataValid(const std::string& username, 195 bool IsLoginAuthDataValid(const std::string& username,
192 string16* error_message); 196 string16* error_message);
193 197
194 // Returns the SigninManager for the parent profile.
195 SigninManager* GetSignin() const;
196
197 // The SigninTracker object used to determine when the user has fully signed 198 // The SigninTracker object used to determine when the user has fully signed
198 // in (this requires waiting for various services to initialize and tracking 199 // in (this requires waiting for various services to initialize and tracking
199 // errors from multiple sources). Should only be non-null while the login UI 200 // errors from multiple sources). Should only be non-null while the login UI
200 // is visible. 201 // is visible.
201 scoped_ptr<SigninTracker> signin_tracker_; 202 scoped_ptr<SigninTracker> signin_tracker_;
202 203
203 // Set to true whenever the sync configure UI is visible. This is used to tell 204 // Set to true whenever the sync configure UI is visible. This is used to tell
204 // what stage of the setup wizard the user was in and to update the UMA 205 // what stage of the setup wizard the user was in and to update the UMA
205 // histograms in the case that the user cancels out. 206 // histograms in the case that the user cancels out.
206 bool configuring_sync_; 207 bool configuring_sync_;
(...skipping 16 matching lines...) Expand all
223 scoped_ptr<base::OneShotTimer<SyncSetupHandler> > backend_start_timer_; 224 scoped_ptr<base::OneShotTimer<SyncSetupHandler> > backend_start_timer_;
224 225
225 // When using web-flow, weak pointer to the tab that holds the Gaia sign in 226 // When using web-flow, weak pointer to the tab that holds the Gaia sign in
226 // page. 227 // page.
227 content::WebContents* active_gaia_signin_tab_; 228 content::WebContents* active_gaia_signin_tab_;
228 229
229 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler); 230 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler);
230 }; 231 };
231 232
232 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ 233 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698