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..aa12c5106b62123d66564efb39d34a5b9f9d5601 100644 |
| --- a/chrome/browser/extensions/browser_event_router.cc |
| +++ b/chrome/browser/extensions/browser_event_router.cc |
| @@ -339,17 +339,17 @@ void BrowserEventRouter::TabMoved(WebContents* contents, |
| void BrowserEventRouter::TabUpdated(WebContents* contents, bool did_navigate) { |
| TabEntry* entry = GetTabEntry(contents); |
| - DictionaryValue* changed_properties = NULL; |
| + scoped_ptr<DictionaryValue> changed_properties; |
| DCHECK(entry); |
| if (did_navigate) |
| - changed_properties = entry->DidNavigate(contents); |
| + changed_properties.reset(entry->DidNavigate(contents)); |
| else |
| - changed_properties = entry->UpdateLoadState(contents); |
| + changed_properties.reset(entry->UpdateLoadState(contents)); |
| - if (changed_properties) |
| - DispatchTabUpdatedEvent(contents, changed_properties); |
| + if (changed_properties.get()) |
|
not at google - send to devlin
2013/01/09 02:04:29
scoped_ptr works in conditionals without the .get(
mvrable
2013/01/09 19:25:35
Done.
|
| + DispatchTabUpdatedEvent(contents, changed_properties.Pass()); |
| } |
| void BrowserEventRouter::DispatchEvent( |
| @@ -397,18 +397,26 @@ void BrowserEventRouter::DispatchSimpleBrowserEvent( |
| } |
| static void WillDispatchTabUpdatedEvent(WebContents* contents, |
| + DictionaryValue* changed_properties, |
|
not at google - send to devlin
2013/01/09 02:04:29
const&?
mvrable
2013/01/09 19:25:35
Changed to a const*. I'm getting compiler errors
|
| Profile* profile, |
| const Extension* extension, |
| ListValue* event_args) { |
| + // Overwrite the second argument with the appropriate properties dictionary, |
| + // depending on extension permissions. |
| + DictionaryValue* properties_value = changed_properties->DeepCopy(); |
| + ExtensionTabUtil::ScrubTabValueForExtension(contents, extension, |
| + properties_value); |
| + 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); |
| } |
| void BrowserEventRouter::DispatchTabUpdatedEvent( |
| - WebContents* contents, DictionaryValue* changed_properties) { |
| - DCHECK(changed_properties); |
| + WebContents* contents, scoped_ptr<DictionaryValue> changed_properties) { |
| + DCHECK(changed_properties.get()); |
|
not at google - send to devlin
2013/01/09 02:04:29
can omit the .get()
mvrable
2013/01/09 19:25:35
Done.
|
| DCHECK(contents); |
| // The state of the tab (as seen from the extension point of view) has |
| @@ -418,8 +426,9 @@ void BrowserEventRouter::DispatchTabUpdatedEvent( |
| // 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 +438,8 @@ 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.get()); |
| ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); |
| } |
| @@ -481,10 +491,10 @@ void BrowserEventRouter::TabPinnedStateChanged(WebContents* contents, |
| int tab_index; |
| if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
| - DictionaryValue* changed_properties = new DictionaryValue(); |
| + scoped_ptr<DictionaryValue> changed_properties(new DictionaryValue()); |
| changed_properties->SetBoolean(tab_keys::kPinnedKey, |
| tab_strip->IsTabPinned(tab_index)); |
| - DispatchTabUpdatedEvent(contents, changed_properties); |
| + DispatchTabUpdatedEvent(contents, changed_properties.Pass()); |
| } |
| } |
| @@ -571,8 +581,7 @@ void BrowserEventRouter::ExtensionActionExecuted( |
| if (event_name) { |
| scoped_ptr<ListValue> args(new ListValue()); |
| DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue( |
| - web_contents, |
| - ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS); |
| + web_contents); |
| args->Append(tab_value); |
| DispatchEventToExtension(profile, |