/chrome/browser/extensions/api/preference/chrome_direct_setting_api.h

https://gitlab.com/0072016/Facebook-SDK- · C Header · 65 lines · 36 code · 20 blank · 9 comment · 0 complexity · da041c0972093a027f263a3bb07aa687 MD5 · raw file

  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.
  4. #ifndef CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
  5. #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
  6. #include "base/macros.h"
  7. #include "components/prefs/pref_change_registrar.h"
  8. #include "extensions/browser/browser_context_keyed_api_factory.h"
  9. #include "extensions/browser/event_router.h"
  10. class Profile;
  11. namespace content {
  12. class BrowserContext;
  13. }
  14. namespace extensions {
  15. namespace chromedirectsetting {
  16. class ChromeDirectSettingAPI : public BrowserContextKeyedAPI,
  17. public EventRouter::Observer {
  18. public:
  19. explicit ChromeDirectSettingAPI(content::BrowserContext* context);
  20. ~ChromeDirectSettingAPI() override;
  21. // KeyedService implementation.
  22. void Shutdown() override;
  23. // BrowserContextKeyedAPI implementation.
  24. static BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>*
  25. GetFactoryInstance();
  26. // EventRouter::Observer implementation.
  27. void OnListenerAdded(const EventListenerInfo& details) override;
  28. // Returns true if the preference is on the whitelist.
  29. bool IsPreferenceOnWhitelist(const std::string& pref_key);
  30. // Convenience method to get the ChromeDirectSettingAPI for a profile.
  31. static ChromeDirectSettingAPI* Get(content::BrowserContext* context);
  32. private:
  33. friend class BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>;
  34. // BrowserContextKeyedAPI implementation.
  35. static const char* service_name();
  36. void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
  37. static const bool kServiceIsNULLWhileTesting = true;
  38. static const bool kServiceRedirectedInIncognito = false;
  39. PrefChangeRegistrar registrar_;
  40. Profile* profile_;
  41. DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI);
  42. };
  43. } // namespace chromedirectsetting
  44. } // namespace extensions
  45. #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__