OLD | NEW |
---|---|
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 Loading... | |
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(); | |
Bernhard Bauer
2012/03/01 16:32:14
Nit: new line?
| |
74 protected: | |
75 // Given an |extension_pref_key|, provides its |browser_pref_key| from the | |
76 // static map in extension_preference.cc. Returns true if the corresponding | |
77 // browser pref exists and the extension has the API permission needed to | |
78 // modify that pref. | |
Bernhard Bauer
2012/03/01 16:32:14
Can you add a comment that it sets an error if the
| |
79 bool ValidateBrowserPref(std::string extension_pref_key, | |
80 std::string* browser_pref_key); | |
81 }; | |
82 | |
83 class GetPreferenceFunction : public PreferenceFunction { | |
70 public: | 84 public: |
71 virtual ~GetPreferenceFunction(); | 85 virtual ~GetPreferenceFunction(); |
72 virtual bool RunImpl() OVERRIDE; | 86 virtual bool RunImpl() OVERRIDE; |
73 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") | 87 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") |
74 }; | 88 }; |
75 | 89 |
76 class SetPreferenceFunction : public SyncExtensionFunction { | 90 class SetPreferenceFunction : public PreferenceFunction { |
77 public: | 91 public: |
78 virtual ~SetPreferenceFunction(); | 92 virtual ~SetPreferenceFunction(); |
79 virtual bool RunImpl() OVERRIDE; | 93 virtual bool RunImpl() OVERRIDE; |
80 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") | 94 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") |
81 }; | 95 }; |
82 | 96 |
83 class ClearPreferenceFunction : public SyncExtensionFunction { | 97 class ClearPreferenceFunction : public PreferenceFunction { |
84 public: | 98 public: |
85 virtual ~ClearPreferenceFunction(); | 99 virtual ~ClearPreferenceFunction(); |
86 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
87 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") | 101 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") |
88 }; | 102 }; |
89 | 103 |
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ | 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ |
OLD | NEW |