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

Unified 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: Fixed unit test 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/sync_setup_handler.h
diff --git a/chrome/browser/ui/webui/sync_setup_handler.h b/chrome/browser/ui/webui/sync_setup_handler.h
index 90e112769cb675bae155d1de36ea12b5ba05b1ea..a982cb8c14c3d983dc6e018b96e4d308ba23bc79 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.h
+++ b/chrome/browser/ui/webui/sync_setup_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,13 +10,17 @@
#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
#include "chrome/browser/sync/sync_setup_flow_handler.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
+#include "chrome/browser/ui/webui/signin/signin_tracker.h"
+class LoginUIService;
+class SigninManager;
class SyncSetupFlow;
class ProfileManager;
class SyncSetupHandler : public GaiaOAuthConsumer,
public OptionsPageUIHandler,
- public SyncSetupFlowHandler {
+ public SyncSetupFlowHandler,
+ public SigninTracker::Observer {
public:
// Constructs a new SyncSetupHandler. |profile_manager| may be NULL.
explicit SyncSetupHandler(ProfileManager* profile_manager);
@@ -29,11 +33,8 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
virtual void RegisterMessages() OVERRIDE;
// SyncSetupFlowHandler implementation.
- virtual void ShowOAuthLogin() OVERRIDE;
- virtual void ShowGaiaLogin(const base::DictionaryValue& args) OVERRIDE;
- virtual void ShowGaiaSuccessAndClose() OVERRIDE;
- virtual void ShowGaiaSuccessAndSettingUp() OVERRIDE;
virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE;
+ virtual void ShowFatalError() OVERRIDE;
virtual void ShowPassphraseEntry(const base::DictionaryValue& args) OVERRIDE;
virtual void ShowSettingUp() OVERRIDE;
virtual void ShowSetupDone(const string16& user) OVERRIDE;
@@ -45,6 +46,11 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
virtual void OnGetOAuthTokenFailure(
const GoogleServiceAuthError& error) OVERRIDE;
+ // SigninTracker::Observer implementation
+ virtual void GaiaCredentialsValid() OVERRIDE;
+ virtual void SigninFailed() OVERRIDE;
+ virtual void SigninSuccess() OVERRIDE;
+
static void GetStaticLocalizedValues(
base::DictionaryValue* localized_strings,
content::WebUI* web_ui);
@@ -81,15 +87,50 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
SyncSetupFlow* flow() { return flow_; }
- // Subclasses must implement to step the SyncSetupWizard to the correct state
- // before showing the Setup UI.
- virtual void StepWizardForShowSetupUI() = 0;
-
// Subclasses must implement this to show the setup UI that's appropriate
// for the page this is contained in.
virtual void ShowSetupUI() = 0;
+ // Overridden by subclasses to log stats about the user's signin activity.
+ virtual void RecordSignin();
+
private:
+ // Helper routine that gets the ProfileSyncService associated with the parent
+ // profile.
+ class ProfileSyncService* GetSyncService() const;
+
+ // Start up the sync setup configuration wizard.
+ void StartConfigureSync();
+
+ // Shows the GAIA login success page then exits.
+ void DisplayGaiaSuccessAndClose();
+
+ // Displays the GAIA login success page then transitions to sync setup.
+ void DisplayGaiaSuccessAndSettingUp();
+
+ // Displays the GAIA login form. If |fatal_error| is true, displays the fatal
+ // error UI.
+ void DisplayGaiaLogin(bool fatal_error);
+
+ // Displays the GAIA login form with a custom error message (used for errors
+ // like "email address already in use by another profile"). No message
+ // displayed if |error_message| is empty. Displays fatal error UI if
+ // |fatal_error| = true.
+ void DisplayGaiaLoginWithErrorMessage(const string16& error_message,
+ bool fatal_error);
+
+ // Returns true if we're the active login object.
+ bool IsActiveLogin() const;
+
+ // Initiates a login via the signin manager.
+ void TryLogin(const std::string& username,
+ const std::string& password,
+ const std::string& captcha,
+ const std::string& access_code);
+
+ // Returns true if the user is already logged in.
+ bool IsUserLoggedIn() const;
+
// If a wizard already exists, focus it and return true.
bool FocusExistingWizard();
@@ -102,15 +143,22 @@ class SyncSetupHandler : public GaiaOAuthConsumer,
bool IsLoginAuthDataValid(const std::string& username,
string16* error_message);
- // Displays the given error message in the login UI.
- void ShowLoginErrorMessage(const string16& error_message);
+ // Returns the SigninManager for the parent profile. Overridden by tests.
+ virtual SigninManager* GetSignin() const;
+
+ // Returns the LoginUIService for the parent profile. Overridden by tests.
+ virtual LoginUIService* GetLoginUIService() const;
+
+ scoped_ptr<SigninTracker> signin_tracker_;
James Hawkins 2012/02/10 23:08:01 Document var.
Andrew T Wilson (Slow) 2012/02/11 01:50:45 Done.
// Weak reference.
SyncSetupFlow* flow_;
- scoped_ptr<GaiaOAuthFetcher> oauth_login_;
// Weak reference to the profile manager.
ProfileManager* const profile_manager_;
+ // Cache of the last name the client attempted to authenticate.
+ std::string last_attempted_user_email_;
+
DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler);
};

Powered by Google App Engine
This is Rietveld 408576698