Index: chrome/browser/extensions/extension_settings_observer.h |
diff --git a/chrome/browser/extensions/extension_settings_observer.h b/chrome/browser/extensions/extension_settings_observer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4fb6e704545f4f94e7f30f08c07905b8bca3520b |
--- /dev/null |
+++ b/chrome/browser/extensions/extension_settings_observer.h |
@@ -0,0 +1,56 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ |
+#pragma once |
+ |
+#include "base/values.h" |
+ |
+class Profile; |
+ |
+// Interface for classes that listen to changes to extension settings. |
+class ExtensionSettingsObserver { |
+ public: |
+ // A list of setting changes. Use this class when building the event value, |
akalin
2011/10/12 22:26:30
i feel like this class should be in its own class
not at google - send to devlin
2011/10/13 06:40:43
Given comment below, still sensible to have this h
akalin
2011/10/13 20:45:57
I think so. Less coupling is better.
not at google - send to devlin
2011/10/13 23:08:14
Done.
|
+ // then pass the result of |GetEventJson| into |OnSettingsChanged|. |
+ class ChangeList { |
+ public: |
+ ChangeList(); |
+ ~ChangeList(); |
+ |
+ // Appends a change for a setting. |
+ void AppendChange( |
+ const std::string& key, |
+ // Ownership taken. May be NULL to imply there is no old value. |
+ Value* old_value, |
+ // Ownership taken. May be NULL to imply there is no new value. |
+ Value* new_value); |
+ |
+ // Gets the JSON serialization of the event. |
+ std::string GetEventJson() const; |
+ |
+ private: |
+ ListValue changes_; |
+ }; |
+ |
+ // Called when a list of settings have changed for an extension. |
+ // |
+ // |profile| is the profile of the event originator, or NULL if the event |
+ // didn't originate from a background page. This is so that events can avoid |
+ // being sent back to the background page which made the change. When the |
+ // settings API is exposed to content scripts, this will need to be changed. |
+ // |
+ // |event_json| is the JSON serialization of the event to be passed directly |
+ // to the onChanged listeners of the settings API. |
+ virtual void OnSettingsChanged( |
+ Profile* profile, |
+ const std::string& extension_id, |
+ const std::string& event_json) = 0; |
akalin
2011/10/12 22:26:30
I'm not really a fan of flattening into a string b
not at google - send to devlin
2011/10/13 06:40:43
Done.
Though it's really very simple. linked_ptr
akalin
2011/10/13 20:45:15
shared_ptr isn't in Chromium and probably won't be
|
+ |
+ protected: |
+ virtual ~ExtensionSettingsObserver(); |
+}; |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ |