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_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
8 #include "base/prefs/pref_change_registrar.h"
9 #include "extensions/browser/browser_context_keyed_api_factory.h"
10 #include "extensions/browser/event_router.h"
18 namespace extensions
{
19 namespace chromedirectsetting
{
21 class ChromeDirectSettingAPI
: public BrowserContextKeyedAPI
,
22 public EventRouter::Observer
{
24 explicit ChromeDirectSettingAPI(content::BrowserContext
* context
);
26 ~ChromeDirectSettingAPI() override
;
28 // KeyedService implementation.
29 void Shutdown() override
;
31 // BrowserContextKeyedAPI implementation.
32 static BrowserContextKeyedAPIFactory
<ChromeDirectSettingAPI
>*
35 // EventRouter::Observer implementation.
36 void OnListenerAdded(const EventListenerInfo
& details
) override
;
38 // Returns true if the preference is on the whitelist.
39 bool IsPreferenceOnWhitelist(const std::string
& pref_key
);
41 // Convenience method to get the ChromeDirectSettingAPI for a profile.
42 static ChromeDirectSettingAPI
* Get(content::BrowserContext
* context
);
45 friend class BrowserContextKeyedAPIFactory
<ChromeDirectSettingAPI
>;
47 // BrowserContextKeyedAPI implementation.
48 static const char* service_name();
50 void OnPrefChanged(PrefService
* pref_service
, const std::string
& pref_key
);
52 static const bool kServiceIsNULLWhileTesting
= true;
53 static const bool kServiceRedirectedInIncognito
= false;
55 PrefChangeRegistrar registrar_
;
58 DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI
);
61 } // namespace chromedirectsetting
62 } // namespace extensions
64 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__