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

Unified Diff: ios/chrome/browser/signin/signin_manager_factory.h

Issue 1257663002: iOS factories for SigninManager and GaiaCookieManagerService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fakeSigninManager
Patch Set: Fix copyright Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/signin/signin_manager_factory.h
diff --git a/ios/chrome/browser/signin/signin_manager_factory.h b/ios/chrome/browser/signin/signin_manager_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..015e0cc39b77b178b6e78d7dca540140bfcded81
--- /dev/null
+++ b/ios/chrome/browser/signin/signin_manager_factory.h
@@ -0,0 +1,69 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
+#define IOS_CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
+
+template <typename T>
+struct DefaultSingletonTraits;
+
+class SigninManagerFactoryObserver;
+class SigninManager;
+class PrefRegistrySimple;
+
+namespace ios {
+
+class ChromeBrowserState;
+
+// Singleton that owns all SigninManagers and associates them with browser
+// states.
+class SigninManagerFactory : public BrowserStateKeyedServiceFactory {
+ public:
+ static SigninManager* GetForBrowserState(
+ ios::ChromeBrowserState* browser_state);
+ static SigninManager* GetForBrowserStateIfExists(
+ ios::ChromeBrowserState* browser_state);
+
+ // Returns an instance of the SigninManagerFactory singleton.
+ static SigninManagerFactory* GetInstance();
+
+ // Implementation of BrowserStateKeyedServiceFactory (public so tests
+ // can call it).
+ void RegisterBrowserStatePrefs(
+ user_prefs::PrefRegistrySyncable* registry) override;
+
+ // Registers the browser-global prefs used by SigninManager.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ // Methods to register or remove observers of SigninManager creation/shutdown.
+ void AddObserver(SigninManagerFactoryObserver* observer);
+ void RemoveObserver(SigninManagerFactoryObserver* observer);
+
+ // Notifies observers of |manager|'s creation. Should be called only by test
+ // SigninManager subclasses whose construction does not occur in
+ // |BuildServiceInstanceFor()|.
+ void NotifyObserversOfSigninManagerCreationForTesting(SigninManager* manager);
+
+ private:
+ friend struct DefaultSingletonTraits<SigninManagerFactory>;
+
+ SigninManagerFactory();
+ ~SigninManagerFactory() override;
+
+ // List of observers. Checks that list is empty on destruction.
+ mutable base::ObserverList<SigninManagerFactoryObserver, true> observer_list_;
+
+ // BrowserStateKeyedServiceFactory:
+ scoped_ptr<KeyedService> BuildServiceInstanceFor(
+ web::BrowserState* context) const override;
+ void BrowserStateShutdown(web::BrowserState* context) override;
+};
+}
+
+#endif // IOS_CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
« no previous file with comments | « ios/chrome/browser/signin/gaia_cookie_manager_service_factory.cc ('k') | ios/chrome/browser/signin/signin_manager_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698