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

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

Issue 205703005: Componentize SigninIdAccountHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 years, 8 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 | « chrome/browser/signin/signin_account_id_helper.cc ('k') | chrome/common/pref_names.h » ('j') | 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/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/profiles/profile_io_data.h" 16 #include "chrome/browser/profiles/profile_io_data.h"
17 #include "chrome/browser/signin/local_auth.h"
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
19 #include "chrome/browser/signin/signin_account_id_helper.h" 18 #include "chrome/browser/signin/signin_account_id_helper.h"
20 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
21 #include "chrome/common/profile_management_switches.h" 20 #include "chrome/common/profile_management_switches.h"
22 #include "components/signin/core/browser/profile_oauth2_token_service.h" 21 #include "components/signin/core/browser/profile_oauth2_token_service.h"
23 #include "components/signin/core/browser/signin_client.h" 22 #include "components/signin/core/browser/signin_client.h"
24 #include "components/signin/core/browser/signin_internals_util.h" 23 #include "components/signin/core/browser/signin_internals_util.h"
25 #include "components/signin/core/browser/signin_manager_cookie_helper.h" 24 #include "components/signin/core/browser/signin_manager_cookie_helper.h"
26 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 293
295 std::string user = profile_->GetPrefs()->GetString( 294 std::string user = profile_->GetPrefs()->GetString(
296 prefs::kGoogleServicesUsername); 295 prefs::kGoogleServicesUsername);
297 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) { 296 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) {
298 // User is signed in, but the username is invalid - the administrator must 297 // User is signed in, but the username is invalid - the administrator must
299 // have changed the policy since the last signin, so sign out the user. 298 // have changed the policy since the last signin, so sign out the user.
300 SignOut(); 299 SignOut();
301 } 300 }
302 301
303 InitTokenService(); 302 InitTokenService();
304 account_id_helper_.reset(new SigninAccountIdHelper(profile_, this)); 303 account_id_helper_.reset(new SigninAccountIdHelper(
304 client_,
305 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
306 this));
305 } 307 }
306 308
307 void SigninManager::Shutdown() { 309 void SigninManager::Shutdown() {
308 if (merge_session_helper_) 310 if (merge_session_helper_)
309 merge_session_helper_->CancelAll(); 311 merge_session_helper_->CancelAll();
310 312
311 local_state_pref_registrar_.RemoveAll(); 313 local_state_pref_registrar_.RemoveAll();
312 account_id_helper_.reset(); 314 account_id_helper_.reset();
313 SigninManagerBase::Shutdown(); 315 SigninManagerBase::Shutdown();
314 } 316 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 password_); 431 password_);
430 content::NotificationService::current()->Notify( 432 content::NotificationService::current()->Notify(
431 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 433 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
432 content::Source<Profile>(profile_), 434 content::Source<Profile>(profile_),
433 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 435 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
434 436
435 FOR_EACH_OBSERVER(Observer, observer_list_, 437 FOR_EACH_OBSERVER(Observer, observer_list_,
436 GoogleSigninSucceeded(GetAuthenticatedUsername(), 438 GoogleSigninSucceeded(GetAuthenticatedUsername(),
437 password_)); 439 password_));
438 440
439 #if !defined(OS_ANDROID) 441 client_->GoogleSigninSucceeded(GetAuthenticatedUsername(), password_);
440 // Don't store password hash except for users of new profile features.
441 if (switches::IsNewProfileManagement())
442 chrome::SetLocalAuthCredentials(profile_, password_);
443 #endif
444 442
445 password_.clear(); // Don't need it anymore. 443 password_.clear(); // Don't need it anymore.
446 DisableOneClickSignIn(profile_); // Don't ever offer again. 444 DisableOneClickSignIn(profile_); // Don't ever offer again.
447 } 445 }
448 446
449 void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) { 447 void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) {
450 // It's possible we're listening to a "stale" renderer because it was replaced 448 // It's possible we're listening to a "stale" renderer because it was replaced
451 // with a new process by process-per-site. In either case, stop observing it, 449 // with a new process by process-per-site. In either case, stop observing it,
452 // but only reset signin_host_id_ tracking if this was from the current signin 450 // but only reset signin_host_id_ tracking if this was from the current signin
453 // process. 451 // process.
454 signin_hosts_observed_.erase(host); 452 signin_hosts_observed_.erase(host);
455 if (signin_host_id_ == host->GetID()) 453 if (signin_host_id_ == host->GetID())
456 signin_host_id_ = ChildProcessHost::kInvalidUniqueID; 454 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
457 } 455 }
458 456
459 void SigninManager::ProhibitSignout(bool prohibit_signout) { 457 void SigninManager::ProhibitSignout(bool prohibit_signout) {
460 prohibit_signout_ = prohibit_signout; 458 prohibit_signout_ = prohibit_signout;
461 } 459 }
462 460
463 bool SigninManager::IsSignoutProhibited() const { 461 bool SigninManager::IsSignoutProhibited() const {
464 return prohibit_signout_; 462 return prohibit_signout_;
465 } 463 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_account_id_helper.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698