| OLD | NEW |
| 1 // Copyright (c) 2012 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 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // into a representation that is used by the extension. | 64 // into a representation that is used by the extension. |
| 65 // Returns the extension representation in case of success or NULL otherwise. | 65 // Returns the extension representation in case of success or NULL otherwise. |
| 66 // The ownership of the returned value is passed to the caller. | 66 // The ownership of the returned value is passed to the caller. |
| 67 virtual base::Value* BrowserToExtensionPref( | 67 virtual base::Value* BrowserToExtensionPref( |
| 68 const base::Value* browser_pref) = 0; | 68 const base::Value* browser_pref) = 0; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // A base class to provide functionality common to the other *PreferenceFunction | 71 // A base class to provide functionality common to the other *PreferenceFunction |
| 72 // classes. | 72 // classes. |
| 73 class PreferenceFunction : public SyncExtensionFunction { | 73 class PreferenceFunction : public SyncExtensionFunction { |
| 74 public: | 74 protected: |
| 75 virtual ~PreferenceFunction(); | 75 virtual ~PreferenceFunction(); |
| 76 | 76 |
| 77 protected: | |
| 78 // Given an |extension_pref_key|, provides its |browser_pref_key| from the | 77 // Given an |extension_pref_key|, provides its |browser_pref_key| from the |
| 79 // static map in extension_preference.cc. Returns true if the corresponding | 78 // static map in extension_preference.cc. Returns true if the corresponding |
| 80 // browser pref exists and the extension has the API permission needed to | 79 // browser pref exists and the extension has the API permission needed to |
| 81 // modify that pref. Sets |error_| if the extension doesn't have the needed | 80 // modify that pref. Sets |error_| if the extension doesn't have the needed |
| 82 // permission. | 81 // permission. |
| 83 bool ValidateBrowserPref(const std::string& extension_pref_key, | 82 bool ValidateBrowserPref(const std::string& extension_pref_key, |
| 84 std::string* browser_pref_key); | 83 std::string* browser_pref_key); |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 class GetPreferenceFunction : public PreferenceFunction { | 86 class GetPreferenceFunction : public PreferenceFunction { |
| 88 public: | 87 public: |
| 88 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") |
| 89 |
| 90 protected: |
| 89 virtual ~GetPreferenceFunction(); | 91 virtual ~GetPreferenceFunction(); |
| 92 |
| 93 // ExtensionFunction: |
| 90 virtual bool RunImpl() OVERRIDE; | 94 virtual bool RunImpl() OVERRIDE; |
| 91 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") | |
| 92 }; | 95 }; |
| 93 | 96 |
| 94 class SetPreferenceFunction : public PreferenceFunction { | 97 class SetPreferenceFunction : public PreferenceFunction { |
| 95 public: | 98 public: |
| 99 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") |
| 100 |
| 101 protected: |
| 96 virtual ~SetPreferenceFunction(); | 102 virtual ~SetPreferenceFunction(); |
| 103 |
| 104 // ExtensionFunction: |
| 97 virtual bool RunImpl() OVERRIDE; | 105 virtual bool RunImpl() OVERRIDE; |
| 98 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") | |
| 99 }; | 106 }; |
| 100 | 107 |
| 101 class ClearPreferenceFunction : public PreferenceFunction { | 108 class ClearPreferenceFunction : public PreferenceFunction { |
| 102 public: | 109 public: |
| 110 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") |
| 111 |
| 112 protected: |
| 103 virtual ~ClearPreferenceFunction(); | 113 virtual ~ClearPreferenceFunction(); |
| 114 |
| 115 // ExtensionFunction: |
| 104 virtual bool RunImpl() OVERRIDE; | 116 virtual bool RunImpl() OVERRIDE; |
| 105 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") | |
| 106 }; | 117 }; |
| 107 | 118 |
| 108 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ | 119 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ |
| OLD | NEW |