summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/gaia/gaia_oauth_fetcher.cc6
-rw-r--r--chrome/browser/sync/profile_sync_service.cc72
-rw-r--r--chrome/browser/sync/profile_sync_service.h4
-rw-r--r--chrome/browser/sync/signin_manager.cc65
-rw-r--r--chrome/browser/sync/signin_manager.h36
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc21
-rw-r--r--chrome/browser/sync/sync_setup_flow_handler.h1
-rw-r--r--chrome/browser/sync/sync_setup_wizard.cc12
-rw-r--r--chrome/browser/sync/sync_setup_wizard.h9
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc2
-rw-r--r--chrome/browser/ui/webui/options/options_sync_setup_handler.cc2
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc10
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.h26
13 files changed, 161 insertions, 105 deletions
diff --git a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
index 168b5ca..2dea731 100644
--- a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
+++ b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
@@ -450,13 +450,14 @@ void GaiaOAuthFetcher::OnCookieChanged(Profile* profile,
const net::CookieMonster::CanonicalCookie* canonical_cookie =
cookie_details->cookie;
if (canonical_cookie->Name() == kOAuthTokenCookie) {
+ VLOG(1) << "OAuth1 request token cookie changed.";
fetch_pending_ = false;
OnGetOAuthTokenFetched(canonical_cookie->Value());
}
}
void GaiaOAuthFetcher::OnGetOAuthTokenFetched(const std::string& token) {
- // DCHECK (popup_);
+ VLOG(1) << "OAuth1 request token fetched.";
if (popup_) {
Browser* popped_up = popup_;
popup_ = NULL;
@@ -493,6 +494,7 @@ void GaiaOAuthFetcher::OnOAuthGetAccessTokenFetched(
const net::URLRequestStatus& status,
int response_code) {
if (status.is_success() && response_code == RC_REQUEST_OK) {
+ VLOG(1) << "OAuth1 access token fetched.";
std::string secret;
std::string token;
ParseOAuthGetAccessTokenResponse(data, &token, &secret);
@@ -509,6 +511,7 @@ void GaiaOAuthFetcher::OnOAuthWrapBridgeFetched(
const net::URLRequestStatus& status,
int response_code) {
if (status.is_success() && response_code == RC_REQUEST_OK) {
+ VLOG(1) << "OAuth2 access token fetched.";
std::string token;
std::string expires_in;
ParseOAuthWrapBridgeResponse(data, &token, &expires_in);
@@ -527,6 +530,7 @@ void GaiaOAuthFetcher::OnUserInfoFetched(
if (status.is_success() && response_code == RC_REQUEST_OK) {
std::string email;
ParseUserInfoResponse(data, &email);
+ VLOG(1) << "GAIA user info fetched for " << email << ".";
consumer_->OnUserInfoSuccess(email);
} else {
consumer_->OnUserInfoFailure(GenerateAuthError(data, status));
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index f0b3a64..3427c39 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -190,12 +190,6 @@ void ProfileSyncService::RegisterAuthNotifications() {
registrar_.Add(this,
chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
Source<Profile>(profile_));
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSyncOAuth)) {
- registrar_.Add(this,
- chrome::NOTIFICATION_COOKIE_CHANGED,
- Source<Profile>(profile_));
- }
}
void ProfileSyncService::RegisterDataTypeController(
@@ -596,59 +590,6 @@ void ProfileSyncService::OnBackendInitialized(bool success) {
}
}
-namespace {
-const char* CauseName(net::CookieMonster::Delegate::ChangeCause cause) {
- switch (cause) {
- case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT:
- return "CHANGE_COOKIE_EXPLICIT";
- case net::CookieMonster::Delegate::CHANGE_COOKIE_OVERWRITE:
- return "CHANGE_COOKIE_OVERWRITE";
- case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED:
- return "CHANGE_COOKIE_EXPIRED";
- case net::CookieMonster::Delegate::CHANGE_COOKIE_EVICTED:
- return "CHANGE_COOKIE_EVICTED";
- case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED_OVERWRITE:
- return "CHANGE_COOKIE_EXPIRED_OVERWRITE";
- default:
- return "<unknown>";
- }
-}
-}
-
-void ProfileSyncService::OnCookieChanged(Profile* profile,
- ChromeCookieDetails* cookie_details) {
- const net::CookieMonster::CanonicalCookie* canonical_cookie =
- cookie_details->cookie;
- if (canonical_cookie->Name() == "oauth_token") {
- net::CookieMonster::Delegate::ChangeCause cause = cookie_details->cause;
- LOG(INFO) << "COOKIE_CHANGED: removed="
- << (cookie_details->removed ? "true" : "false")
- << ", cause=" << CauseName(cause)
- << ", Source=" << canonical_cookie->Source()
- << ", Name=" << canonical_cookie->Name()
- << ", Value=" << canonical_cookie->Value()
- << ", Domain=" << canonical_cookie->Domain()
- << ", Path=" << canonical_cookie->Path()
- << ", DoesExpire="
- << (canonical_cookie->DoesExpire() ? "true" : "false")
- << ", IsPersistent="
- << (canonical_cookie->IsPersistent() ? "true" : "false")
- << ", IsSecure="
- << (canonical_cookie->IsSecure() ? "true" : "false")
- << ", IsHttpOnly="
- << (canonical_cookie->IsHttpOnly() ? "true" : "false")
- << ", IsDomainCookie="
- << (canonical_cookie->IsDomainCookie() ? "true" : "false")
- << ", IsHostCookie="
- << (canonical_cookie->IsHostCookie() ? "true" : "false")
- << ", IsExpired="
- << (const_cast<net::CookieMonster::CanonicalCookie*>(
- canonical_cookie)->IsExpired(
- base::Time::NowFromSystemTime())
- ? "true" : "false");
- }
-}
-
void ProfileSyncService::OnSyncCycleCompleted() {
UpdateLastSyncedTime();
VLOG(2) << "Notifying observers sync cycle completed";
@@ -662,8 +603,8 @@ void ProfileSyncService::UpdateAuthErrorState(
// Require the user to click somewhere to run the setup wizard in the case
// of a steady-state auth failure.
if (WizardIsVisible()) {
- wizard_.Step(AuthError::NONE == last_auth_error_.state() ?
- SyncSetupWizard::GAIA_SUCCESS : SyncSetupWizard::GAIA_LOGIN);
+ wizard_.Step(last_auth_error_.state() == AuthError::NONE ?
+ SyncSetupWizard::GAIA_SUCCESS : SyncSetupWizard::GetLoginState());
} else {
auth_error_time_ = base::TimeTicks::Now();
}
@@ -820,7 +761,7 @@ void ProfileSyncService::ShowLoginDialog() {
wizard_.Focus();
// Force the wizard to step to the login screen (which will only actually
// happen if the transition is valid).
- wizard_.Step(SyncSetupWizard::GAIA_LOGIN);
+ wizard_.Step(SyncSetupWizard::GetLoginState());
return;
}
@@ -830,7 +771,7 @@ void ProfileSyncService::ShowLoginDialog() {
auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null.
}
- ShowSyncSetup(SyncSetupWizard::GAIA_LOGIN);
+ ShowSyncSetup(SyncSetupWizard::GetLoginState());
NotifyObservers();
}
@@ -1372,11 +1313,6 @@ void ProfileSyncService::Observe(int type,
}
break;
}
- case chrome::NOTIFICATION_COOKIE_CHANGED: {
- OnCookieChanged(Source<Profile>(source).ptr(),
- Details<ChromeCookieDetails>(details).ptr());
- break;
- }
default: {
NOTREACHED();
}
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 6d3a610..cef7d618 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -209,10 +209,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
const std::string& captcha,
const std::string& access_code);
- // Called when a cookie, e. g. oauth_token, changes
- virtual void OnCookieChanged(Profile* profile,
- ChromeCookieDetails* cookie_details);
-
// Update the last auth error and notify observers of error state.
void UpdateAuthErrorState(const GoogleServiceAuthError& error);
diff --git a/chrome/browser/sync/signin_manager.cc b/chrome/browser/sync/signin_manager.cc
index d5450f0..2c06078 100644
--- a/chrome/browser/sync/signin_manager.cc
+++ b/chrome/browser/sync/signin_manager.cc
@@ -18,6 +18,8 @@
const char kGetInfoEmailKey[] = "email";
+const char kSyncOAuth2Scope[] = "https://www.googleapis.com/auth/chromesync";
+
SigninManager::SigninManager()
: profile_(NULL), had_two_factor_error_(false) {}
@@ -65,11 +67,8 @@ void SigninManager::SetUsername(const std::string& username) {
username_ = username;
}
-// Users must always sign out before they sign in again.
-void SigninManager::StartSignIn(const std::string& username,
- const std::string& password,
- const std::string& login_token,
- const std::string& login_captcha) {
+// static
+void SigninManager::PrepareForSignin() {
DCHECK(username_.empty());
#if !defined(OS_CHROMEOS)
// The Sign out should clear the token service credentials.
@@ -77,6 +76,24 @@ void SigninManager::StartSignIn(const std::string& username,
// set up 2-factor authentication.
DCHECK(!profile_->GetTokenService()->AreCredentialsValid());
#endif
+}
+
+// Users must always sign out before they sign in again.
+void SigninManager::StartOAuthSignIn() {
+ PrepareForSignin();
+ oauth_login_.reset(new GaiaOAuthFetcher(this,
+ profile_->GetRequestContext(),
+ profile_,
+ kSyncOAuth2Scope));
+ oauth_login_->StartGetOAuthToken();
+}
+
+// Users must always sign out before they sign in again.
+void SigninManager::StartSignIn(const std::string& username,
+ const std::string& password,
+ const std::string& login_token,
+ const std::string& login_captcha) {
+ PrepareForSignin();
username_.assign(username);
password_.assign(password);
@@ -177,7 +194,7 @@ void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) {
void SigninManager::OnTokenAuthFailure(const GoogleServiceAuthError& error) {
#if !defined(OS_CHROMEOS)
- LOG(INFO) << "Unable to retreive the token auth.";
+ VLOG(1) << "Unable to retrieve the token auth.";
CleanupNotificationRegistration();
#endif
}
@@ -202,6 +219,42 @@ void SigninManager::OnClientLoginFailure(const GoogleServiceAuthError& error) {
SignOut();
}
+void SigninManager::OnGetOAuthTokenSuccess(const std::string& oauth_token) {
+ VLOG(1) << "SigninManager::SigninManager::OnGetOAuthTokenSuccess";
+}
+
+void SigninManager::OnGetOAuthTokenFailure() {
+ VLOG(1) << "SigninManager::OnGetOAuthTokenFailure";
+}
+
+void SigninManager::OnOAuthGetAccessTokenSuccess(const std::string& token,
+ const std::string& secret) {
+ VLOG(1) << "SigninManager::OnOAuthGetAccessTokenSuccess";
+}
+
+void SigninManager::OnOAuthGetAccessTokenFailure(
+ const GoogleServiceAuthError& error) {
+ VLOG(1) << "SigninManager::OnOAuthGetAccessTokenFailure";
+}
+
+void SigninManager::OnOAuthWrapBridgeSuccess(const std::string& token,
+ const std::string& expires_in) {
+ VLOG(1) << "SigninManager::OnOAuthWrapBridgeSuccess";
+}
+
+void SigninManager::OnOAuthWrapBridgeFailure(
+ const GoogleServiceAuthError& error) {
+ VLOG(1) << "SigninManager::OnOAuthWrapBridgeFailure";
+}
+
+void SigninManager::OnUserInfoSuccess(const std::string& email) {
+ VLOG(1) << "SigninManager::OnUserInfoSuccess(\"" << email << "\")";
+}
+
+void SigninManager::OnUserInfoFailure(const GoogleServiceAuthError& error) {
+ VLOG(1) << "SigninManager::OnUserInfoFailure";
+}
+
void SigninManager::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/sync/signin_manager.h b/chrome/browser/sync/signin_manager.h
index 30ca00f..60d0320 100644
--- a/chrome/browser/sync/signin_manager.h
+++ b/chrome/browser/sync/signin_manager.h
@@ -12,8 +12,10 @@
#pragma once
#include <string>
+
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "content/common/notification_observer.h"
@@ -35,7 +37,9 @@ struct GoogleServiceSigninSuccessDetails {
std::string password;
};
-class SigninManager : public GaiaAuthConsumer , public NotificationObserver {
+class SigninManager : public GaiaAuthConsumer,
+ public GaiaOAuthConsumer,
+ public NotificationObserver {
public:
SigninManager();
virtual ~SigninManager();
@@ -54,9 +58,14 @@ class SigninManager : public GaiaAuthConsumer , public NotificationObserver {
// Sets the user name. Used for migrating credentials from previous system.
void SetUsername(const std::string& username);
- // Attempt to sign in this user. If successful, set a preference indicating
- // the signed in user and send out a notification, then start fetching tokens
- // for the user.
+ // Attempt to sign in this user with OAuth. If successful, set a preference
+ // indicating the signed in user and send out a notification, then start
+ // fetching tokens for the user.
+ virtual void StartOAuthSignIn();
+
+ // Attempt to sign in this user with ClientLogin. If successful, set a
+ // preference indicating the signed in user and send out a notification,
+ // then start fetching tokens for the user.
// This is overridden for test subclasses that don't want to issue auth
// requests.
virtual void StartSignIn(const std::string& username,
@@ -84,12 +93,28 @@ class SigninManager : public GaiaAuthConsumer , public NotificationObserver {
virtual void OnTokenAuthFailure(const GoogleServiceAuthError& error)
OVERRIDE;
+ // GaiaOAuthConsumer
+ virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE;
+ virtual void OnGetOAuthTokenFailure() OVERRIDE;
+ virtual void OnOAuthGetAccessTokenSuccess(const std::string& token,
+ const std::string& secret) OVERRIDE;
+ virtual void OnOAuthGetAccessTokenFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+ virtual void OnOAuthWrapBridgeSuccess(const std::string& token,
+ const std::string& expires_in)
+ OVERRIDE;
+ virtual void OnOAuthWrapBridgeFailure(const GoogleServiceAuthError& error);
+ virtual void OnUserInfoSuccess(const std::string& email) OVERRIDE;
+ virtual void OnUserInfoFailure(const GoogleServiceAuthError& error) OVERRIDE;
+
// NotificationObserver
virtual void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
private:
+ void PrepareForSignin();
+
Profile* profile_;
std::string username_;
std::string password_; // This is kept empty whenever possible.
@@ -104,6 +129,9 @@ class SigninManager : public GaiaAuthConsumer , public NotificationObserver {
// Actual client login handler.
scoped_ptr<GaiaAuthFetcher> client_login_;
+ // Actual OAuth login handler.
+ scoped_ptr<GaiaOAuthFetcher> oauth_login_;
+
// Register for notifications from the TokenService.
NotificationRegistrar registrar_;
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 8e3b5c0..c2cc1b3 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -51,8 +51,7 @@ SyncSetupWizard::State GetStepForNonFatalError(ProfileSyncService* service) {
if (service->IsPassphraseRequired()) {
if (service->IsUsingSecondaryPassphrase())
return SyncSetupWizard::ENTER_PASSPHRASE;
- else
- return SyncSetupWizard::GAIA_LOGIN;
+ return SyncSetupWizard::GetLoginState();
}
const GoogleServiceAuthError& error = service->GetAuthError();
@@ -61,7 +60,7 @@ SyncSetupWizard::State GetStepForNonFatalError(ProfileSyncService* service) {
error.state() == GoogleServiceAuthError::ACCOUNT_DELETED ||
error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED ||
error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE)
- return SyncSetupWizard::GAIA_LOGIN;
+ return SyncSetupWizard::GetLoginState();
NOTREACHED();
return SyncSetupWizard::FATAL_ERROR;
@@ -211,6 +210,7 @@ void SyncSetupFlow::Focus() {
}
// A callback to notify the delegate that the dialog closed.
+// TODO(rickcam): Bug 90713: Handle OAUTH_LOGIN case here
void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
DCHECK(json_retval.empty());
container_->set_flow(NULL); // Sever ties from the wizard.
@@ -320,13 +320,18 @@ SyncSetupFlow::SyncSetupFlow(SyncSetupWizard::State start_state,
// Returns true if the flow should advance to |state| based on |current_state_|.
bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) {
switch (state) {
+ case SyncSetupWizard::OAUTH_LOGIN:
+ return current_state_ == SyncSetupWizard::FATAL_ERROR ||
+ current_state_ == SyncSetupWizard::OAUTH_LOGIN ||
+ current_state_ == SyncSetupWizard::SETTING_UP;
case SyncSetupWizard::GAIA_LOGIN:
return current_state_ == SyncSetupWizard::FATAL_ERROR ||
current_state_ == SyncSetupWizard::GAIA_LOGIN ||
current_state_ == SyncSetupWizard::SETTING_UP;
case SyncSetupWizard::GAIA_SUCCESS:
- return current_state_ == SyncSetupWizard::GAIA_LOGIN;
- case SyncSetupWizard::SYNC_EVERYTHING:
+ return current_state_ == SyncSetupWizard::GAIA_LOGIN ||
+ current_state_ == SyncSetupWizard::OAUTH_LOGIN;
+ case SyncSetupWizard::SYNC_EVERYTHING: // Intentionally fall through.
case SyncSetupWizard::CONFIGURE:
return current_state_ == SyncSetupWizard::GAIA_SUCCESS;
case SyncSetupWizard::ENTER_PASSPHRASE:
@@ -339,7 +344,7 @@ bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) {
return current_state_ == SyncSetupWizard::SYNC_EVERYTHING ||
current_state_ == SyncSetupWizard::CONFIGURE ||
current_state_ == SyncSetupWizard::ENTER_PASSPHRASE;
- case SyncSetupWizard::NONFATAL_ERROR:
+ case SyncSetupWizard::NONFATAL_ERROR: // Intentionally fall through.
case SyncSetupWizard::FATAL_ERROR:
return true; // You can always hit the panic button.
case SyncSetupWizard::DONE:
@@ -360,6 +365,10 @@ void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) {
current_state_ = state;
switch (state) {
+ case SyncSetupWizard::OAUTH_LOGIN: {
+ flow_handler_->ShowOAuthLogin();
+ break;
+ }
case SyncSetupWizard::GAIA_LOGIN: {
DictionaryValue args;
SyncSetupFlow::GetArgsForGaiaLogin(service_, &args);
diff --git a/chrome/browser/sync/sync_setup_flow_handler.h b/chrome/browser/sync/sync_setup_flow_handler.h
index a7c2ae3..5070a1a 100644
--- a/chrome/browser/sync/sync_setup_flow_handler.h
+++ b/chrome/browser/sync/sync_setup_flow_handler.h
@@ -17,6 +17,7 @@ class DictionaryValue;
class SyncSetupFlowHandler {
public:
// These functions control which part of the HTML is visible.
+ virtual void ShowOAuthLogin() = 0;
virtual void ShowGaiaLogin(const base::DictionaryValue& args) = 0;
virtual void ShowGaiaSuccessAndClose() = 0;
virtual void ShowGaiaSuccessAndSettingUp() = 0;
diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc
index d079d9e8..7d9dac2 100644
--- a/chrome/browser/sync/sync_setup_wizard.cc
+++ b/chrome/browser/sync/sync_setup_wizard.cc
@@ -7,10 +7,12 @@
#include <stddef.h>
#include <ostream>
+#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_setup_flow.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
namespace {
@@ -22,7 +24,8 @@ namespace {
SyncSetupWizard::State GetEndStateForDiscreteRun(
SyncSetupWizard::State start_state) {
SyncSetupWizard::State result = SyncSetupWizard::FATAL_ERROR;
- if (start_state == SyncSetupWizard::GAIA_LOGIN) {
+ if (start_state == SyncSetupWizard::GAIA_LOGIN ||
+ start_state == SyncSetupWizard::OAUTH_LOGIN) {
result = SyncSetupWizard::GAIA_SUCCESS;
} else if (start_state == SyncSetupWizard::ENTER_PASSPHRASE ||
start_state == SyncSetupWizard::NONFATAL_ERROR ||
@@ -87,6 +90,13 @@ bool SyncSetupWizard::IsVisible() const {
return flow_container_->get_flow() != NULL;
}
+// static
+SyncSetupWizard::State SyncSetupWizard::GetLoginState() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSyncOAuth))
+ return SyncSetupWizard::OAUTH_LOGIN;
+ return SyncSetupWizard::GAIA_LOGIN;
+}
+
void SyncSetupWizard::Focus() {
SyncSetupFlow* flow = flow_container_->get_flow();
if (flow)
diff --git a/chrome/browser/sync/sync_setup_wizard.h b/chrome/browser/sync/sync_setup_wizard.h
index a9f3579..4b037cd 100644
--- a/chrome/browser/sync/sync_setup_wizard.h
+++ b/chrome/browser/sync/sync_setup_wizard.h
@@ -19,6 +19,9 @@ class SyncSetupWizard {
enum State {
// Show the Google Account login UI.
GAIA_LOGIN = 0,
+ // Show the Gaia OAuth login UI.
+ // TODO(rickcam): After Sync with OAuth works, revisit removing this state.
+ OAUTH_LOGIN,
// A login attempt succeeded. This will wait for an explicit transition
// (via Step) to the next state.
GAIA_SUCCESS,
@@ -53,7 +56,7 @@ class SyncSetupWizard {
~SyncSetupWizard();
// Advances the wizard to the specified state if possible, or opens a
- // new dialog starting at |advance_state|. If the wizard has never ran
+ // new dialog starting at |advance_state|. If the wizard has never run
// through to completion, it will always attempt to do so. Otherwise, e.g
// for a transient auth failure, it will just run as far as is necessary
// based on |advance_state| (so for auth failure, up to GAIA_SUCCESS).
@@ -63,6 +66,10 @@ class SyncSetupWizard {
// if various buttons in the UI should be enabled or disabled.
bool IsVisible() const;
+ // Returns either GAIA_LOGIN or OAUTH_LOGIN depending on which
+ // authentication scheme is in force.
+ static State GetLoginState();
+
// Focus the dialog if it is already open. Does nothing if the dialog is
// not visible.
void Focus();
diff --git a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc
index 2476c39..1036241 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc
@@ -65,7 +65,7 @@ void NewTabSyncSetupHandler::Observe(int type,
void NewTabSyncSetupHandler::ShowSetupUI() {
ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- service->get_wizard().Step(SyncSetupWizard::GAIA_LOGIN);
+ service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
void NewTabSyncSetupHandler::HandleInitializeSyncPromo(const ListValue* args) {
diff --git a/chrome/browser/ui/webui/options/options_sync_setup_handler.cc b/chrome/browser/ui/webui/options/options_sync_setup_handler.cc
index d953544..caaa053 100644
--- a/chrome/browser/ui/webui/options/options_sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/options/options_sync_setup_handler.cc
@@ -28,7 +28,7 @@ void OptionsSyncSetupHandler::ShowSetupUI() {
service->get_wizard().Step(SyncSetupWizard::CONFIGURE);
}
} else {
- service->get_wizard().Step(SyncSetupWizard::GAIA_LOGIN);
+ service->get_wizard().Step(SyncSetupWizard::GetLoginState());
}
// Show the Sync Setup page.
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index f85c6cb..8da58bb 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -10,7 +10,9 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_setup_flow.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "grit/chromium_strings.h"
@@ -293,6 +295,14 @@ void SyncSetupHandler::RegisterMessages() {
NewCallback(this, &SyncSetupHandler::HandleShowSetupUI));
}
+// Ideal(?) solution here would be to mimic the ClientLogin overlay. Since
+// this UI must render an external URL, that overlay cannot be used directly.
+// The current implementation is functional, but fails asthetically.
+// TODO(rickcam): Bug 90711: Update UI for OAuth sign-in flow
+void SyncSetupHandler::ShowOAuthLogin() {
+ web_ui_->GetProfile()->GetProfileSyncService()->signin()->StartOAuthSignIn();
+}
+
void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) {
StringValue page("login");
web_ui_->CallJavascriptFunction(
diff --git a/chrome/browser/ui/webui/sync_setup_handler.h b/chrome/browser/ui/webui/sync_setup_handler.h
index 2b35d23..8adc627 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.h
+++ b/chrome/browser/ui/webui/sync_setup_handler.h
@@ -17,20 +17,22 @@ class SyncSetupHandler : public OptionsPageUIHandler,
virtual ~SyncSetupHandler();
// OptionsPageUIHandler implementation.
- virtual void GetLocalizedValues(base::DictionaryValue* localized_strings);
- virtual void Initialize();
- virtual void RegisterMessages();
+ virtual void GetLocalizedValues(base::DictionaryValue* localized_strings)
+ OVERRIDE;
+ virtual void Initialize() OVERRIDE;
+ virtual void RegisterMessages() OVERRIDE;
// SyncSetupFlowHandler implementation.
- virtual void ShowGaiaLogin(const base::DictionaryValue& args);
- virtual void ShowGaiaSuccessAndClose();
- virtual void ShowGaiaSuccessAndSettingUp();
- virtual void ShowConfigure(const base::DictionaryValue& args);
- virtual void ShowPassphraseEntry(const base::DictionaryValue& args);
- virtual void ShowSettingUp();
- virtual void ShowSetupDone(const std::wstring& user);
- virtual void SetFlow(SyncSetupFlow* flow);
- virtual void Focus();
+ 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 ShowPassphraseEntry(const base::DictionaryValue& args) OVERRIDE;
+ virtual void ShowSettingUp() OVERRIDE;
+ virtual void ShowSetupDone(const std::wstring& user) OVERRIDE;
+ virtual void SetFlow(SyncSetupFlow* flow) OVERRIDE;
+ virtual void Focus() OVERRIDE;
static void GetStaticLocalizedValues(
base::DictionaryValue* localized_strings);