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

Unified Diff: chrome/browser/extensions/browser_event_router.cc

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ETU now SetString()'s for empty values Created 8 years, 4 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/browser_event_router.cc
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc
index 1aa89c5c90227df9fa71e7421c0339df201b5304..af5cf9b53b39d0a1ad37eac855aaf571cc0769d6 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -384,18 +384,35 @@ void BrowserEventRouter::DispatchEventWithTab(
const char* event_name,
const WebContents* web_contents,
bool active,
- EventRouter::UserGestureState user_gesture) {
+ EventRouter::UserGestureState user_gesture,
+ scoped_ptr<ListValue> event_args) {
if (!profile_->IsSameProfile(profile))
return;
- scoped_ptr<ListValue> args(new ListValue());
- args->Append(ExtensionTabUtil::CreateTabValueActive(
- web_contents, active));
if (!extension_id.empty()) {
- DispatchEventToExtension(profile, extension_id, event_name, args.Pass(),
- user_gesture);
+ event_args->Append(ExtensionTabUtil::CreateTabValueActive(
+ web_contents,
+ active,
+ profile->GetExtensionService()->extensions()->GetByID(extension_id)));
+ DispatchEventToExtension(profile, extension_id, event_name,
+ event_args.Pass(), user_gesture);
} else {
- DispatchEvent(profile, event_name, args.Pass(), user_gesture);
+ const EventListenerMap::ListenerList& listeners(
+ ExtensionSystem::Get(profile)->event_router()->
+ listeners().GetEventListenersByName(event_name));
+
+ for (EventListenerMap::ListenerList::const_iterator it = listeners.begin();
+ it != listeners.end();
+ ++it) {
+ scoped_ptr<ListValue> args(event_args->DeepCopy());
+ args->Append(ExtensionTabUtil::CreateTabValueActive(
+ web_contents,
+ active,
+ profile->GetExtensionService()->extensions()->GetByID(
+ (*it)->extension_id)));
+ DispatchEventToExtension(profile, (*it)->extension_id, event_name,
+ args.Pass(), user_gesture);
+ }
}
}
@@ -427,11 +444,10 @@ void BrowserEventRouter::DispatchTabUpdatedEvent(
args->Append(changed_properties);
// Third arg: An object containing the state of the tab.
- args->Append(ExtensionTabUtil::CreateTabValue(contents));
-
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- DispatchEvent(profile, events::kOnTabUpdated, args.Pass(),
- EventRouter::USER_GESTURE_UNKNOWN);
+
+ DispatchEventWithTab(profile, "", events::kOnTabUpdated, contents, true,
+ EventRouter::USER_GESTURE_UNKNOWN, args.Pass());
}
BrowserEventRouter::TabEntry* BrowserEventRouter::GetTabEntry(
« no previous file with comments | « chrome/browser/extensions/browser_event_router.h ('k') | chrome/browser/extensions/browser_extension_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698