Commit 4c316bae authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Forward browser action bar activation to background page.

This fixes the following three tests for UAv2:
- BrowserActionApiTest.TestPictureInPictureOnBrowserActionIconClick
- PictureInPictureLazyBackgroundPageApiTest.PictureInPictureInBackgroundPage
- NotificationsApiTest.TestUserGesture

Bug: 860718
Change-Id: I004f7a3922b7b9f39f4371c0dfdd439c6f0b9a07
Reviewed-on: https://chromium-review.googlesource.com/c/1336029Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608767}
parent d8d6e765
......@@ -977,21 +977,38 @@ void Dispatcher::OnMessageInvoke(const std::string& extension_id,
void Dispatcher::OnDispatchEvent(
const ExtensionMsg_DispatchEvent_Params& params,
const base::ListValue& event_args) {
content::RenderFrame* background_frame =
ExtensionFrameHelper::GetBackgroundPageFrame(params.extension_id);
std::unique_ptr<WebScopedUserGesture> web_user_gesture;
if (params.is_user_gesture)
web_user_gesture.reset(new WebScopedUserGesture(nullptr));
// Synthesize a user gesture if this was in response to user action; this is
// necessary if the gesture was e.g. by clicking on the extension toolbar
// icon, context menu entry, etc.
//
// This will only add an active user gesture for the background page, so any
// listeners in different frames (like a popup or tab) won't be able to use
// the user gesture. This is intentional, since frames other than the
// background page should have their own user gestures, such as through button
// clicks.
if (params.is_user_gesture && background_frame) {
ScriptContext* background_context =
ScriptContextSet::GetMainWorldContextForFrame(background_frame);
if (background_context && bindings_system_->HasEventListenerInContext(
params.event_name, background_context)) {
web_user_gesture.reset(
new WebScopedUserGesture(background_frame->GetWebFrame()));
}
}
DispatchEvent(params.extension_id, params.event_name, event_args,
&params.filtering_info);
if (background_frame) {
// Tell the browser process when an event has been dispatched with a lazy
// background page active.
const Extension* extension =
RendererExtensionRegistry::Get()->GetByID(params.extension_id);
if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) {
content::RenderFrame* background_frame =
ExtensionFrameHelper::GetBackgroundPageFrame(params.extension_id);
if (background_frame) {
background_frame->Send(new ExtensionHostMsg_EventAck(
background_frame->GetRoutingID(), params.event_id));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment