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

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

Issue 7189029: Implement an initial extension settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Make clang happy Created 9 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/extensions/extension_function.h"
11 #include "chrome/browser/extensions/extension_settings.h"
12 #include "chrome/browser/extensions/extension_settings_storage.h"
13
14 // Superclass of all settings functions.
15 class SettingsFunction : public AsyncExtensionFunction {
16 public:
17 // Extension settings function implementations should do their work here, and
18 // either run a StorageResultCallback or fill the function result / call
19 // SendResponse themselves.
20 // The exception is that implementations can return false to immediately
21 // call SendResponse(false), for compliance with EXTENSION_FUNCTION_VALIDATE.
22 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) = 0;
23
24 virtual bool RunImpl() OVERRIDE;
25
26 // Callback from all storage methods (Get/Set/Remove/Clear) which sets the
27 // appropriate fields of the extension function (result/error) and sends a
28 // response.
29 // Declared here to access to the protected members of ExtensionFunction.
30 class StorageResultCallback : public ExtensionSettingsStorage::Callback {
31 public:
32 explicit StorageResultCallback(SettingsFunction* settings_function);
33 virtual ~StorageResultCallback();
34 virtual void OnSuccess(DictionaryValue* settings) OVERRIDE;
35 virtual void OnFailure(const std::string& message) OVERRIDE;
36
37 private:
38 scoped_refptr<SettingsFunction> settings_function_;
39 };
40
41 private:
42 // Callback method from GetStorage(); delegates to RunWithStorageImpl.
43 void RunWithStorage(ExtensionSettingsStorage* storage);
44 };
45
46 class GetSettingsFunction : public SettingsFunction {
47 public:
48 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get");
49
50 protected:
51 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
52 };
53
54 class SetSettingsFunction : public SettingsFunction {
55 public:
56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set");
57
58 protected:
59 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
60 };
61
62 class RemoveSettingsFunction : public SettingsFunction {
63 public:
64 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove");
65
66 protected:
67 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
68 };
69
70 class ClearSettingsFunction : public SettingsFunction {
71 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear");
73
74 protected:
75 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
76 };
77
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_settings.cc ('k') | chrome/browser/extensions/extension_settings_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698