OLD | NEW |
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
14 #include "chrome/browser/extensions/api/storage/settings_namespace.h" | 13 #include "chrome/browser/extensions/api/storage/settings_namespace.h" |
15 #include "chrome/browser/extensions/api/storage/settings_observer.h" | 14 #include "chrome/browser/extensions/api/storage/settings_observer.h" |
16 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" | 15 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" |
17 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" | 16 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" |
18 #include "chrome/browser/extensions/api/storage/value_store_cache.h" | 17 #include "chrome/browser/extensions/api/storage/value_store_cache.h" |
| 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
19 #include "sync/api/syncable_service.h" | 19 #include "sync/api/syncable_service.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class BrowserContext; | 22 class BrowserContext; |
23 } | 23 } |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
26 | 26 |
27 // The component of extension settings which runs on the UI thread, as opposed | 27 // The component of extension settings which runs on the UI thread, as opposed |
28 // to SettingsBackend which lives on the FILE thread. | 28 // to SettingsBackend which lives on the FILE thread. |
29 // All public methods, must be called on the UI thread, with the exception of | 29 // All public methods, must be called on the UI thread, with the exception of |
30 // GetBackendForSync(), which must be called on the FILE thread. | 30 // GetBackendForSync(), which must be called on the FILE thread. |
31 class SettingsFrontend : public ProfileKeyedAPI { | 31 class SettingsFrontend : public BrowserContextKeyedAPI { |
32 public: | 32 public: |
33 // Returns the current instance for |context|. | 33 // Returns the current instance for |context|. |
34 static SettingsFrontend* Get(content::BrowserContext* context); | 34 static SettingsFrontend* Get(content::BrowserContext* context); |
35 | 35 |
36 // Creates with a specific |storage_factory|. Caller owns the object. | 36 // Creates with a specific |storage_factory|. Caller owns the object. |
37 static SettingsFrontend* CreateForTesting( | 37 static SettingsFrontend* CreateForTesting( |
38 const scoped_refptr<SettingsStorageFactory>& storage_factory, | 38 const scoped_refptr<SettingsStorageFactory>& storage_factory, |
39 content::BrowserContext* context); | 39 content::BrowserContext* context); |
40 | 40 |
41 // Public so tests can create and delete their own instances. | 41 // Public so tests can create and delete their own instances. |
(...skipping 14 matching lines...) Expand all Loading... |
56 | 56 |
57 // Deletes the settings for the given |extension_id|. | 57 // Deletes the settings for the given |extension_id|. |
58 void DeleteStorageSoon(const std::string& extension_id); | 58 void DeleteStorageSoon(const std::string& extension_id); |
59 | 59 |
60 // Gets the thread-safe observer list. | 60 // Gets the thread-safe observer list. |
61 scoped_refptr<SettingsObserverList> GetObservers(); | 61 scoped_refptr<SettingsObserverList> GetObservers(); |
62 | 62 |
63 void DisableStorageForTesting( | 63 void DisableStorageForTesting( |
64 settings_namespace::Namespace settings_namespace); | 64 settings_namespace::Namespace settings_namespace); |
65 | 65 |
66 // ProfileKeyedAPI implementation. | 66 // BrowserContextKeyedAPI implementation. |
67 static ProfileKeyedAPIFactory<SettingsFrontend>* GetFactoryInstance(); | 67 static BrowserContextKeyedAPIFactory<SettingsFrontend>* GetFactoryInstance(); |
68 static const char* service_name(); | 68 static const char* service_name(); |
69 static const bool kServiceRedirectedInIncognito = true; | 69 static const bool kServiceRedirectedInIncognito = true; |
70 static const bool kServiceIsNULLWhileTesting = true; | 70 static const bool kServiceIsNULLWhileTesting = true; |
71 | 71 |
72 private: | 72 private: |
73 friend class ProfileKeyedAPIFactory<SettingsFrontend>; | 73 friend class BrowserContextKeyedAPIFactory<SettingsFrontend>; |
74 | 74 |
75 typedef std::map<settings_namespace::Namespace, ValueStoreCache*> CacheMap; | 75 typedef std::map<settings_namespace::Namespace, ValueStoreCache*> CacheMap; |
76 | 76 |
77 // Constructor for normal ProfileKeyedAPI usage. | 77 // Constructor for normal BrowserContextKeyedAPI usage. |
78 explicit SettingsFrontend(content::BrowserContext* context); | 78 explicit SettingsFrontend(content::BrowserContext* context); |
79 | 79 |
80 // Constructor for tests. | 80 // Constructor for tests. |
81 SettingsFrontend(const scoped_refptr<SettingsStorageFactory>& storage_factory, | 81 SettingsFrontend(const scoped_refptr<SettingsStorageFactory>& storage_factory, |
82 content::BrowserContext* context); | 82 content::BrowserContext* context); |
83 | 83 |
84 void Init(const scoped_refptr<SettingsStorageFactory>& storage_factory); | 84 void Init(const scoped_refptr<SettingsStorageFactory>& storage_factory); |
85 | 85 |
86 // The quota limit configurations for the local and sync areas, taken out of | 86 // The quota limit configurations for the local and sync areas, taken out of |
87 // the schema in chrome/common/extensions/api/storage.json. | 87 // the schema in chrome/common/extensions/api/storage.json. |
(...skipping 12 matching lines...) Expand all Loading... |
100 // Maps a known namespace to its corresponding ValueStoreCache. The caches | 100 // Maps a known namespace to its corresponding ValueStoreCache. The caches |
101 // are owned by this object. | 101 // are owned by this object. |
102 CacheMap caches_; | 102 CacheMap caches_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); | 104 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace extensions | 107 } // namespace extensions |
108 | 108 |
109 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ | 109 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ |
OLD | NEW |