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

Side by Side Diff: chrome/browser/extensions/api/preference/preference_api.h

Issue 10952021: Moving preference API into api/preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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) 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_API_PREFERENCE_PREFERENCE_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/api/prefs/pref_change_registrar.h" 10 #include "chrome/browser/api/prefs/pref_change_registrar.h"
11 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 13
14 class PrefService; 14 class PrefService;
15 15
16 namespace base { 16 namespace base {
17 class Value; 17 class Value;
18 } 18 }
19 19
20 class ExtensionPreferenceEventRouter : public content::NotificationObserver { 20 namespace extensions {
21
22 class PreferenceEventRouter : public content::NotificationObserver {
21 public: 23 public:
22 explicit ExtensionPreferenceEventRouter(Profile* profile); 24 explicit PreferenceEventRouter(Profile* profile);
23 virtual ~ExtensionPreferenceEventRouter(); 25 virtual ~PreferenceEventRouter();
24 26
25 private: 27 private:
26 // content::NotificationObserver implementation. 28 // content::NotificationObserver implementation.
27 virtual void Observe(int type, 29 virtual void Observe(int type,
28 const content::NotificationSource& source, 30 const content::NotificationSource& source,
29 const content::NotificationDetails& details) OVERRIDE; 31 const content::NotificationDetails& details) OVERRIDE;
30 32
31 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key); 33 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
32 34
33 // This method dispatches events to the extension message service. 35 // This method dispatches events to the extension message service.
34 void DispatchEvent(const std::string& extension_id, 36 void DispatchEvent(const std::string& extension_id,
35 const std::string& event_name, 37 const std::string& event_name,
36 const std::string& json_args); 38 const std::string& json_args);
37 39
38 PrefChangeRegistrar registrar_; 40 PrefChangeRegistrar registrar_;
39 PrefChangeRegistrar incognito_registrar_; 41 PrefChangeRegistrar incognito_registrar_;
40 42
41 // Weak, owns us (transitively via ExtensionService). 43 // Weak, owns us (transitively via ExtensionService).
42 Profile* profile_; 44 Profile* profile_;
43 45
44 DISALLOW_COPY_AND_ASSIGN(ExtensionPreferenceEventRouter); 46 DISALLOW_COPY_AND_ASSIGN(PreferenceEventRouter);
45 }; 47 };
46 48
47 class PrefTransformerInterface { 49 class PrefTransformerInterface {
48 public: 50 public:
49 virtual ~PrefTransformerInterface() {} 51 virtual ~PrefTransformerInterface() {}
50 52
51 // Converts the representation of a preference as seen by the extension 53 // Converts the representation of a preference as seen by the extension
52 // into a representation that is used in the pref stores of the browser. 54 // into a representation that is used in the pref stores of the browser.
53 // Returns the pref store representation in case of success or sets 55 // Returns the pref store representation in case of success or sets
54 // |error| and returns NULL otherwise. |bad_message| is passed to simulate 56 // |error| and returns NULL otherwise. |bad_message| is passed to simulate
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 public: 110 public:
109 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear") 111 DECLARE_EXTENSION_FUNCTION_NAME("types.ChromeSetting.clear")
110 112
111 protected: 113 protected:
112 virtual ~ClearPreferenceFunction(); 114 virtual ~ClearPreferenceFunction();
113 115
114 // ExtensionFunction: 116 // ExtensionFunction:
115 virtual bool RunImpl() OVERRIDE; 117 virtual bool RunImpl() OVERRIDE;
116 }; 118 };
117 119
118 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 120 } // namespace extensions
121
122 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698