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_
11 #include "base/basictypes.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
19 namespace extensions {
21 class SettingsOverridesAPI : public ProfileKeyedAPI,
22 public content::NotificationObserver {
24 explicit SettingsOverridesAPI(Profile* profile);
25 virtual ~SettingsOverridesAPI();
27 // ProfileKeyedAPI implementation.
28 static ProfileKeyedAPIFactory<SettingsOverridesAPI>* GetFactoryInstance();
31 friend class ProfileKeyedAPIFactory<SettingsOverridesAPI>;
33 typedef std::set<scoped_refptr<const Extension> > PendingExtensions;
35 // Wrappers around PreferenceAPI.
36 void SetPref(const std::string& extension_id,
37 const std::string& pref_key,
39 void UnsetPref(const std::string& extension_id,
40 const std::string& pref_key);
41 // content::NotificationObserver implementation.
42 virtual void Observe(int type,
43 const content::NotificationSource& source,
44 const content::NotificationDetails& details) OVERRIDE;
45 // BrowserContextKeyedService implementation.
46 virtual void Shutdown() OVERRIDE;
48 void OnTemplateURLsLoaded();
50 void RegisterSearchProvider(const Extension* extension) const;
51 // ProfileKeyedAPI implementation.
52 static const char* service_name() { return "SettingsOverridesAPI"; }
55 TemplateURLService* url_service_;
57 // List of extensions waiting for the TemplateURLService to Load to
58 // have search provider registered.
59 PendingExtensions pending_extensions_;
61 content::NotificationRegistrar registrar_;
62 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
64 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI);
68 void ProfileKeyedAPIFactory<SettingsOverridesAPI>::DeclareFactoryDependencies();
70 } // namespace extensions
72 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_H_