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

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

Issue 244473002: Remove NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED from c/b/e/api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/scoped_observer.h"
12 #include "chrome/browser/search_engines/template_url_service.h" 13 #include "chrome/browser/search_engines/template_url_service.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h" 16 #include "extensions/browser/browser_context_keyed_api_factory.h"
17 #include "extensions/browser/extension_registry_observer.h"
16 18
17 class TemplateURL; 19 class TemplateURL;
18 20
19 namespace extensions { 21 namespace extensions {
22 class ExtensionRegistry;
20 23
21 class SettingsOverridesAPI : public BrowserContextKeyedAPI, 24 class SettingsOverridesAPI : public BrowserContextKeyedAPI,
22 public content::NotificationObserver { 25 public ExtensionRegistryObserver {
23 public: 26 public:
24 explicit SettingsOverridesAPI(content::BrowserContext* context); 27 explicit SettingsOverridesAPI(content::BrowserContext* context);
25 virtual ~SettingsOverridesAPI(); 28 virtual ~SettingsOverridesAPI();
26 29
27 // BrowserContextKeyedAPI implementation. 30 // BrowserContextKeyedAPI implementation.
28 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>* 31 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>*
29 GetFactoryInstance(); 32 GetFactoryInstance();
30 33
31 private: 34 private:
32 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>; 35 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>;
33 36
34 typedef std::set<scoped_refptr<const Extension> > PendingExtensions; 37 typedef std::set<scoped_refptr<const Extension> > PendingExtensions;
35 38
36 // Wrappers around PreferenceAPI. 39 // Wrappers around PreferenceAPI.
37 void SetPref(const std::string& extension_id, 40 void SetPref(const std::string& extension_id,
38 const std::string& pref_key, 41 const std::string& pref_key,
39 base::Value* value); 42 base::Value* value);
40 void UnsetPref(const std::string& extension_id, 43 void UnsetPref(const std::string& extension_id,
41 const std::string& pref_key); 44 const std::string& pref_key);
42 // content::NotificationObserver implementation. 45
43 virtual void Observe(int type, 46 // ExtensionRegistryObserver implementation.
44 const content::NotificationSource& source, 47 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
45 const content::NotificationDetails& details) OVERRIDE; 48 const Extension* extension) OVERRIDE;
49 virtual void OnExtensionUnloaded(
50 content::BrowserContext* browser_context,
51 const Extension* extension,
52 UnloadedExtensionInfo::Reason reason) OVERRIDE;
53
46 // KeyedService implementation. 54 // KeyedService implementation.
47 virtual void Shutdown() OVERRIDE; 55 virtual void Shutdown() OVERRIDE;
48 56
49 void OnTemplateURLsLoaded(); 57 void OnTemplateURLsLoaded();
50 58
51 void RegisterSearchProvider(const Extension* extension) const; 59 void RegisterSearchProvider(const Extension* extension) const;
52 // BrowserContextKeyedAPI implementation. 60 // BrowserContextKeyedAPI implementation.
53 static const char* service_name() { return "SettingsOverridesAPI"; } 61 static const char* service_name() { return "SettingsOverridesAPI"; }
54 62
55 Profile* profile_; 63 Profile* profile_;
56 TemplateURLService* url_service_; 64 TemplateURLService* url_service_;
57 65
58 // List of extensions waiting for the TemplateURLService to Load to 66 // List of extensions waiting for the TemplateURLService to Load to
59 // have search provider registered. 67 // have search provider registered.
60 PendingExtensions pending_extensions_; 68 PendingExtensions pending_extensions_;
61 69
62 content::NotificationRegistrar registrar_; 70 // Listen to extension load, unloaded notifications.
71 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
72 extension_registry_observer_;
73
63 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; 74 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
64 75
65 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI); 76 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI);
66 }; 77 };
67 78
68 template <> 79 template <>
69 void BrowserContextKeyedAPIFactory< 80 void BrowserContextKeyedAPIFactory<
70 SettingsOverridesAPI>::DeclareFactoryDependencies(); 81 SettingsOverridesAPI>::DeclareFactoryDependencies();
71 82
72 } // namespace extensions 83 } // namespace extensions
73 84
74 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A PI_H_ 85 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A PI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698