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

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

Issue 15024007: Eliminate BrowserProcess dependency from sign-in production code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR Created 7 years, 7 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_manager.h ('k') | chrome/browser/signin/signin_manager_base.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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile_io_data.h" 17 #include "chrome/browser/profiles/profile_io_data.h"
19 #include "chrome/browser/signin/about_signin_internals.h" 18 #include "chrome/browser/signin/about_signin_internals.h"
20 #include "chrome/browser/signin/about_signin_internals_factory.h" 19 #include "chrome/browser/signin/about_signin_internals_factory.h"
21 #include "chrome/browser/signin/signin_global_error.h" 20 #include "chrome/browser/signin/signin_global_error.h"
22 #include "chrome/browser/signin/signin_internals_util.h" 21 #include "chrome/browser/signin/signin_internals_util.h"
23 #include "chrome/browser/signin/signin_manager_cookie_helper.h" 22 #include "chrome/browser/signin/signin_manager_cookie_helper.h"
24 #include "chrome/browser/signin/signin_manager_delegate.h" 23 #include "chrome/browser/signin/signin_manager_delegate.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 24 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/browser/signin/token_service.h" 25 #include "chrome/browser/signin/token_service.h"
27 #include "chrome/browser/signin/token_service_factory.h" 26 #include "chrome/browser/signin/token_service_factory.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 374
376 content::NotificationService::current()->Notify( 375 content::NotificationService::current()->Notify(
377 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 376 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
378 content::Source<Profile>(profile_), 377 content::Source<Profile>(profile_),
379 content::Details<const GoogleServiceSignoutDetails>(&details)); 378 content::Details<const GoogleServiceSignoutDetails>(&details));
380 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 379 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
381 token_service->ResetCredentialsInMemory(); 380 token_service->ResetCredentialsInMemory();
382 token_service->EraseTokensFromDB(); 381 token_service->EraseTokensFromDB();
383 } 382 }
384 383
385 void SigninManager::Initialize(Profile* profile) { 384 void SigninManager::Initialize(Profile* profile, PrefService* local_state) {
386 SigninManagerBase::Initialize(profile); 385 SigninManagerBase::Initialize(profile, local_state);
387 386
388 // local_state can be null during unit tests. 387 // local_state can be null during unit tests.
389 PrefService* local_state = g_browser_process->local_state();
390 if (local_state) { 388 if (local_state) {
391 local_state_pref_registrar_.Init(local_state); 389 local_state_pref_registrar_.Init(local_state);
392 local_state_pref_registrar_.Add( 390 local_state_pref_registrar_.Add(
393 prefs::kGoogleServicesUsernamePattern, 391 prefs::kGoogleServicesUsernamePattern,
394 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, 392 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged,
395 weak_pointer_factory_.GetWeakPtr())); 393 weak_pointer_factory_.GetWeakPtr()));
396 } 394 }
397 signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(), 395 signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(),
398 base::Bind(&SigninManager::OnSigninAllowedPrefChanged, 396 base::Bind(&SigninManager::OnSigninAllowedPrefChanged,
399 base::Unretained(this))); 397 base::Unretained(this)));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 string16 username16 = UTF8ToUTF16(username); 456 string16 username16 = UTF8ToUTF16(username);
459 icu::UnicodeString icu_input(username16.data(), username16.length()); 457 icu::UnicodeString icu_input(username16.data(), username16.length());
460 matcher.reset(icu_input); 458 matcher.reset(icu_input);
461 status = U_ZERO_ERROR; 459 status = U_ZERO_ERROR;
462 UBool match = matcher.matches(status); 460 UBool match = matcher.matches(status);
463 DCHECK(U_SUCCESS(status)); 461 DCHECK(U_SUCCESS(status));
464 return !!match; // !! == convert from UBool to bool. 462 return !!match; // !! == convert from UBool to bool.
465 } 463 }
466 464
467 bool SigninManager::IsAllowedUsername(const std::string& username) const { 465 bool SigninManager::IsAllowedUsername(const std::string& username) const {
468 PrefService* local_state = g_browser_process->local_state(); 466 const PrefService* local_state = local_state_pref_registrar_.prefs();
469 if (!local_state) 467 if (!local_state)
470 return true; // In a unit test with no local state - all names are allowed. 468 return true; // In a unit test with no local state - all names are allowed.
471 469
472 std::string pattern = local_state->GetString( 470 std::string pattern = local_state->GetString(
473 prefs::kGoogleServicesUsernamePattern); 471 prefs::kGoogleServicesUsernamePattern);
474 return IsUsernameAllowedByPolicy(username, pattern); 472 return IsUsernameAllowedByPolicy(username, pattern);
475 } 473 }
476 474
477 void SigninManager::RevokeOAuthLoginToken() { 475 void SigninManager::RevokeOAuthLoginToken() {
478 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 476 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 697 }
700 } 698 }
701 699
702 void SigninManager::ProhibitSignout(bool prohibit_signout) { 700 void SigninManager::ProhibitSignout(bool prohibit_signout) {
703 prohibit_signout_ = prohibit_signout; 701 prohibit_signout_ = prohibit_signout;
704 } 702 }
705 703
706 bool SigninManager::IsSignoutProhibited() const { 704 bool SigninManager::IsSignoutProhibited() const {
707 return prohibit_signout_; 705 return prohibit_signout_;
708 } 706 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/signin/signin_manager_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698