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

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

Issue 9295044: Start moving signin code out of browser/sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 8 years, 10 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) 2011 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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" 9 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
10 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" 10 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
11 #include "chrome/browser/sync/sync_setup_flow_handler.h" 11 #include "chrome/browser/sync/sync_setup_flow_handler.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/signin_tracker.h"
13 14
15 class LoginUIService;
16 class SigninManager;
14 class SyncSetupFlow; 17 class SyncSetupFlow;
15 class ProfileManager; 18 class ProfileManager;
16 19
17 class SyncSetupHandler : public GaiaOAuthConsumer, 20 class SyncSetupHandler : public GaiaOAuthConsumer,
18 public OptionsPageUIHandler, 21 public OptionsPageUIHandler,
19 public SyncSetupFlowHandler { 22 public SyncSetupFlowHandler,
23 public SigninTracker::Observer {
20 public: 24 public:
21 // Constructs a new SyncSetupHandler. |profile_manager| may be NULL. 25 // Constructs a new SyncSetupHandler. |profile_manager| may be NULL.
22 explicit SyncSetupHandler(ProfileManager* profile_manager); 26 explicit SyncSetupHandler(ProfileManager* profile_manager);
23 virtual ~SyncSetupHandler(); 27 virtual ~SyncSetupHandler();
24 28
25 // OptionsPageUIHandler implementation. 29 // OptionsPageUIHandler implementation.
26 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) 30 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings)
27 OVERRIDE; 31 OVERRIDE;
28 virtual void Initialize() OVERRIDE;
29 virtual void RegisterMessages() OVERRIDE; 32 virtual void RegisterMessages() OVERRIDE;
30 33
31 // SyncSetupFlowHandler implementation. 34 // SyncSetupFlowHandler implementation.
32 virtual void ShowOAuthLogin() OVERRIDE;
33 virtual void ShowGaiaLogin(const base::DictionaryValue& args) OVERRIDE;
34 virtual void ShowGaiaSuccessAndClose() OVERRIDE;
35 virtual void ShowGaiaSuccessAndSettingUp() OVERRIDE;
36 virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE; 35 virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE;
36 virtual void ShowFatalError() OVERRIDE;
37 virtual void ShowPassphraseEntry(const base::DictionaryValue& args) OVERRIDE; 37 virtual void ShowPassphraseEntry(const base::DictionaryValue& args) OVERRIDE;
38 virtual void ShowSettingUp() OVERRIDE; 38 virtual void ShowSettingUp() OVERRIDE;
39 virtual void ShowSetupDone(const string16& user) OVERRIDE; 39 virtual void ShowSetupDone(const string16& user) OVERRIDE;
40 virtual void SetFlow(SyncSetupFlow* flow) OVERRIDE; 40 virtual void SetFlow(SyncSetupFlow* flow) OVERRIDE;
41 virtual void Focus() OVERRIDE; 41 virtual void Focus() OVERRIDE;
42 42
43 // GaiaOAuthConsumer implementation. 43 // GaiaOAuthConsumer implementation.
44 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE; 44 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE;
45 virtual void OnGetOAuthTokenFailure( 45 virtual void OnGetOAuthTokenFailure(
46 const GoogleServiceAuthError& error) OVERRIDE; 46 const GoogleServiceAuthError& error) OVERRIDE;
47 47
48 // SigninTracker::Observer implementation
49 virtual void GaiaCredentialsValid() OVERRIDE;
50 virtual void SigninFailed() OVERRIDE;
51 virtual void SigninSuccess() OVERRIDE;
52
48 static void GetStaticLocalizedValues( 53 static void GetStaticLocalizedValues(
49 base::DictionaryValue* localized_strings, 54 base::DictionaryValue* localized_strings,
50 content::WebUI* web_ui); 55 content::WebUI* web_ui);
51 56
52 // Initializes the sync setup flow and shows the setup UI. 57 // Initializes the sync setup flow and shows the setup UI.
53 void OpenSyncSetup(); 58 void OpenSyncSetup();
54 59
55 // Terminates the sync setup flow. 60 // Terminates the sync setup flow.
56 void CloseSyncSetup(); 61 void CloseSyncSetup();
57 62
(...skipping 16 matching lines...) Expand all
74 void HandleSubmitAuth(const base::ListValue* args); 79 void HandleSubmitAuth(const base::ListValue* args);
75 void HandleConfigure(const base::ListValue* args); 80 void HandleConfigure(const base::ListValue* args);
76 void HandlePassphraseEntry(const base::ListValue* args); 81 void HandlePassphraseEntry(const base::ListValue* args);
77 void HandlePassphraseCancel(const base::ListValue* args); 82 void HandlePassphraseCancel(const base::ListValue* args);
78 void HandleAttachHandler(const base::ListValue* args); 83 void HandleAttachHandler(const base::ListValue* args);
79 void HandleShowErrorUI(const base::ListValue* args); 84 void HandleShowErrorUI(const base::ListValue* args);
80 void HandleShowSetupUI(const base::ListValue* args); 85 void HandleShowSetupUI(const base::ListValue* args);
81 86
82 SyncSetupFlow* flow() { return flow_; } 87 SyncSetupFlow* flow() { return flow_; }
83 88
84 // Subclasses must implement to step the SyncSetupWizard to the correct state
85 // before showing the Setup UI.
86 virtual void StepWizardForShowSetupUI() = 0;
87
88 // Subclasses must implement this to show the setup UI that's appropriate 89 // Subclasses must implement this to show the setup UI that's appropriate
89 // for the page this is contained in. 90 // for the page this is contained in.
90 virtual void ShowSetupUI() = 0; 91 virtual void ShowSetupUI() = 0;
91 92
93 // Overridden by subclasses to log stats about the user's signin activity.
94 virtual void RecordSignin();
95
92 private: 96 private:
97 // Helper routine that gets the ProfileSyncService associated with the parent
98 // profile.
99 class ProfileSyncService* GetSyncService() const;
100
101 // Start up the sync setup configuration wizard.
102 void StartConfigureSync();
103
104 // Shows the GAIA login success page then exits.
105 void DisplayGaiaSuccessAndClose();
106
107 // Displays the GAIA login success page then transitions to sync setup.
108 void DisplayGaiaSuccessAndSettingUp();
109
110 // Displays the GAIA login form. If |fatal_error| is true, displays the fatal
111 // error UI.
112 void DisplayGaiaLogin(bool fatal_error);
113
114 // Displays the GAIA login form with a custom error message (used for errors
115 // like "email address already in use by another profile"). No message
116 // displayed if |error_message| is empty. Displays fatal error UI if
117 // |fatal_error| = true.
118 void DisplayGaiaLoginWithErrorMessage(const string16& error_message,
119 bool fatal_error);
120
121 // Returns true if we're the active login object.
122 bool IsActiveLogin() const;
123
124 // Initiates a login via the signin manager.
125 void TryLogin(const std::string& username,
126 const std::string& password,
127 const std::string& captcha,
128 const std::string& access_code);
129
130 // Returns true if the user is already logged in.
131 bool IsUserLoggedIn() const;
132
93 // If a wizard already exists, focus it and return true. 133 // If a wizard already exists, focus it and return true.
94 bool FocusExistingWizard(); 134 bool FocusExistingWizard();
95 135
96 // Invokes the javascript call to close the setup overlay. 136 // Invokes the javascript call to close the setup overlay.
97 void CloseOverlay(); 137 void CloseOverlay();
98 138
99 // Returns true if the given login data is valid, false otherwise. If the 139 // Returns true if the given login data is valid, false otherwise. If the
100 // login data is not valid then on return |error_message| will be set to a 140 // login data is not valid then on return |error_message| will be set to a
101 // localized error message. Note, |error_message| must not be NULL. 141 // localized error message. Note, |error_message| must not be NULL.
102 bool IsLoginAuthDataValid(const std::string& username, 142 bool IsLoginAuthDataValid(const std::string& username,
103 string16* error_message); 143 string16* error_message);
104 144
105 // Displays the given error message in the login UI. 145 // Returns the SigninManager for the parent profile. Overridden by tests.
106 void ShowLoginErrorMessage(const string16& error_message); 146 virtual SigninManager* GetSignin() const;
147
148 // Returns the LoginUIService for the parent profile. Overridden by tests.
149 virtual LoginUIService* GetLoginUIService() const;
150
151 // The SigninTracker object used to determine when the user has fully signed
152 // in (this requires waiting for various services to initialize and tracking
153 // errors from multiple sources). Should only be non-null while the login UI
154 // is visible.
155 scoped_ptr<SigninTracker> signin_tracker_;
107 156
108 // Weak reference. 157 // Weak reference.
109 SyncSetupFlow* flow_; 158 SyncSetupFlow* flow_;
110 scoped_ptr<GaiaOAuthFetcher> oauth_login_;
111 // Weak reference to the profile manager. 159 // Weak reference to the profile manager.
112 ProfileManager* const profile_manager_; 160 ProfileManager* const profile_manager_;
113 161
162 // Cache of the last name the client attempted to authenticate.
163 std::string last_attempted_user_email_;
164
114 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler); 165 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler);
115 }; 166 };
116 167
117 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ 168 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698