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

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: Created 6 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
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/about_signin_internals.h" 17 #include "chrome/browser/signin/about_signin_internals.h"
18 #include "chrome/browser/signin/about_signin_internals_factory.h" 18 #include "chrome/browser/signin/about_signin_internals_factory.h"
19 #include "chrome/browser/signin/local_auth.h"
20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
21 #include "chrome/browser/signin/signin_account_id_helper.h"
22 #include "chrome/browser/signin/signin_internals_util.h" 20 #include "chrome/browser/signin/signin_internals_util.h"
23 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
24 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
25 #include "chrome/common/profile_management_switches.h" 23 #include "chrome/common/profile_management_switches.h"
26 #include "components/signin/core/profile_oauth2_token_service.h" 24 #include "components/signin/core/profile_oauth2_token_service.h"
27 #include "components/signin/core/signin_client.h" 25 #include "components/signin/core/signin_client.h"
28 #include "components/signin/core/signin_manager_cookie_helper.h" 26 #include "components/signin/core/signin_manager_cookie_helper.h"
29 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 294
297 std::string user = profile_->GetPrefs()->GetString( 295 std::string user = profile_->GetPrefs()->GetString(
298 prefs::kGoogleServicesUsername); 296 prefs::kGoogleServicesUsername);
299 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) { 297 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) {
300 // User is signed in, but the username is invalid - the administrator must 298 // User is signed in, but the username is invalid - the administrator must
301 // have changed the policy since the last signin, so sign out the user. 299 // have changed the policy since the last signin, so sign out the user.
302 SignOut(); 300 SignOut();
303 } 301 }
304 302
305 InitTokenService(); 303 InitTokenService();
306 account_id_helper_.reset(new SigninAccountIdHelper(this)); 304 client_->SigninManagerInitialized(this);
307 } 305 }
308 306
309 void SigninManager::Shutdown() { 307 void SigninManager::Shutdown() {
310 if (merge_session_helper_) 308 if (merge_session_helper_)
311 merge_session_helper_->CancelAll(); 309 merge_session_helper_->CancelAll();
312 310
313 local_state_pref_registrar_.RemoveAll(); 311 local_state_pref_registrar_.RemoveAll();
314 account_id_helper_.reset(); 312 client_->SigninManagerShutdown(this);
Roger Tawa OOO till Jul 10th 2014/03/24 14:10:08 At this point, the SM is sort of like half shutdow
315 SigninManagerBase::Shutdown(); 313 SigninManagerBase::Shutdown();
316 } 314 }
317 315
318 void SigninManager::OnGoogleServicesUsernamePatternChanged() { 316 void SigninManager::OnGoogleServicesUsernamePatternChanged() {
319 if (!GetAuthenticatedUsername().empty() && 317 if (!GetAuthenticatedUsername().empty() &&
320 !IsAllowedUsername(GetAuthenticatedUsername())) { 318 !IsAllowedUsername(GetAuthenticatedUsername())) {
321 // Signed in user is invalid according to the current policy so sign 319 // Signed in user is invalid according to the current policy so sign
322 // the user out. 320 // the user out.
323 SignOut(); 321 SignOut();
324 } 322 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 password_); 435 password_);
438 content::NotificationService::current()->Notify( 436 content::NotificationService::current()->Notify(
439 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 437 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
440 content::Source<Profile>(profile_), 438 content::Source<Profile>(profile_),
441 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 439 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
442 440
443 FOR_EACH_OBSERVER(Observer, observer_list_, 441 FOR_EACH_OBSERVER(Observer, observer_list_,
444 GoogleSigninSucceeded(GetAuthenticatedUsername(), 442 GoogleSigninSucceeded(GetAuthenticatedUsername(),
445 password_)); 443 password_));
446 444
447 #if !defined(OS_ANDROID) 445 client_->GoogleSigninSucceeded(GetAuthenticatedUsername(), password_);
448 // Don't store password hash except for users of new profile features.
449 if (switches::IsNewProfileManagement())
450 chrome::SetLocalAuthCredentials(profile_, password_);
451 #endif
452 446
453 password_.clear(); // Don't need it anymore. 447 password_.clear(); // Don't need it anymore.
454 DisableOneClickSignIn(profile_); // Don't ever offer again. 448 DisableOneClickSignIn(profile_); // Don't ever offer again.
455 } 449 }
456 450
457 void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) { 451 void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) {
458 // It's possible we're listening to a "stale" renderer because it was replaced 452 // It's possible we're listening to a "stale" renderer because it was replaced
459 // with a new process by process-per-site. In either case, stop observing it, 453 // with a new process by process-per-site. In either case, stop observing it,
460 // but only reset signin_host_id_ tracking if this was from the current signin 454 // but only reset signin_host_id_ tracking if this was from the current signin
461 // process. 455 // process.
462 signin_hosts_observed_.erase(host); 456 signin_hosts_observed_.erase(host);
463 if (signin_host_id_ == host->GetID()) 457 if (signin_host_id_ == host->GetID())
464 signin_host_id_ = ChildProcessHost::kInvalidUniqueID; 458 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
465 } 459 }
466 460
467 void SigninManager::ProhibitSignout(bool prohibit_signout) { 461 void SigninManager::ProhibitSignout(bool prohibit_signout) {
468 prohibit_signout_ = prohibit_signout; 462 prohibit_signout_ = prohibit_signout;
469 } 463 }
470 464
471 bool SigninManager::IsSignoutProhibited() const { 465 bool SigninManager::IsSignoutProhibited() const {
472 return prohibit_signout_; 466 return prohibit_signout_;
473 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698