Chromium Code Reviews| 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()); |
| } |