diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 20:21:27 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 20:21:27 +0000 |
commit | 6fda572f74ba9950b628e6f655b9a98af388bb12 (patch) | |
tree | e5480656a66699f9964001264c9a1823ade489a2 /chrome/browser/extensions/browser_event_router.cc | |
parent | 31388001637fa18ba206855cd45bf80ab20f6732 (diff) | |
download | chromium_src-6fda572f74ba9950b628e6f655b9a98af388bb12.zip chromium_src-6fda572f74ba9950b628e6f655b9a98af388bb12.tar.gz chromium_src-6fda572f74ba9950b628e6f655b9a98af388bb12.tar.bz2 |
Revert 176406
> Do not pass URLs in onUpdated events to extensions unless they have the
> "tabs" permission.
>
> BUG=168442
>
>
> Review URL: https://chromiumcodereview.appspot.com/11824004
TBR=mvrable@chromium.org
Review URL: https://codereview.chromium.org/11866012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/browser_event_router.cc')
-rw-r--r-- | chrome/browser/extensions/browser_event_router.cc | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc index e647b8f..7b38ef9 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); - scoped_ptr<DictionaryValue> changed_properties; + DictionaryValue* changed_properties = NULL; DCHECK(entry); if (did_navigate) - changed_properties.reset(entry->DidNavigate(contents)); + changed_properties = entry->DidNavigate(contents); else - changed_properties.reset(entry->UpdateLoadState(contents)); + changed_properties = entry->UpdateLoadState(contents); if (changed_properties) - DispatchTabUpdatedEvent(contents, changed_properties.Pass()); + DispatchTabUpdatedEvent(contents, changed_properties); } void BrowserEventRouter::DispatchEvent( @@ -396,27 +396,18 @@ void BrowserEventRouter::DispatchSimpleBrowserEvent( EventRouter::USER_GESTURE_UNKNOWN); } -static void WillDispatchTabUpdatedEvent( - WebContents* contents, - const 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 = 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. +static void WillDispatchTabUpdatedEvent(WebContents* contents, + Profile* profile, + const Extension* extension, + ListValue* event_args) { 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, scoped_ptr<DictionaryValue> changed_properties) { + WebContents* contents, DictionaryValue* changed_properties) { DCHECK(changed_properties); DCHECK(contents); @@ -427,9 +418,8 @@ 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. Filled in - // by WillDispatchTabUpdatedEvent as a copy of changed_properties, if the - // extension has the tabs permission. + // Second arg: An object containing the changes to the tab state. + args_base->Append(changed_properties); // Third arg: An object containing the state of the tab. Filled in by // WillDispatchTabUpdatedEvent. @@ -439,8 +429,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, changed_properties.get()); + base::Bind(&WillDispatchTabUpdatedEvent, contents); ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } @@ -512,10 +501,10 @@ void BrowserEventRouter::TabPinnedStateChanged(WebContents* contents, int tab_index; if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { - scoped_ptr<DictionaryValue> changed_properties(new DictionaryValue()); + DictionaryValue* changed_properties = new DictionaryValue(); changed_properties->SetBoolean(tab_keys::kPinnedKey, tab_strip->IsTabPinned(tab_index)); - DispatchTabUpdatedEvent(contents, changed_properties.Pass()); + DispatchTabUpdatedEvent(contents, changed_properties); } } @@ -602,7 +591,8 @@ void BrowserEventRouter::ExtensionActionExecuted( if (event_name) { scoped_ptr<ListValue> args(new ListValue()); DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue( - web_contents); + web_contents, + ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS); args->Append(tab_value); DispatchEventToExtension(profile, |