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

Side by Side Diff: chrome/browser/extensions/api/settings_overrides/settings_overrides_api.h

Issue 2623833005: Revert of Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/settings_overrides/settings_overrides_api.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_ H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_ H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_ H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_ H_
7 7
8 #include <memory>
9 #include <set> 8 #include <set>
10 #include <string> 9 #include <string>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
14 #include "components/search_engines/template_url_service.h" 13 #include "components/search_engines/template_url_service.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h" 14 #include "extensions/browser/browser_context_keyed_api_factory.h"
16 #include "extensions/browser/extension_registry_observer.h" 15 #include "extensions/browser/extension_registry_observer.h"
17 16
18 class Profile; 17 class Profile;
19 18
20 namespace extensions { 19 namespace extensions {
21 class ExtensionRegistry; 20 class ExtensionRegistry;
22 21
23 class SettingsOverridesAPI : public BrowserContextKeyedAPI, 22 class SettingsOverridesAPI : public BrowserContextKeyedAPI,
24 public ExtensionRegistryObserver { 23 public ExtensionRegistryObserver {
25 public: 24 public:
26 explicit SettingsOverridesAPI(content::BrowserContext* context); 25 explicit SettingsOverridesAPI(content::BrowserContext* context);
27 ~SettingsOverridesAPI() override; 26 ~SettingsOverridesAPI() override;
28 27
29 // BrowserContextKeyedAPI implementation. 28 // BrowserContextKeyedAPI implementation.
30 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>* 29 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>*
31 GetFactoryInstance(); 30 GetFactoryInstance();
32 31
33 private: 32 private:
34 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>; 33 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>;
35 34
35 typedef std::set<scoped_refptr<const Extension> > PendingExtensions;
36
36 // Wrappers around PreferenceAPI. 37 // Wrappers around PreferenceAPI.
37 void SetPref(const std::string& extension_id, 38 void SetPref(const std::string& extension_id,
38 const std::string& pref_key, 39 const std::string& pref_key,
39 std::unique_ptr<base::Value> value) const; 40 base::Value* value);
40 void UnsetPref(const std::string& extension_id, 41 void UnsetPref(const std::string& extension_id,
41 const std::string& pref_key) const; 42 const std::string& pref_key);
42 43
43 // ExtensionRegistryObserver implementation. 44 // ExtensionRegistryObserver implementation.
44 void OnExtensionLoaded(content::BrowserContext* browser_context, 45 void OnExtensionLoaded(content::BrowserContext* browser_context,
45 const Extension* extension) override; 46 const Extension* extension) override;
46 void OnExtensionUnloaded(content::BrowserContext* browser_context, 47 void OnExtensionUnloaded(content::BrowserContext* browser_context,
47 const Extension* extension, 48 const Extension* extension,
48 UnloadedExtensionInfo::Reason reason) override; 49 UnloadedExtensionInfo::Reason reason) override;
49 50
51 // KeyedService implementation.
52 void Shutdown() override;
53
54 void OnTemplateURLsLoaded();
55
50 void RegisterSearchProvider(const Extension* extension) const; 56 void RegisterSearchProvider(const Extension* extension) const;
51 // BrowserContextKeyedAPI implementation. 57 // BrowserContextKeyedAPI implementation.
52 static const char* service_name() { return "SettingsOverridesAPI"; } 58 static const char* service_name() { return "SettingsOverridesAPI"; }
53 59
54 Profile* profile_; 60 Profile* profile_;
55 TemplateURLService* url_service_; 61 TemplateURLService* url_service_;
56 62
63 // List of extensions waiting for the TemplateURLService to Load to
64 // have search provider registered.
65 PendingExtensions pending_extensions_;
66
57 // Listen to extension load, unloaded notifications. 67 // Listen to extension load, unloaded notifications.
58 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 68 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
59 extension_registry_observer_; 69 extension_registry_observer_;
60 70
71 std::unique_ptr<TemplateURLService::Subscription> template_url_sub_;
72
61 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI); 73 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI);
62 }; 74 };
63 75
64 template <> 76 template <>
65 void BrowserContextKeyedAPIFactory< 77 void BrowserContextKeyedAPIFactory<
66 SettingsOverridesAPI>::DeclareFactoryDependencies(); 78 SettingsOverridesAPI>::DeclareFactoryDependencies();
67 79
68 } // namespace extensions 80 } // namespace extensions
69 81
70 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A PI_H_ 82 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A PI_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698