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

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

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
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_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"
12 #include "chrome/browser/prefs/pref_change_registrar.h" 12 #include "chrome/browser/prefs/pref_change_registrar.h"
13 #include "content/common/notification_observer.h" 13 #include "content/common/notification_observer.h"
14 14
15 namespace base {
16 class Value;
17 }
18
15 class ExtensionPreferenceEventRouter : public NotificationObserver { 19 class ExtensionPreferenceEventRouter : public NotificationObserver {
16 public: 20 public:
17 explicit ExtensionPreferenceEventRouter(Profile* profile); 21 explicit ExtensionPreferenceEventRouter(Profile* profile);
18 virtual ~ExtensionPreferenceEventRouter(); 22 virtual ~ExtensionPreferenceEventRouter();
19 23
20 private: 24 private:
21 // NotificationObserver implementation. 25 // NotificationObserver implementation.
22 virtual void Observe(int type, 26 virtual void Observe(int type,
23 const NotificationSource& source, 27 const NotificationSource& source,
24 const NotificationDetails& details); 28 const NotificationDetails& details);
25 29
26 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key); 30 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
27 31
28 // This method dispatches events to the extension message service. 32 // This method dispatches events to the extension message service.
29 void DispatchEvent(const std::string& extension_id, 33 void DispatchEvent(const std::string& extension_id,
30 const std::string& event_name, 34 const std::string& event_name,
31 const std::string& json_args); 35 const std::string& json_args);
32 36
33 PrefChangeRegistrar registrar_; 37 PrefChangeRegistrar registrar_;
34 PrefChangeRegistrar incognito_registrar_; 38 PrefChangeRegistrar incognito_registrar_;
35 39
36 // Weak, owns us (transitively via ExtensionService). 40 // Weak, owns us (transitively via ExtensionService).
37 Profile* profile_; 41 Profile* profile_;
38 42
39 DISALLOW_COPY_AND_ASSIGN(ExtensionPreferenceEventRouter); 43 DISALLOW_COPY_AND_ASSIGN(ExtensionPreferenceEventRouter);
40 }; 44 };
41 45
42 class Value;
43
44 class PrefTransformerInterface { 46 class PrefTransformerInterface {
45 public: 47 public:
46 virtual ~PrefTransformerInterface() {} 48 virtual ~PrefTransformerInterface() {}
47 49
48 // Converts the representation of a preference as seen by the extension 50 // Converts the representation of a preference as seen by the extension
49 // into a representation that is used in the pref stores of the browser. 51 // into a representation that is used in the pref stores of the browser.
50 // Returns the pref store representation in case of success or sets 52 // Returns the pref store representation in case of success or sets
51 // |error| and returns NULL otherwise. |bad_message| is passed to simulate 53 // |error| and returns NULL otherwise. |bad_message| is passed to simulate
52 // the behavior of EXTENSION_FUNCTION_VALIDATE. It is never NULL. 54 // the behavior of EXTENSION_FUNCTION_VALIDATE. It is never NULL.
53 // The ownership of the returned value is passed to the caller. 55 // The ownership of the returned value is passed to the caller.
54 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, 56 virtual base::Value* ExtensionToBrowserPref(
55 std::string* error, 57 const base::Value* extension_pref,
56 bool* bad_message) = 0; 58 std::string* error,
59 bool* bad_message) = 0;
57 60
58 // Converts the representation of the preference as stored in the browser 61 // Converts the representation of the preference as stored in the browser
59 // into a representation that is used by the extension. 62 // into a representation that is used by the extension.
60 // Returns the extension representation in case of success or NULL otherwise. 63 // Returns the extension representation in case of success or NULL otherwise.
61 // The ownership of the returned value is passed to the caller. 64 // The ownership of the returned value is passed to the caller.
62 virtual Value* BrowserToExtensionPref(const Value* browser_pref) = 0; 65 virtual base::Value* BrowserToExtensionPref(
66 const base::Value* browser_pref) = 0;
63 }; 67 };
64 68
65 class GetPreferenceFunction : public SyncExtensionFunction { 69 class GetPreferenceFunction : public SyncExtensionFunction {
66 public: 70 public:
67 virtual ~GetPreferenceFunction(); 71 virtual ~GetPreferenceFunction();
68 virtual bool RunImpl(); 72 virtual bool RunImpl();
69 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get") 73 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.get")
70 }; 74 };
71 75
72 class SetPreferenceFunction : public SyncExtensionFunction { 76 class SetPreferenceFunction : public SyncExtensionFunction {
73 public: 77 public:
74 virtual ~SetPreferenceFunction(); 78 virtual ~SetPreferenceFunction();
75 virtual bool RunImpl(); 79 virtual bool RunImpl();
76 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set") 80 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.set")
77 }; 81 };
78 82
79 class ClearPreferenceFunction : public SyncExtensionFunction { 83 class ClearPreferenceFunction : public SyncExtensionFunction {
80 public: 84 public:
81 virtual ~ClearPreferenceFunction(); 85 virtual ~ClearPreferenceFunction();
82 virtual bool RunImpl(); 86 virtual bool RunImpl();
83 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") 87 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear")
84 }; 88 };
85 89
86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_pref_value_map.h ('k') | chrome/browser/extensions/extension_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698