Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2450)

Unified Diff: chrome/browser/extensions/api/preference/chrome_direct_setting.h

Issue 18341016: Add types.private.ChromeDirectSetting and Connect it to preferencesPrivate.googleGeolocationAccessE… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added Lazy Initialized Whitelist Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/preference/chrome_direct_setting.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/preference/chrome_direct_setting.h
diff --git a/chrome/browser/extensions/api/preference/chrome_direct_setting.h b/chrome/browser/extensions/api/preference/chrome_direct_setting.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd290c86213f5f77aeca846200ba6c583e0ae510
--- /dev/null
+++ b/chrome/browser/extensions/api/preference/chrome_direct_setting.h
@@ -0,0 +1,100 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__
+#define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__
+
+#include "base/lazy_instance.h"
+#include "chrome/browser/extensions/extension_function.h"
+
+class PrefService;
+
+namespace extensions {
+namespace chromedirectsetting {
+
+// Base class to host instance method helpers.
+class DirectSettingFunctionBase : public SyncExtensionFunction {
+ protected:
+ explicit DirectSettingFunctionBase() {}
+ virtual ~DirectSettingFunctionBase() {}
+
+ // Returns the user pref service.
+ PrefService* GetPrefService();
+
+ // Returns true if the caller is a component extension.
+ bool IsCalledFromComponentExtension();
+
+ // Returns true if the preference is on the whitelist.
+ bool IsPreferenceOnWhitelist(const std::string& pref_key);
+
+ private:
+ class PreferenceWhitelist {
Bernhard Bauer 2013/07/09 23:23:44 You can move this class (and the variable) to the
robliao 2013/07/09 23:37:41 I'll move the class, but keep it in the namespace.
Bernhard Bauer 2013/07/10 10:52:25 I'm sorry, but that's not the customary way in Chr
robliao 2013/07/10 16:52:39 Where can I provide feedback on this rule? I've bu
+ public:
+ explicit PreferenceWhitelist();
Bernhard Bauer 2013/07/09 23:23:44 Explicit is only necessary for single-argument con
robliao 2013/07/09 23:37:41 Done.
+
+ bool IsPreferenceOnWhitelist(const std::string& pref_key);
+
+ private:
+ base::hash_set<std::string> whitelist_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreferenceWhitelist);
+ };
+
+ static base::LazyInstance<PreferenceWhitelist> preference_whitelist_;
+ DISALLOW_COPY_AND_ASSIGN(DirectSettingFunctionBase);
+};
+
+class GetDirectSettingFunction : public DirectSettingFunctionBase {
+ public:
+ DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.get",
+ TYPES_PRIVATE_CHROMEDIRECTSETTING_GET)
+
+ explicit GetDirectSettingFunction() {}
+
+ protected:
+ // ExtensionFunction:
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ virtual ~GetDirectSettingFunction() {}
+ DISALLOW_COPY_AND_ASSIGN(GetDirectSettingFunction);
+};
+
+class SetDirectSettingFunction : public DirectSettingFunctionBase {
+ public:
+ DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.set",
+ TYPES_PRIVATE_CHROMEDIRECTSETTING_SET)
+
+ explicit SetDirectSettingFunction() {}
+
+ protected:
+ // ExtensionFunction:
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ virtual ~SetDirectSettingFunction() {}
+ DISALLOW_COPY_AND_ASSIGN(SetDirectSettingFunction);
+};
+
+class ClearDirectSettingFunction : public DirectSettingFunctionBase {
+ public:
+ DECLARE_EXTENSION_FUNCTION("types.private.ChromeDirectSetting.clear",
+ TYPES_PRIVATE_CHROMEDIRECTSETTING_CLEAR)
+
+ explicit ClearDirectSettingFunction() {}
+
+ protected:
+ // ExtensionFunction:
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ virtual ~ClearDirectSettingFunction() {}
+ DISALLOW_COPY_AND_ASSIGN(ClearDirectSettingFunction);
+};
+
+} // namespace chromedirectsetting
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__
+
« no previous file with comments | « no previous file | chrome/browser/extensions/api/preference/chrome_direct_setting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698