summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_browser_event_router.cc
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-28 16:09:31 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-28 16:09:31 +0000
commitd8dffda127b4192e219b26fac2341e39d000f9a0 (patch)
tree0f88dfd9dae683c58364f4accc1cb72fdb65a3b4 /chrome/browser/extensions/extension_browser_event_router.cc
parent061c88db214f095852bddd1025765816feb1d657 (diff)
downloadchromium_src-d8dffda127b4192e219b26fac2341e39d000f9a0.zip
chromium_src-d8dffda127b4192e219b26fac2341e39d000f9a0.tar.gz
chromium_src-d8dffda127b4192e219b26fac2341e39d000f9a0.tar.bz2
Fix duplicate tab and window events on Chrome OS.
There is one ExtensionBrowserEventRouter per profile, yet each listens for browser events from all profiles. This patch fixes the event duplication by updating ExtensionBrowserEventRouter to drop events when they originate from other profiles. BUG=80559 TEST= See bug. Review URL: http://codereview.chromium.org/7084003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_browser_event_router.cc')
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc101
1 files changed, 55 insertions, 46 deletions
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index 23bc94c..2e54caa 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -61,52 +61,6 @@ DictionaryValue* ExtensionBrowserEventRouter::TabEntry::DidNavigate(
return changed_properties;
}
-static void DispatchEvent(Profile* profile,
- const char* event_name,
- const std::string& json_args) {
- if (profile->GetExtensionEventRouter()) {
- profile->GetExtensionEventRouter()->DispatchEventToRenderers(
- event_name, json_args, profile, GURL());
- }
-}
-
-static void DispatchEventToExtension(Profile* profile,
- const std::string& extension_id,
- const char* event_name,
- const std::string& json_args) {
- if (profile->GetExtensionEventRouter()) {
- profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id, event_name, json_args, profile, GURL());
- }
-}
-
-static void DispatchEventWithTab(Profile* profile,
- const std::string& extension_id,
- const char* event_name,
- const TabContents* tab_contents) {
- ListValue args;
- args.Append(ExtensionTabUtil::CreateTabValue(tab_contents));
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
- if (!extension_id.empty()) {
- DispatchEventToExtension(profile, extension_id, event_name, json_args);
- } else {
- DispatchEvent(profile, event_name, json_args);
- }
-}
-
-static void DispatchSimpleBrowserEvent(Profile* profile,
- const int window_id,
- const char* event_name) {
- ListValue args;
- args.Append(Value::CreateIntegerValue(window_id));
-
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
-
- DispatchEvent(profile, event_name, json_args);
-}
-
void ExtensionBrowserEventRouter::Init() {
if (initialized_)
return;
@@ -406,6 +360,61 @@ void ExtensionBrowserEventRouter::TabUpdated(TabContents* contents,
DispatchTabUpdatedEvent(contents, changed_properties);
}
+void ExtensionBrowserEventRouter::DispatchEvent(Profile* profile,
+ const char* event_name,
+ const std::string& json_args) {
+ if (!profile_->IsSameProfile(profile) || !profile->GetExtensionEventRouter())
+ return;
+
+ profile->GetExtensionEventRouter()->DispatchEventToRenderers(
+ event_name, json_args, profile, GURL());
+}
+
+void ExtensionBrowserEventRouter::DispatchEventToExtension(
+ Profile* profile,
+ const std::string& extension_id,
+ const char* event_name,
+ const std::string& json_args) {
+ if (!profile_->IsSameProfile(profile) || !profile->GetExtensionEventRouter())
+ return;
+
+ profile->GetExtensionEventRouter()->DispatchEventToExtension(
+ extension_id, event_name, json_args, profile, GURL());
+}
+
+void ExtensionBrowserEventRouter::DispatchEventWithTab(
+ Profile* profile,
+ const std::string& extension_id,
+ const char* event_name,
+ const TabContents* tab_contents) {
+ if (!profile_->IsSameProfile(profile))
+ return;
+
+ ListValue args;
+ args.Append(ExtensionTabUtil::CreateTabValue(tab_contents));
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+ if (!extension_id.empty()) {
+ DispatchEventToExtension(profile, extension_id, event_name, json_args);
+ } else {
+ DispatchEvent(profile, event_name, json_args);
+ }
+}
+
+void ExtensionBrowserEventRouter::DispatchSimpleBrowserEvent(
+ Profile* profile, const int window_id, const char* event_name) {
+ if (!profile_->IsSameProfile(profile))
+ return;
+
+ ListValue args;
+ args.Append(Value::CreateIntegerValue(window_id));
+
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+
+ DispatchEvent(profile, event_name, json_args);
+}
+
void ExtensionBrowserEventRouter::DispatchTabUpdatedEvent(
TabContents* contents, DictionaryValue* changed_properties) {
DCHECK(changed_properties);