1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_
6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
11 enum class ServiceAccessType
;
13 class KeyedServiceBaseFactory
;
19 namespace sync_driver
{
25 class ChromeBrowserState
;
26 class KeyedServiceProvider
;
28 // Registers and returns the global KeyedService provider.
29 void SetKeyedServiceProvider(KeyedServiceProvider
* provider
);
30 KeyedServiceProvider
* GetKeyedServiceProvider();
32 // A class that provides access to KeyedService that do not have a pure iOS
33 // implementation yet.
34 class KeyedServiceProvider
{
36 KeyedServiceProvider();
37 virtual ~KeyedServiceProvider();
39 // Ensures that all KeyedService factories are instantiated. Must be called
40 // before any BrowserState instance is created so that dependencies are
42 virtual void AssertKeyedFactoriesBuilt() = 0;
44 // Returns the bookmarks::BookmarkModel factory for dependencies.
45 virtual KeyedServiceBaseFactory
* GetBookmarkModelFactory() = 0;
47 // Returns an instance of bookmarks::BookmarkModel tied to |browser_state|.
48 virtual bookmarks::BookmarkModel
* GetBookmarkModelForBrowserState(
49 ChromeBrowserState
* browser_state
) = 0;
51 // Returns the sync_driver::SyncService factory for dependencies.
52 virtual KeyedServiceBaseFactory
* GetSyncServiceFactory() = 0;
54 // Returns an instance of sync_driver::SyncService tied to |browser_state|.
55 virtual sync_driver::SyncService
* GetSyncServiceForBrowserState(
56 ChromeBrowserState
* browser_state
) = 0;
59 DISALLOW_COPY_AND_ASSIGN(KeyedServiceProvider
);
64 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_