Chromium Code Reviews| 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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/content_settings/cookie_settings.h" | |
| 13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/signin/token_service.h" | 16 #include "chrome/browser/signin/token_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/net/gaia/gaia_constants.h" | 20 #include "chrome/common/net/gaia/gaia_constants.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 22 | 23 |
| 23 const char kGetInfoEmailKey[] = "email"; | 24 const char kGetInfoEmailKey[] = "email"; |
| 24 const char kGetInfoServicesKey[] = "allServices"; | 25 const char kGetInfoServicesKey[] = "allServices"; |
| 25 const char kGooglePlusServiceKey[] = "googleme"; | 26 const char kGooglePlusServiceKey[] = "googleme"; |
| 26 | 27 |
| 28 const char kGoogleAccountsUrl[] = "https://accounts.google.com"; | |
| 29 | |
| 27 SigninManager::SigninManager() | 30 SigninManager::SigninManager() |
| 28 : profile_(NULL), | 31 : profile_(NULL), |
| 29 had_two_factor_error_(false), | 32 had_two_factor_error_(false), |
| 30 last_login_auth_error_(GoogleServiceAuthError::None()) { | 33 last_login_auth_error_(GoogleServiceAuthError::None()) { |
| 31 } | 34 } |
| 32 | 35 |
| 33 SigninManager::~SigninManager() {} | 36 SigninManager::~SigninManager() {} |
| 34 | 37 |
| 35 void SigninManager::Initialize(Profile* profile) { | 38 void SigninManager::Initialize(Profile* profile) { |
| 36 // Should never call Initialize() twice. | 39 // Should never call Initialize() twice. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 profile_->GetRequestContext())); | 114 profile_->GetRequestContext())); |
| 112 client_login_->StartClientLogin(username, | 115 client_login_->StartClientLogin(username, |
| 113 password, | 116 password, |
| 114 "", | 117 "", |
| 115 login_token, | 118 login_token, |
| 116 login_captcha, | 119 login_captcha, |
| 117 GaiaAuthFetcher::HostedAccountsNotAllowed); | 120 GaiaAuthFetcher::HostedAccountsNotAllowed); |
| 118 | 121 |
| 119 // Register for token availability. The signin manager will pre-login the | 122 // Register for token availability. The signin manager will pre-login the |
| 120 // user when the GAIA service token is ready for use. Only do this if we | 123 // user when the GAIA service token is ready for use. Only do this if we |
| 121 // are not running in ChomiumOS, since it handles pre-login itself. | 124 // are not running in ChomiumOS, since it handles pre-login itself, and if |
| 125 // cookies are not disabled for Google accounts. | |
| 122 #if !defined(OS_CHROMEOS) | 126 #if !defined(OS_CHROMEOS) |
| 127 CookieSettings* cookie_settings = | |
| 128 CookieSettings::Factory::GetForProfile(profile_); | |
| 129 if (cookie_settings->IsReadingCookieAllowed(GURL(kGoogleAccountsUrl), | |
|
jochen (gone - plz use gerrit)
2012/03/01 08:27:58
IsSettingCookieAllowed is enough. Also, please use
Roger Tawa OOO till Jul 10th
2012/03/01 16:53:36
Done. I added a check against null pointer too.
| |
| 130 GURL("")) && | |
| 131 cookie_settings->IsSettingCookieAllowed(GURL(kGoogleAccountsUrl), | |
| 132 GURL(""))) { | |
| 123 registrar_.Add(this, | 133 registrar_.Add(this, |
| 124 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 134 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 125 content::Source<TokenService>(profile_->GetTokenService())); | 135 content::Source<TokenService>(profile_->GetTokenService())); |
| 136 } | |
| 126 #endif | 137 #endif |
| 127 } | 138 } |
| 128 | 139 |
| 129 void SigninManager::ProvideSecondFactorAccessCode( | 140 void SigninManager::ProvideSecondFactorAccessCode( |
| 130 const std::string& access_code) { | 141 const std::string& access_code) { |
| 131 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && | 142 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && |
| 132 last_result_.data.empty()); | 143 last_result_.data.empty()); |
| 133 | 144 |
| 134 client_login_.reset(new GaiaAuthFetcher(this, | 145 client_login_.reset(new GaiaAuthFetcher(this, |
| 135 GaiaConstants::kChromeSource, | 146 GaiaConstants::kChromeSource, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 profile_->GetRequestContext())); | 296 profile_->GetRequestContext())); |
| 286 } | 297 } |
| 287 | 298 |
| 288 client_login_->StartMergeSession(tok_details->token()); | 299 client_login_->StartMergeSession(tok_details->token()); |
| 289 | 300 |
| 290 // We only want to do this once per sign-in. | 301 // We only want to do this once per sign-in. |
| 291 CleanupNotificationRegistration(); | 302 CleanupNotificationRegistration(); |
| 292 } | 303 } |
| 293 #endif | 304 #endif |
| 294 } | 305 } |
| OLD | NEW |