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

Side by Side Diff: chrome/browser/extensions/extension_preference_api.h

Issue 9566007: Initial Managed Mode extension API, supporting querying the setting and a stub for enabling the mod… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixed API test.js Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 bool* bad_message) = 0; 59 bool* bad_message) = 0;
60 60
61 // Converts the representation of the preference as stored in the browser 61 // Converts the representation of the preference as stored in the browser
62 // into a representation that is used by the extension. 62 // into a representation that is used by the extension.
63 // Returns the extension representation in case of success or NULL otherwise. 63 // Returns the extension representation in case of success or NULL otherwise.
64 // The ownership of the returned value is passed to the caller. 64 // The ownership of the returned value is passed to the caller.
65 virtual base::Value* BrowserToExtensionPref( 65 virtual base::Value* BrowserToExtensionPref(
66 const base::Value* browser_pref) = 0; 66 const base::Value* browser_pref) = 0;
67 }; 67 };
68 68
69 class GetPreferenceFunction : public SyncExtensionFunction { 69 // A base class to provide functionality common to the other *PreferenceFunction
70 // classes.
71 class PreferenceFunction : public SyncExtensionFunction {
72 public:
73 virtual ~PreferenceFunction();
74
75 protected:
76 // Given an |extension_pref_key|, provides its |browser_pref_key| from the
77 // static map in extension_preference.cc. Returns true if the corresponding
78 // browser pref exists and the extension has the API permission needed to
79 // modify that pref. Sets |error_| if the extension doesn't have the needed
80 // permission.
81 bool ValidateBrowserPref(std::string extension_pref_key,
82 std::string* browser_pref_key);
83 };
84
85 class GetPreferenceFunction : public PreferenceFunction {
70 public: 86 public:
71 virtual ~GetPreferenceFunction(); 87 virtual ~GetPreferenceFunction();
72 virtual bool RunImpl() OVERRIDE; 88 virtual bool RunImpl() OVERRIDE;
73 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") 89 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get")
74 }; 90 };
75 91
76 class SetPreferenceFunction : public SyncExtensionFunction { 92 class SetPreferenceFunction : public PreferenceFunction {
77 public: 93 public:
78 virtual ~SetPreferenceFunction(); 94 virtual ~SetPreferenceFunction();
79 virtual bool RunImpl() OVERRIDE; 95 virtual bool RunImpl() OVERRIDE;
80 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") 96 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set")
81 }; 97 };
82 98
83 class ClearPreferenceFunction : public SyncExtensionFunction { 99 class ClearPreferenceFunction : public PreferenceFunction {
84 public: 100 public:
85 virtual ~ClearPreferenceFunction(); 101 virtual ~ClearPreferenceFunction();
86 virtual bool RunImpl() OVERRIDE; 102 virtual bool RunImpl() OVERRIDE;
87 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") 103 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear")
88 }; 104 };
89 105
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 106 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698