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

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

Issue 11824004: Do not pass URLs in onUpdated events to extensions unless they have the (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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 5947c58687ac048ea50c8758ca34ec387f7a854c..de7974cb6c6b1e5c828a92fa57147dcde5b4b62a 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -397,12 +397,19 @@ void BrowserEventRouter::DispatchSimpleBrowserEvent(
}
static void WillDispatchTabUpdatedEvent(WebContents* contents,
+ DictionaryValue* changed_properties,
Profile* profile,
const Extension* extension,
ListValue* event_args) {
+ // Overwrite the second argument with the appropriate properties dictionary,
+ // depending on extension permissions.
+ DictionaryValue* properties_value =
+ ExtensionTabUtil::ScrubTabValue(contents, extension, changed_properties);
not at google - send to devlin 2013/01/08 21:25:09 since DispatchTabUpdatedEvent is taking ownership
mvrable 2013/01/09 01:46:59 I believe the way this callback works is that it r
+ event_args->Set(1, properties_value);
+
+ // Overwrite the third arg with our tab value as seen by this extension.
DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(
contents, extension);
- // Overwrite the third arg with our tab value as seen by this extension.
event_args->Set(2, tab_value);
}
@@ -415,11 +422,16 @@ void BrowserEventRouter::DispatchTabUpdatedEvent(
// changed. Send a notification to the extension.
scoped_ptr<ListValue> args_base(new ListValue());
+ // Ownership of changed_properties has been passed to us; ensure it is
+ // cleaned up when we return.
+ scoped_ptr<DictionaryValue> changed_properties_deleter(changed_properties);
+
// First arg: The id of the tab that changed.
args_base->AppendInteger(ExtensionTabUtil::GetTabId(contents));
- // Second arg: An object containing the changes to the tab state.
- args_base->Append(changed_properties);
+ // Second arg: An object containing the changes to the tab state. Filled in
+ // by WillDispatchTabUpdatedEvent as a copy of changed_properties, if the
+ // extension has the tabs permission.
// Third arg: An object containing the state of the tab. Filled in by
// WillDispatchTabUpdatedEvent.
@@ -429,7 +441,7 @@ void BrowserEventRouter::DispatchTabUpdatedEvent(
event->restrict_to_profile = profile;
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED;
event->will_dispatch_callback =
- base::Bind(&WillDispatchTabUpdatedEvent, contents);
+ base::Bind(&WillDispatchTabUpdatedEvent, contents, changed_properties);
not at google - send to devlin 2013/01/08 21:25:09 changed_properties will have been deleted by the t
mvrable 2013/01/09 01:46:59 I believe that the callback is run from within Bro
ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
}
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_tab_util.h » ('j') | chrome/browser/extensions/extension_tab_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698