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

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

Issue 6596044: Add onChange event to preference extension APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 9 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"
13 #include "chrome/common/notification_observer.h"
14
15 class ExtensionPreferenceEventRouter : public NotificationObserver {
16 public:
17 explicit ExtensionPreferenceEventRouter(Profile* profile);
18 virtual ~ExtensionPreferenceEventRouter();
19
20 private:
21 // NotificationObserver implementation.
22 virtual void Observe(NotificationType type,
23 const NotificationSource& source,
24 const NotificationDetails& details);
25
26 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
27
28 // This method dispatches events to the extension message service.
29 void DispatchEvent(const std::string& extension_id,
30 const std::string& event_name,
31 const std::string& json_args);
32
33 PrefChangeRegistrar registrar_;
34 PrefChangeRegistrar incognito_registrar_;
35
36 // Weak, owns us (transitively via ExtensionService).
37 Profile* profile_;
38
39 DISALLOW_COPY_AND_ASSIGN(ExtensionPreferenceEventRouter);
40 };
12 41
13 class GetPreferenceFunction : public SyncExtensionFunction { 42 class GetPreferenceFunction : public SyncExtensionFunction {
14 public: 43 public:
15 virtual ~GetPreferenceFunction(); 44 virtual ~GetPreferenceFunction();
16 virtual bool RunImpl(); 45 virtual bool RunImpl();
17 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.get") 46 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.get")
18
19 private:
20 // Returns a string constant (defined in API) indicating the level of
21 // control this extension has on the specified preference.
22 const char* GetLevelOfControl(const std::string& browser_pref,
23 bool incognito) const;
24 }; 47 };
25 48
26 class SetPreferenceFunction : public SyncExtensionFunction { 49 class SetPreferenceFunction : public SyncExtensionFunction {
27 public: 50 public:
28 virtual ~SetPreferenceFunction(); 51 virtual ~SetPreferenceFunction();
29 virtual bool RunImpl(); 52 virtual bool RunImpl();
30 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.set") 53 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.set")
31 }; 54 };
32 55
33 class ClearPreferenceFunction : public SyncExtensionFunction { 56 class ClearPreferenceFunction : public SyncExtensionFunction {
34 public: 57 public:
35 virtual ~ClearPreferenceFunction(); 58 virtual ~ClearPreferenceFunction();
36 virtual bool RunImpl(); 59 virtual bool RunImpl();
37 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.clear") 60 DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.clear")
38 }; 61 };
39 62
40 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ 63 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698