| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // The signin manager encapsulates some functionality tracking | 5 // The signin manager encapsulates some functionality tracking | 
| 6 // which user is signed in. | 6 // which user is signed in. | 
| 7 // | 7 // | 
| 8 // **NOTE** on semantics of SigninManager: | 8 // **NOTE** on semantics of SigninManager: | 
| 9 // | 9 // | 
| 10 // Once a signin is successful, the username becomes "established" and will not | 10 // Once a signin is successful, the username becomes "established" and will not | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 30 #include "base/logging.h" | 30 #include "base/logging.h" | 
| 31 #include "base/memory/scoped_ptr.h" | 31 #include "base/memory/scoped_ptr.h" | 
| 32 #include "base/observer_list.h" | 32 #include "base/observer_list.h" | 
| 33 #include "base/prefs/pref_change_registrar.h" | 33 #include "base/prefs/pref_change_registrar.h" | 
| 34 #include "base/prefs/pref_member.h" | 34 #include "base/prefs/pref_member.h" | 
| 35 #include "components/keyed_service/core/keyed_service.h" | 35 #include "components/keyed_service/core/keyed_service.h" | 
| 36 #include "components/signin/core/browser/signin_internals_util.h" | 36 #include "components/signin/core/browser/signin_internals_util.h" | 
| 37 #include "google_apis/gaia/google_service_auth_error.h" | 37 #include "google_apis/gaia/google_service_auth_error.h" | 
| 38 | 38 | 
| 39 class AccountTrackerService; | 39 class AccountTrackerService; | 
|  | 40 class PrefRegistrySimple; | 
| 40 class PrefService; | 41 class PrefService; | 
| 41 class SigninClient; | 42 class SigninClient; | 
| 42 | 43 | 
|  | 44 namespace user_prefs { | 
|  | 45 class PrefRegistrySyncable; | 
|  | 46 } | 
|  | 47 | 
| 43 class SigninManagerBase : public KeyedService { | 48 class SigninManagerBase : public KeyedService { | 
| 44  public: | 49  public: | 
| 45   class Observer { | 50   class Observer { | 
| 46    public: | 51    public: | 
| 47     // Called when a user fails to sign into Google services such as sync. | 52     // Called when a user fails to sign into Google services such as sync. | 
| 48     virtual void GoogleSigninFailed(const GoogleServiceAuthError& error) {} | 53     virtual void GoogleSigninFailed(const GoogleServiceAuthError& error) {} | 
| 49 | 54 | 
| 50     // Called when a user signs into Google services such as sync. | 55     // Called when a user signs into Google services such as sync. | 
| 51     virtual void GoogleSigninSucceeded(const std::string& account_id, | 56     virtual void GoogleSigninSucceeded(const std::string& account_id, | 
| 52                                        const std::string& username, | 57                                        const std::string& username, | 
| 53                                        const std::string& password) {} | 58                                        const std::string& password) {} | 
| 54 | 59 | 
| 55     // Called when the currently signed-in user for a user has been signed out. | 60     // Called when the currently signed-in user for a user has been signed out. | 
| 56     virtual void GoogleSignedOut(const std::string& account_id, | 61     virtual void GoogleSignedOut(const std::string& account_id, | 
| 57                                  const std::string& username) {} | 62                                  const std::string& username) {} | 
| 58 | 63 | 
| 59    protected: | 64    protected: | 
| 60     virtual ~Observer() {} | 65     virtual ~Observer() {} | 
| 61   }; | 66   }; | 
| 62 | 67 | 
| 63   SigninManagerBase(SigninClient* client, | 68   SigninManagerBase(SigninClient* client, | 
| 64                     AccountTrackerService* account_tracker_service); | 69                     AccountTrackerService* account_tracker_service); | 
| 65   ~SigninManagerBase() override; | 70   ~SigninManagerBase() override; | 
| 66 | 71 | 
|  | 72   // Registers per-profile prefs. | 
|  | 73   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 
|  | 74 | 
|  | 75   // Registers per-install prefs. | 
|  | 76   static void RegisterPrefs(PrefRegistrySimple* registry); | 
|  | 77 | 
| 67   // If user was signed in, load tokens from DB if available. | 78   // If user was signed in, load tokens from DB if available. | 
| 68   virtual void Initialize(PrefService* local_state); | 79   virtual void Initialize(PrefService* local_state); | 
| 69   bool IsInitialized() const; | 80   bool IsInitialized() const; | 
| 70 | 81 | 
| 71   // Returns true if a signin to Chrome is allowed (by policy or pref). | 82   // Returns true if a signin to Chrome is allowed (by policy or pref). | 
| 72   // TODO(tim): kSigninAllowed is defined for all platforms in pref_names.h. | 83   // TODO(tim): kSigninAllowed is defined for all platforms in pref_names.h. | 
| 73   // If kSigninAllowed pref was non-Chrome OS-only, this method wouldn't be | 84   // If kSigninAllowed pref was non-Chrome OS-only, this method wouldn't be | 
| 74   // needed, but as is we provide this method to let all interested code | 85   // needed, but as is we provide this method to let all interested code | 
| 75   // code query the value in one way, versus half using PrefService directly | 86   // code query the value in one way, versus half using PrefService directly | 
| 76   // and the other half using SigninManager. | 87   // and the other half using SigninManager. | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160   // The list of SigninDiagnosticObservers. | 171   // The list of SigninDiagnosticObservers. | 
| 161   base::ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> | 172   base::ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> | 
| 162       signin_diagnostics_observers_; | 173       signin_diagnostics_observers_; | 
| 163 | 174 | 
| 164   base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; | 175   base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; | 
| 165 | 176 | 
| 166   DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); | 177   DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); | 
| 167 }; | 178 }; | 
| 168 | 179 | 
| 169 #endif  // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_BASE_H_ | 180 #endif  // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_BASE_H_ | 
| OLD | NEW | 
|---|