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

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

Issue 11817045: Move auth-error reporting code out of SyncGlobalError and into SigninGlobalError (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disabled ExtensionActionContextMenuTest.BrowserAction Created 7 years, 11 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_factory.cc » ('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/string_split.h" 11 #include "base/string_split.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/content_settings/cookie_settings.h" 16 #include "chrome/browser/content_settings/cookie_settings.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/signin/about_signin_internals.h" 19 #include "chrome/browser/signin/about_signin_internals.h"
20 #include "chrome/browser/signin/about_signin_internals_factory.h" 20 #include "chrome/browser/signin/about_signin_internals_factory.h"
21 #include "chrome/browser/signin/signin_global_error.h"
21 #include "chrome/browser/signin/signin_internals_util.h" 22 #include "chrome/browser/signin/signin_internals_util.h"
22 #include "chrome/browser/signin/token_service.h" 23 #include "chrome/browser/signin/token_service.h"
23 #include "chrome/browser/signin/token_service_factory.h" 24 #include "chrome/browser/signin/token_service_factory.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/ui/global_error/global_error_service.h"
27 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
25 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
28 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
29 #include "google_apis/gaia/gaia_auth_fetcher.h" 32 #include "google_apis/gaia/gaia_auth_fetcher.h"
30 #include "google_apis/gaia/gaia_constants.h" 33 #include "google_apis/gaia/gaia_constants.h"
31 #include "google_apis/gaia/gaia_urls.h" 34 #include "google_apis/gaia/gaia_urls.h"
32 #include "net/cookies/cookie_monster.h" 35 #include "net/cookies/cookie_monster.h"
33 #include "third_party/icu/public/i18n/unicode/regex.h" 36 #include "third_party/icu/public/i18n/unicode/regex.h"
34 37
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 DCHECK(U_SUCCESS(status)); 95 DCHECK(U_SUCCESS(status));
93 return !!match; // !! == convert from UBool to bool. 96 return !!match; // !! == convert from UBool to bool.
94 } 97 }
95 98
96 SigninManager::SigninManager() 99 SigninManager::SigninManager()
97 : profile_(NULL), 100 : profile_(NULL),
98 had_two_factor_error_(false), 101 had_two_factor_error_(false),
99 type_(SIGNIN_TYPE_NONE) { 102 type_(SIGNIN_TYPE_NONE) {
100 } 103 }
101 104
102 SigninManager::~SigninManager() {} 105 SigninManager::~SigninManager() {
106 DCHECK(!signin_global_error_.get()) <<
107 "SigninManager::Initialize called but not SigninManager::Shutdown";
108 }
103 109
104 void SigninManager::Initialize(Profile* profile) { 110 void SigninManager::Initialize(Profile* profile) {
105 // Should never call Initialize() twice. 111 // Should never call Initialize() twice.
106 DCHECK(!IsInitialized()); 112 DCHECK(!IsInitialized());
107 profile_ = profile; 113 profile_ = profile;
114 signin_global_error_.reset(new SigninGlobalError(profile));
115 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
116 signin_global_error_.get());
108 PrefService* local_state = g_browser_process->local_state(); 117 PrefService* local_state = g_browser_process->local_state();
109 // local_state can be null during unit tests. 118 // local_state can be null during unit tests.
110 if (local_state) { 119 if (local_state) {
111 local_state_pref_registrar_.Init(local_state); 120 local_state_pref_registrar_.Init(local_state);
112 local_state_pref_registrar_.Add( 121 local_state_pref_registrar_.Add(
113 prefs::kGoogleServicesUsernamePattern, 122 prefs::kGoogleServicesUsernamePattern,
114 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, 123 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged,
115 base::Unretained(this))); 124 base::Unretained(this)));
116 } 125 }
117 126
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 CleanupNotificationRegistration(); 607 CleanupNotificationRegistration();
599 } 608 }
600 break; 609 break;
601 } 610 }
602 #endif 611 #endif
603 default: 612 default:
604 NOTREACHED(); 613 NOTREACHED();
605 } 614 }
606 } 615 }
607 616
617 void SigninManager::Shutdown() {
618 if (signin_global_error_.get()) {
619 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
620 signin_global_error_.get());
621 signin_global_error_.reset();
622 }
623 }
624
608 void SigninManager::OnGoogleServicesUsernamePatternChanged() { 625 void SigninManager::OnGoogleServicesUsernamePatternChanged() {
609 if (!authenticated_username_.empty() && 626 if (!authenticated_username_.empty() &&
610 !IsAllowedUsername(authenticated_username_)) { 627 !IsAllowedUsername(authenticated_username_)) {
611 // Signed in user is invalid according to the current policy so sign 628 // Signed in user is invalid according to the current policy so sign
612 // the user out. 629 // the user out.
613 SignOut(); 630 SignOut();
614 } 631 }
615 } 632 }
616 633
617 void SigninManager::AddSigninDiagnosticsObserver( 634 void SigninManager::AddSigninDiagnosticsObserver(
(...skipping 14 matching lines...) Expand all
632 NotifySigninValueChanged(field, value)); 649 NotifySigninValueChanged(field, value));
633 } 650 }
634 651
635 void SigninManager::NotifyDiagnosticsObservers( 652 void SigninManager::NotifyDiagnosticsObservers(
636 const TimedSigninStatusField& field, 653 const TimedSigninStatusField& field,
637 const std::string& value) { 654 const std::string& value) {
638 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 655 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
639 signin_diagnostics_observers_, 656 signin_diagnostics_observers_,
640 NotifySigninValueChanged(field, value)); 657 NotifySigninValueChanged(field, value));
641 } 658 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/signin/signin_manager_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698