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

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: Remove core file Created 9 years, 5 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 virtual ~SettingsFunction() {}
18
19 // Extension settings function implementations should do their work here, and
20 // either run a StorageResultCallback or fill the function result / call
21 // SendResponse themselves.
22 // The exception is that implementations can return false to immediately
23 // call SendResponse(false), for compliance with EXTENSION_FUNCTION_VALIDATE.
24 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) = 0;
25
26 virtual bool RunImpl() OVERRIDE;
27
28 // Callback from all storage methods (Get/Set/Remove/Clear) which sets the
29 // appropriate fields of the extension function (result/error) and sends a
30 // response.
31 // Declared here to access to the protected members of ExtensionFunction.
32 class StorageResultCallback : public ExtensionSettingsStorage::Callback {
33 public:
34 explicit StorageResultCallback(SettingsFunction* settings_function);
35 ~StorageResultCallback();
36 virtual void OnSuccess(DictionaryValue* settings) OVERRIDE;
37 virtual void OnFailure(const std::string& message) OVERRIDE;
38
39 private:
40 scoped_refptr<SettingsFunction> settings_function_;
41 };
42
43 private:
44 // Callback method from GetStorage(); delegates to RunWithStorageImpl.
45 void RunWithStorage(ExtensionSettingsStorage* storage);
46 };
47
48 class GetSettingsFunction : public SettingsFunction {
49 public:
50 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get");
51
52 protected:
53 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
54 };
55
56 class SetSettingsFunction : public SettingsFunction {
57 public:
58 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set");
59
60 protected:
61 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
62 };
63
64 class RemoveSettingsFunction : public SettingsFunction {
65 public:
66 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove");
67
68 protected:
69 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
70 };
71
72 class ClearSettingsFunction : public SettingsFunction {
73 public:
74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear");
75
76 protected:
77 virtual bool RunWithStorageImpl(ExtensionSettingsStorage* storage) OVERRIDE;
78 };
79
80 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698