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

Unified 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: fix 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_preference_api.h
diff --git a/chrome/browser/extensions/extension_preference_api.h b/chrome/browser/extensions/extension_preference_api.h
index d020c11ae375c40412f480553ddd79e0c7d794c5..31c4452c8e4a50658a32e27f980b9ebdd976f9fe 100644
--- a/chrome/browser/extensions/extension_preference_api.h
+++ b/chrome/browser/extensions/extension_preference_api.h
@@ -9,6 +9,35 @@
#include <string>
#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/prefs/pref_change_registrar.h"
+#include "content/common/notification_observer.h"
+
+class ExtensionPreferenceEventRouter : public NotificationObserver {
+ public:
+ explicit ExtensionPreferenceEventRouter(Profile* profile);
+ virtual ~ExtensionPreferenceEventRouter();
+
+ private:
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
+
+ // This method dispatches events to the extension message service.
+ void DispatchEvent(const std::string& extension_id,
+ const std::string& event_name,
+ const std::string& json_args);
+
+ PrefChangeRegistrar registrar_;
+ PrefChangeRegistrar incognito_registrar_;
+
+ // Weak, owns us (transitively via ExtensionService).
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionPreferenceEventRouter);
+};
class Value;
@@ -36,12 +65,6 @@ class GetPreferenceFunction : public SyncExtensionFunction {
virtual ~GetPreferenceFunction();
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.get")
-
- private:
- // Returns a string constant (defined in API) indicating the level of
- // control this extension has on the specified preference.
- const char* GetLevelOfControl(const std::string& browser_pref,
- bool incognito) const;
};
class SetPreferenceFunction : public SyncExtensionFunction {

Powered by Google App Engine
This is Rietveld 408576698