Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / settings_overrides / settings_overrides_api.h
blobe0dad1ca3f146b267e0c97ede94a21754f70dacd
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_H_
8 #include <set>
9 #include <string>
11 #include "base/scoped_observer.h"
12 #include "components/search_engines/template_url_service.h"
13 #include "extensions/browser/browser_context_keyed_api_factory.h"
14 #include "extensions/browser/extension_registry_observer.h"
16 class Profile;
17 class TemplateURL;
19 namespace extensions {
20 class ExtensionRegistry;
22 class SettingsOverridesAPI : public BrowserContextKeyedAPI,
23 public ExtensionRegistryObserver {
24 public:
25 explicit SettingsOverridesAPI(content::BrowserContext* context);
26 ~SettingsOverridesAPI() override;
28 // BrowserContextKeyedAPI implementation.
29 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>*
30 GetFactoryInstance();
32 private:
33 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>;
35 typedef std::set<scoped_refptr<const Extension> > PendingExtensions;
37 // Wrappers around PreferenceAPI.
38 void SetPref(const std::string& extension_id,
39 const std::string& pref_key,
40 base::Value* value);
41 void UnsetPref(const std::string& extension_id,
42 const std::string& pref_key);
44 // ExtensionRegistryObserver implementation.
45 void OnExtensionLoaded(content::BrowserContext* browser_context,
46 const Extension* extension) override;
47 void OnExtensionUnloaded(content::BrowserContext* browser_context,
48 const Extension* extension,
49 UnloadedExtensionInfo::Reason reason) override;
51 // KeyedService implementation.
52 void Shutdown() override;
54 void OnTemplateURLsLoaded();
56 void RegisterSearchProvider(const Extension* extension) const;
57 // BrowserContextKeyedAPI implementation.
58 static const char* service_name() { return "SettingsOverridesAPI"; }
60 Profile* profile_;
61 TemplateURLService* url_service_;
63 // List of extensions waiting for the TemplateURLService to Load to
64 // have search provider registered.
65 PendingExtensions pending_extensions_;
67 // Listen to extension load, unloaded notifications.
68 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
69 extension_registry_observer_;
71 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
73 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI);
76 template <>
77 void BrowserContextKeyedAPIFactory<
78 SettingsOverridesAPI>::DeclareFactoryDependencies();
80 } // namespace extensions
82 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_H_