OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SETTINGS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
11 #include "chrome/browser/extensions/extension_settings.h" | 11 #include "chrome/browser/extensions/extension_settings.h" |
12 #include "chrome/browser/extensions/extension_settings_storage.h" | 12 #include "chrome/browser/extensions/extension_settings_storage.h" |
| 13 #include "chrome/browser/extensions/syncable_extension_settings_storage.h" |
13 | 14 |
14 // Superclass of all settings functions. | 15 // Superclass of all settings functions. |
15 class SettingsFunction : public AsyncExtensionFunction { | 16 class SettingsFunction : public AsyncExtensionFunction { |
16 public: | 17 public: |
17 // Extension settings function implementations should do their work here, and | 18 // Extension settings function implementations should do their work here, and |
18 // either run a StorageResultCallback or fill the function result / call | 19 // either run a StorageResultCallback or fill the function result / call |
19 // SendResponse themselves. | 20 // SendResponse themselves. |
20 // The exception is that implementations can return false to immediately | 21 // The exception is that implementations can return false to immediately |
21 // call SendResponse(false), for compliance with EXTENSION_FUNCTION_VALIDATE. | 22 // call SendResponse(false), for compliance with EXTENSION_FUNCTION_VALIDATE. |
22 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) = 0; | 23 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) = 0; |
(...skipping 10 matching lines...) Expand all Loading... |
33 virtual ~StorageResultCallback(); | 34 virtual ~StorageResultCallback(); |
34 virtual void OnSuccess(DictionaryValue* settings) OVERRIDE; | 35 virtual void OnSuccess(DictionaryValue* settings) OVERRIDE; |
35 virtual void OnFailure(const std::string& message) OVERRIDE; | 36 virtual void OnFailure(const std::string& message) OVERRIDE; |
36 | 37 |
37 private: | 38 private: |
38 scoped_refptr<SettingsFunction> settings_function_; | 39 scoped_refptr<SettingsFunction> settings_function_; |
39 }; | 40 }; |
40 | 41 |
41 private: | 42 private: |
42 // Callback method from GetStorage(); delegates to RunWithStorageImpl. | 43 // Callback method from GetStorage(); delegates to RunWithStorageImpl. |
43 void RunWithStorage(ExtensionSettingsStorage* storage); | 44 void RunWithStorage(SyncableExtensionSettingsStorage* storage); |
44 }; | 45 }; |
45 | 46 |
46 class GetSettingsFunction : public SettingsFunction { | 47 class GetSettingsFunction : public SettingsFunction { |
47 public: | 48 public: |
48 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get"); | 49 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get"); |
49 | 50 |
50 protected: | 51 protected: |
51 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE; | 52 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE; |
52 }; | 53 }; |
53 | 54 |
(...skipping 15 matching lines...) Expand all Loading... |
69 | 70 |
70 class ClearSettingsFunction : public SettingsFunction { | 71 class ClearSettingsFunction : public SettingsFunction { |
71 public: | 72 public: |
72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear"); | 73 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear"); |
73 | 74 |
74 protected: | 75 protected: |
75 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE; | 76 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE; |
76 }; | 77 }; |
77 | 78 |
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ | 79 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ |
OLD | NEW |