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_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__
8 #include "base/lazy_instance.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h"
13 namespace extensions
{
14 namespace chromedirectsetting
{
16 // Base class to host instance method helpers.
17 class DirectSettingFunctionBase
: public ChromeSyncExtensionFunction
{
19 DirectSettingFunctionBase();
20 ~DirectSettingFunctionBase() override
;
22 // Returns the user pref service.
23 PrefService
* GetPrefService();
25 // Returns true if the caller is a component extension.
26 bool IsCalledFromComponentExtension();
29 DISALLOW_COPY_AND_ASSIGN(DirectSettingFunctionBase
);
32 class GetDirectSettingFunction
: public DirectSettingFunctionBase
{
34 DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.get",
35 TYPES_PRIVATE_CHROMEDIRECTSETTING_GET
)
37 GetDirectSettingFunction();
41 bool RunSync() override
;
44 ~GetDirectSettingFunction() override
;
45 DISALLOW_COPY_AND_ASSIGN(GetDirectSettingFunction
);
48 class SetDirectSettingFunction
: public DirectSettingFunctionBase
{
50 DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.set",
51 TYPES_PRIVATE_CHROMEDIRECTSETTING_SET
)
53 SetDirectSettingFunction();
57 bool RunSync() override
;
60 ~SetDirectSettingFunction() override
;
61 DISALLOW_COPY_AND_ASSIGN(SetDirectSettingFunction
);
64 class ClearDirectSettingFunction
: public DirectSettingFunctionBase
{
66 DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.clear",
67 TYPES_PRIVATE_CHROMEDIRECTSETTING_CLEAR
)
69 ClearDirectSettingFunction();
73 bool RunSync() override
;
76 ~ClearDirectSettingFunction() override
;
77 DISALLOW_COPY_AND_ASSIGN(ClearDirectSettingFunction
);
80 } // namespace chromedirectsetting
81 } // namespace extensions
83 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__