Commit 76c2f431 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

UAv2: skip IPCs to the browser when it has been updated already.

Bug: 780556
Change-Id: Iee5496e123f8969cc68ce774ad339d4c90f7c7f0
Reviewed-on: https://chromium-review.googlesource.com/1085248
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565398}
parent 9d4b8e8e
......@@ -468,7 +468,10 @@ class CONTENT_EXPORT RenderFrameHostManager
// match the provided |render_frame_host|.
void CancelPendingIfNecessary(RenderFrameHostImpl* render_frame_host);
// Updates the user activation state in all proxies of this frame. For
// more details, see the comment on FrameTreeNode::user_activation_state_.
void UpdateUserActivationState(blink::UserActivationUpdateType update_type);
void OnSetHasReceivedUserGestureBeforeNavigation(bool value);
// Sets up the necessary state for a new RenderViewHost. If |proxy| is not
......
......@@ -109,6 +109,7 @@
#include "ppapi/buildflags/buildflags.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/frame/user_activation_update_source.h"
#include "third_party/blink/public/mojom/page/page_visibility_state.mojom.h"
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/url_conversion.h"
......@@ -1312,14 +1313,10 @@ WebView* RenderViewImpl::CreateView(WebLocalFrame* creator,
DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_route_id);
DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_widget_route_id);
// This consumption call also propagates to browser and other renderer
// processes. With UAv2, only the part of the call for the current renderer
// process is needed; and the rest (IPCs to the browser then to all other
// renderers) are redundant and should be removed.
//
// TODO(mustaq): Clean this up after considering nuking all renderer-side
// consumptions.
WebUserGestureIndicator::ConsumeUserGesture(creator);
// The browser allowed creation of a new window and consumed the user
// activation (UAv2 only).
WebUserGestureIndicator::ConsumeUserGesture(
creator, blink::UserActivationUpdateSource::kBrowser);
// While this view may be a background extension page, it can spawn a visible
// render view. So we just assume that the new one is not another background
......
......@@ -41,6 +41,7 @@ source_set("headers") {
"frame/frame_policy.h",
"frame/sandbox_flags.h",
"frame/user_activation_state.h",
"frame/user_activation_update_source.h",
"frame/user_activation_update_type.h",
"manifest/manifest.h",
"manifest/manifest_share_target_util.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_USER_ACTIVATION_UPDATE_SOURCE_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_USER_ACTIVATION_UPDATE_SOURCE_H_
namespace blink {
// Limits of UserActivationV2 state updates originated from the current renderer
// process.
enum class UserActivationUpdateSource {
kBrowser,
kRenderer,
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_USER_ACTIVATION_UPDATE_SOURCE_H_
......@@ -7,8 +7,8 @@
namespace blink {
// Types of UserActivationV2 state updates sent between a RenderFrame and a
// RenderFrameProxy
// Types of UserActivationV2 state updates sent between the browser and the
// renderer processes.
enum class UserActivationUpdateType {
kNotifyActivation,
kConsumeTransientActivation,
......
......@@ -31,6 +31,7 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_USER_GESTURE_INDICATOR_H_
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_USER_GESTURE_INDICATOR_H_
#include "third_party/blink/public/common/frame/user_activation_update_source.h"
#include "third_party/blink/public/platform/web_common.h"
namespace blink {
......@@ -56,7 +57,10 @@ class WebUserGestureIndicator {
// Returns true if a consumable gesture exists and has been successfully
// consumed.
BLINK_EXPORT static bool ConsumeUserGesture(WebLocalFrame*);
BLINK_EXPORT static bool ConsumeUserGesture(
WebLocalFrame*,
UserActivationUpdateSource update_source =
UserActivationUpdateSource::kRenderer);
// Returns true if a user gesture was processed on the provided frame since
// the time the frame was loaded.
......
......@@ -51,9 +51,12 @@ bool WebUserGestureIndicator::IsProcessingUserGestureThreadSafe(
// TODO(csharrison): consumeUserGesture() and currentUserGestureToken() use
// the thread-safe API, which many callers probably do not need. Consider
// updating them if they are in any sort of critical path or called often.
bool WebUserGestureIndicator::ConsumeUserGesture(WebLocalFrame* frame) {
bool WebUserGestureIndicator::ConsumeUserGesture(
WebLocalFrame* frame,
UserActivationUpdateSource update_source) {
return Frame::ConsumeTransientUserActivation(
frame ? ToWebLocalFrameImpl(frame)->GetFrame() : nullptr, true);
frame ? ToWebLocalFrameImpl(frame)->GetFrame() : nullptr, true,
update_source);
;
}
......
......@@ -197,8 +197,10 @@ bool Frame::ConsumeTransientUserActivationInLocalTree() {
return was_active;
}
bool Frame::ConsumeTransientUserActivation() {
ToLocalFrame(this)->Client()->ConsumeUserActivation();
bool Frame::ConsumeTransientUserActivation(
UserActivationUpdateSource update_source) {
if (update_source == UserActivationUpdateSource::kRenderer)
ToLocalFrame(this)->Client()->ConsumeUserActivation();
return ConsumeTransientUserActivationInLocalTree();
}
......@@ -233,10 +235,12 @@ bool Frame::HasTransientUserActivation(LocalFrame* frame,
}
// static
bool Frame::ConsumeTransientUserActivation(LocalFrame* frame,
bool checkIfMainThread) {
bool Frame::ConsumeTransientUserActivation(
LocalFrame* frame,
bool checkIfMainThread,
UserActivationUpdateSource update_source) {
if (RuntimeEnabledFeatures::UserActivationV2Enabled()) {
return frame ? frame->ConsumeTransientUserActivation() : false;
return frame ? frame->ConsumeTransientUserActivation(update_source) : false;
}
return checkIfMainThread
......
......@@ -34,6 +34,7 @@
#include "base/unguessable_token.h"
#include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/common/frame/user_activation_state.h"
#include "third_party/blink/public/common/frame/user_activation_update_source.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/user_gesture_indicator.h"
#include "third_party/blink/renderer/core/frame/frame_lifecycle.h"
......@@ -212,8 +213,11 @@ class CORE_EXPORT Frame : public GarbageCollectedFinalized<Frame> {
//
// The |checkIfMainThread| parameter determines if the token based gestures
// (legacy code) must be used in a thread-safe manner.
static bool ConsumeTransientUserActivation(LocalFrame*,
bool checkIfMainThread = false);
static bool ConsumeTransientUserActivation(
LocalFrame*,
bool checkIfMainThread = false,
UserActivationUpdateSource update_source =
UserActivationUpdateSource::kRenderer);
bool IsAttached() const {
return lifecycle_.GetState() == FrameLifecycle::kAttached;
......@@ -285,7 +289,7 @@ class CORE_EXPORT Frame : public GarbageCollectedFinalized<Frame> {
// Consumes and returns the transient user activation of current Frame, after
// updating all ancestor/descendant frames.
bool ConsumeTransientUserActivation();
bool ConsumeTransientUserActivation(UserActivationUpdateSource update_source);
Member<FrameClient> client_;
const Member<WindowProxyManager> window_proxy_manager_;
......
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