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

Side by Side Diff: chrome/browser/signin/signin_manager.cc

Issue 9549026: Pre-login should not set cookies and log the user in of cookies are not (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix indent Created 8 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
123 registrar_.Add(this, 127 CookieSettings* cookie_settings =
124 chrome::NOTIFICATION_TOKEN_AVAILABLE, 128 CookieSettings::Factory::GetForProfile(profile_);
125 content::Source<TokenService>(profile_->GetTokenService())); 129 if (cookie_settings &&
130 cookie_settings->IsSettingCookieAllowed(GURL(kGoogleAccountsUrl),
131 GURL(kGoogleAccountsUrl))) {
132 registrar_.Add(this,
133 chrome::NOTIFICATION_TOKEN_AVAILABLE,
134 content::Source<TokenService>(profile_->GetTokenService()));
135 }
126 #endif 136 #endif
127 } 137 }
128 138
129 void SigninManager::ProvideSecondFactorAccessCode( 139 void SigninManager::ProvideSecondFactorAccessCode(
130 const std::string& access_code) { 140 const std::string& access_code) {
131 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && 141 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() &&
132 last_result_.data.empty()); 142 last_result_.data.empty());
133 143
134 client_login_.reset(new GaiaAuthFetcher(this, 144 client_login_.reset(new GaiaAuthFetcher(this,
135 GaiaConstants::kChromeSource, 145 GaiaConstants::kChromeSource,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 profile_->GetRequestContext())); 295 profile_->GetRequestContext()));
286 } 296 }
287 297
288 client_login_->StartMergeSession(tok_details->token()); 298 client_login_->StartMergeSession(tok_details->token());
289 299
290 // We only want to do this once per sign-in. 300 // We only want to do this once per sign-in.
291 CleanupNotificationRegistration(); 301 CleanupNotificationRegistration();
292 } 302 }
293 #endif 303 #endif
294 } 304 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698