| OLD | NEW |
| 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 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/signin/signin_manager.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 11 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 12 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 12 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 13 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 13 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 14 | 14 |
| 15 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 15 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| 16 const std::string& session_index, |
| 16 const std::string& email, | 17 const std::string& email, |
| 17 const std::string& password, | 18 const std::string& password, |
| 18 Profile* profile, | 19 Profile* profile, |
| 19 bool use_default_settings) | 20 bool use_default_settings) |
| 20 : profile_(profile), | 21 : profile_(profile), |
| 21 signin_tracker_(profile, this), | 22 signin_tracker_(profile, this), |
| 22 use_default_settings_(use_default_settings) { | 23 use_default_settings_(use_default_settings) { |
| 23 DCHECK(profile_); | 24 DCHECK(profile_); |
| 24 | 25 |
| 25 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); | 26 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); |
| 26 manager->StartSignInWithCredentials(email, password); | 27 manager->StartSignInWithCredentials(session_index, email, password); |
| 27 } | 28 } |
| 28 | 29 |
| 29 OneClickSigninSyncStarter::~OneClickSigninSyncStarter() { | 30 OneClickSigninSyncStarter::~OneClickSigninSyncStarter() { |
| 30 } | 31 } |
| 31 | 32 |
| 32 void OneClickSigninSyncStarter::GaiaCredentialsValid() { | 33 void OneClickSigninSyncStarter::GaiaCredentialsValid() { |
| 33 } | 34 } |
| 34 | 35 |
| 35 void OneClickSigninSyncStarter::SigninFailed( | 36 void OneClickSigninSyncStarter::SigninFailed( |
| 36 const GoogleServiceAuthError& error) { | 37 const GoogleServiceAuthError& error) { |
| 37 delete this; | 38 delete this; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void OneClickSigninSyncStarter::SigninSuccess() { | 41 void OneClickSigninSyncStarter::SigninSuccess() { |
| 41 ProfileSyncService* profile_sync_service = | 42 ProfileSyncService* profile_sync_service = |
| 42 ProfileSyncServiceFactory::GetForProfile(profile_); | 43 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 43 | 44 |
| 44 if (use_default_settings_) { | 45 if (use_default_settings_) { |
| 45 // Just kick off the sync machine, no need to configure it first. | 46 // Just kick off the sync machine, no need to configure it first. |
| 46 profile_sync_service->SetSyncSetupCompleted(); | 47 profile_sync_service->SetSyncSetupCompleted(); |
| 47 profile_sync_service->UnsuppressAndStart(); | 48 profile_sync_service->UnsuppressAndStart(); |
| 48 } else { | 49 } else { |
| 49 // Give the user a chance to configure things. | 50 // Give the user a chance to configure things. |
| 50 profile_sync_service->ShowConfigure(false); | 51 profile_sync_service->ShowConfigure(false); |
| 51 } | 52 } |
| 52 | 53 |
| 53 delete this; | 54 delete this; |
| 54 } | 55 } |
| OLD | NEW |