Commit f59e6c6a authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Autoplay] Expose was activated to embedders

Adds a WasActivatedOption to allow embedders to override the
`was_activated` logic for browser initiated navigations.

This is for when a user activation occurs on a surface outside
of the page and we want this to be passed to a navigation as if
this had occured on a previous page.

BUG=884777

Change-Id: Ifc7ce9352c3736d9e5c5c7d6909b3c5b2ead0cd8
Reviewed-on: https://chromium-review.googlesource.com/1228502Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarGreg Kerr <kerrnel@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593614}
parent 3c2d9527
...@@ -234,6 +234,25 @@ IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, ...@@ -234,6 +234,25 @@ IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
EXPECT_TRUE(AttemptPlay(GetWebContents())); EXPECT_TRUE(AttemptPlay(GetWebContents()));
} }
IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, ForceWasActivated_Default) {
const GURL kTestPageUrl = embedded_test_server()->GetURL(kTestPagePath);
NavigateParams params(browser(), kTestPageUrl, ui::PAGE_TRANSITION_LINK);
ui_test_utils::NavigateToURL(&params);
EXPECT_FALSE(AttemptPlay(GetWebContents()));
}
IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, ForceWasActivated_Yes) {
const GURL kTestPageUrl = embedded_test_server()->GetURL(kTestPagePath);
NavigateParams params(browser(), kTestPageUrl, ui::PAGE_TRANSITION_LINK);
params.was_activated = content::WasActivatedOption::kYes;
ui_test_utils::NavigateToURL(&params);
EXPECT_TRUE(AttemptPlay(GetWebContents()));
}
// Integration tests for the new unified autoplay sound settings UI. // Integration tests for the new unified autoplay sound settings UI.
class UnifiedAutoplaySettingBrowserTest : public UnifiedAutoplayBrowserTest { class UnifiedAutoplaySettingBrowserTest : public UnifiedAutoplayBrowserTest {
......
...@@ -326,6 +326,7 @@ void LoadURLInContents(WebContents* target_contents, ...@@ -326,6 +326,7 @@ void LoadURLInContents(WebContents* target_contents,
load_url_params.has_user_gesture = params->user_gesture; load_url_params.has_user_gesture = params->user_gesture;
load_url_params.blob_url_loader_factory = params->blob_url_loader_factory; load_url_params.blob_url_loader_factory = params->blob_url_loader_factory;
load_url_params.input_start = params->input_start; load_url_params.input_start = params->input_start;
load_url_params.was_activated = params->was_activated;
// |frame_tree_node_id| is kNoFrameTreeNodeId for main frame navigations. // |frame_tree_node_id| is kNoFrameTreeNodeId for main frame navigations.
if (params->frame_tree_node_id == if (params->frame_tree_node_id ==
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/site_instance.h" #include "content/public/browser/site_instance.h"
#include "content/public/common/referrer.h" #include "content/public/common/referrer.h"
#include "content/public/common/was_activated_option.h"
#include "services/network/public/cpp/resource_request_body.h" #include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
...@@ -258,6 +259,14 @@ struct NavigateParams { ...@@ -258,6 +259,14 @@ struct NavigateParams {
// desktop omnibox. // desktop omnibox.
base::TimeTicks input_start; base::TimeTicks input_start;
// Indicates that the new page should have a propagated user activation.
// This should be used when we want to pass an activation that occurred
// outside of the page and pass it to the page as if it happened on a prior
// page. For example, if the assistant opens a page we should treat the
// user's interaction with the assistant as a previous user activation.
content::WasActivatedOption was_activated =
content::WasActivatedOption::kUnknown;
private: private:
NavigateParams(); NavigateParams();
DISALLOW_COPY_AND_ASSIGN(NavigateParams); DISALLOW_COPY_AND_ASSIGN(NavigateParams);
......
...@@ -1849,7 +1849,7 @@ bool NavigationControllerImpl::StartHistoryNavigationInNewSubframe( ...@@ -1849,7 +1849,7 @@ bool NavigationControllerImpl::StartHistoryNavigationInNewSubframe(
render_frame_host->frame_tree_node(), *entry, frame_entry, render_frame_host->frame_tree_node(), *entry, frame_entry,
ReloadType::NONE, false /* is_same_document_history_load */, ReloadType::NONE, false /* is_same_document_history_load */,
true /* is_history_navigation_in_new_child */, nullptr, nullptr, true /* is_history_navigation_in_new_child */, nullptr, nullptr,
base::TimeTicks() /* input_start */); base::TimeTicks() /* input_start */, WasActivatedOption::kUnknown);
if (!request) if (!request)
return false; return false;
...@@ -1940,7 +1940,7 @@ void NavigationControllerImpl::NavigateFromFrameProxy( ...@@ -1940,7 +1940,7 @@ void NavigationControllerImpl::NavigateFromFrameProxy(
render_frame_host->frame_tree_node(), *entry, frame_entry.get(), render_frame_host->frame_tree_node(), *entry, frame_entry.get(),
ReloadType::NONE, false /* is_same_document_history_load */, ReloadType::NONE, false /* is_same_document_history_load */,
false /* is_history_navigation_in_new_child */, post_body, nullptr, false /* is_history_navigation_in_new_child */, post_body, nullptr,
base::TimeTicks() /* input_start */); base::TimeTicks() /* input_start */, WasActivatedOption::kUnknown);
if (!request) if (!request)
return; return;
...@@ -2198,7 +2198,7 @@ void NavigationControllerImpl::NavigateToExistingPendingEntry( ...@@ -2198,7 +2198,7 @@ void NavigationControllerImpl::NavigateToExistingPendingEntry(
root, *pending_entry_, pending_entry_->GetFrameEntry(root), root, *pending_entry_, pending_entry_->GetFrameEntry(root),
reload_type, false /* is_same_document_history_load */, reload_type, false /* is_same_document_history_load */,
false /* is_history_navigation_in_new_child */, nullptr, nullptr, false /* is_history_navigation_in_new_child */, nullptr, nullptr,
base::TimeTicks() /* input_start */); base::TimeTicks() /* input_start */, WasActivatedOption::kUnknown);
if (!navigation_request) { if (!navigation_request) {
// This navigation cannot start (e.g. the URL is invalid), delete the // This navigation cannot start (e.g. the URL is invalid), delete the
// pending NavigationEntry. // pending NavigationEntry.
...@@ -2275,7 +2275,8 @@ void NavigationControllerImpl::FindFramesToNavigate( ...@@ -2275,7 +2275,8 @@ void NavigationControllerImpl::FindFramesToNavigate(
frame, *pending_entry_, new_item, reload_type, frame, *pending_entry_, new_item, reload_type,
true /* is_same_document_history_load */, true /* is_same_document_history_load */,
false /* is_history_navigation_in_new_child */, nullptr, nullptr, false /* is_history_navigation_in_new_child */, nullptr, nullptr,
base::TimeTicks() /* input_start */); base::TimeTicks() /* input_start */,
WasActivatedOption::kUnknown);
if (navigation_request) { if (navigation_request) {
// Only add the request if was properly created. It's possible for the // Only add the request if was properly created. It's possible for the
// creation to fail in certain cases, e.g. when the URL is invalid. // creation to fail in certain cases, e.g. when the URL is invalid.
...@@ -2302,7 +2303,8 @@ void NavigationControllerImpl::FindFramesToNavigate( ...@@ -2302,7 +2303,8 @@ void NavigationControllerImpl::FindFramesToNavigate(
frame, *pending_entry_, new_item, reload_type, frame, *pending_entry_, new_item, reload_type,
false /* is_same_document_history_load */, false /* is_same_document_history_load */,
false /* is_history_navigation_in_new_child */, nullptr, nullptr, false /* is_history_navigation_in_new_child */, nullptr, nullptr,
base::TimeTicks() /* input_start */); base::TimeTicks() /* input_start */,
WasActivatedOption::kUnknown);
if (navigation_request) { if (navigation_request) {
// Only add the request if was properly created. It's possible for the // Only add the request if was properly created. It's possible for the
// creation to fail in certain cases, e.g. when the URL is invalid. // creation to fail in certain cases, e.g. when the URL is invalid.
...@@ -2387,7 +2389,7 @@ void NavigationControllerImpl::NavigateWithoutEntry( ...@@ -2387,7 +2389,7 @@ void NavigationControllerImpl::NavigateWithoutEntry(
false /* is_same_document_history_load */, false /* is_same_document_history_load */,
false /* is_history_navigation_in_new_child */, nullptr, false /* is_history_navigation_in_new_child */, nullptr,
params.navigation_ui_data ? params.navigation_ui_data->Clone() : nullptr, params.navigation_ui_data ? params.navigation_ui_data->Clone() : nullptr,
params.input_start); params.input_start, params.was_activated);
// If the navigation couldn't start, return immediately and discard the // If the navigation couldn't start, return immediately and discard the
// pending NavigationEntry. // pending NavigationEntry.
...@@ -2550,7 +2552,8 @@ NavigationControllerImpl::CreateNavigationRequest( ...@@ -2550,7 +2552,8 @@ NavigationControllerImpl::CreateNavigationRequest(
bool is_history_navigation_in_new_child, bool is_history_navigation_in_new_child,
const scoped_refptr<network::ResourceRequestBody>& post_body, const scoped_refptr<network::ResourceRequestBody>& post_body,
std::unique_ptr<NavigationUIData> navigation_ui_data, std::unique_ptr<NavigationUIData> navigation_ui_data,
base::TimeTicks input_start) { base::TimeTicks input_start,
WasActivatedOption was_activated) {
GURL dest_url = frame_entry->url(); GURL dest_url = frame_entry->url();
Referrer dest_referrer = frame_entry->referrer(); Referrer dest_referrer = frame_entry->referrer();
if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && if (reload_type == ReloadType::ORIGINAL_REQUEST_URL &&
...@@ -2623,7 +2626,7 @@ NavigationControllerImpl::CreateNavigationRequest( ...@@ -2623,7 +2626,7 @@ NavigationControllerImpl::CreateNavigationRequest(
frame_tree_node, dest_url, dest_referrer, *frame_entry, entry, frame_tree_node, dest_url, dest_referrer, *frame_entry, entry,
navigation_type, previews_state, is_same_document_history_load, navigation_type, previews_state, is_same_document_history_load,
is_history_navigation_in_new_child, post_body, navigation_start, this, is_history_navigation_in_new_child, post_body, navigation_start, this,
std::move(navigation_ui_data), input_start); std::move(navigation_ui_data), input_start, was_activated);
} }
void NavigationControllerImpl::NotifyNavigationEntryCommitted( void NavigationControllerImpl::NotifyNavigationEntryCommitted(
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
struct FrameHostMsg_DidCommitProvisionalLoad_Params; struct FrameHostMsg_DidCommitProvisionalLoad_Params;
namespace content { namespace content {
enum class WasActivatedOption;
class FrameTreeNode; class FrameTreeNode;
class RenderFrameHostImpl; class RenderFrameHostImpl;
class NavigationEntryScreenshotManager; class NavigationEntryScreenshotManager;
...@@ -294,7 +295,8 @@ class CONTENT_EXPORT NavigationControllerImpl : public NavigationController { ...@@ -294,7 +295,8 @@ class CONTENT_EXPORT NavigationControllerImpl : public NavigationController {
bool is_history_navigation_in_new_child, bool is_history_navigation_in_new_child,
const scoped_refptr<network::ResourceRequestBody>& post_body, const scoped_refptr<network::ResourceRequestBody>& post_body,
std::unique_ptr<NavigationUIData> navigation_ui_data, std::unique_ptr<NavigationUIData> navigation_ui_data,
base::TimeTicks input_start); base::TimeTicks input_start,
WasActivatedOption was_activated);
// Returns whether there is a pending NavigationEntry whose unique ID matches // Returns whether there is a pending NavigationEntry whose unique ID matches
// the given NavigationHandle's pending_nav_entry_id. // the given NavigationHandle's pending_nav_entry_id.
......
...@@ -293,7 +293,8 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( ...@@ -293,7 +293,8 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
base::TimeTicks navigation_start, base::TimeTicks navigation_start,
NavigationControllerImpl* controller, NavigationControllerImpl* controller,
std::unique_ptr<NavigationUIData> navigation_ui_data, std::unique_ptr<NavigationUIData> navigation_ui_data,
base::TimeTicks input_start) { base::TimeTicks input_start,
WasActivatedOption was_activated) {
// A form submission happens either because the navigation is a // A form submission happens either because the navigation is a
// renderer-initiated form submission that took the OpenURL path or a // renderer-initiated form submission that took the OpenURL path or a
// back/forward/reload navigation the does a form resubmission. // back/forward/reload navigation the does a form resubmission.
...@@ -338,6 +339,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( ...@@ -338,6 +339,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
controller->GetLastCommittedEntryIndex(), controller->GetLastCommittedEntryIndex(),
controller->GetEntryCount()); controller->GetEntryCount());
request_params.post_content_type = post_content_type; request_params.post_content_type = post_content_type;
request_params.was_activated = was_activated;
std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
frame_tree_node, common_params, frame_tree_node, common_params,
...@@ -990,23 +992,27 @@ void NavigationRequest::OnResponseStarted( ...@@ -990,23 +992,27 @@ void NavigationRequest::OnResponseStarted(
// context menu. This should apply to pages that open in a new tab and we // context menu. This should apply to pages that open in a new tab and we
// have to follow the referrer. It means that the activation might not be // have to follow the referrer. It means that the activation might not be
// transmitted if it should have. // transmitted if it should have.
request_params_.was_activated = false; if (request_params_.was_activated == WasActivatedOption::kUnknown) {
if (navigation_handle_->IsRendererInitiated() && request_params_.was_activated = WasActivatedOption::kNo;
frame_tree_node_->has_received_user_gesture() &&
ShouldPropagateUserActivation( if (navigation_handle_->IsRendererInitiated() &&
frame_tree_node_->current_origin(), frame_tree_node_->has_received_user_gesture() &&
url::Origin::Create(navigation_handle_->GetURL()))) { ShouldPropagateUserActivation(
request_params_.was_activated = true; frame_tree_node_->current_origin(),
// TODO(805871): the next check is relying on url::Origin::Create(navigation_handle_->GetURL()))) {
// navigation_handle_->GetReferrer() but should ideally use a more reliable request_params_.was_activated = WasActivatedOption::kYes;
// source for the originating URL when the navigation is renderer initiated. // TODO(805871): the next check is relying on
} else if (((navigation_handle_->HasUserGesture() && // navigation_handle_->GetReferrer() but should ideally use a more
navigation_handle_->IsRendererInitiated()) || // reliable source for the originating URL when the navigation is renderer
navigation_handle_->WasStartedFromContextMenu()) && // initiated.
ShouldPropagateUserActivation( } else if (((navigation_handle_->HasUserGesture() &&
url::Origin::Create(navigation_handle_->GetReferrer().url), navigation_handle_->IsRendererInitiated()) ||
url::Origin::Create(navigation_handle_->GetURL()))) { navigation_handle_->WasStartedFromContextMenu()) &&
request_params_.was_activated = true; ShouldPropagateUserActivation(
url::Origin::Create(navigation_handle_->GetReferrer().url),
url::Origin::Create(navigation_handle_->GetURL()))) {
request_params_.was_activated = WasActivatedOption::kYes;
}
} }
// Update the previews state of the request. // Update the previews state of the request.
......
...@@ -94,7 +94,8 @@ class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate { ...@@ -94,7 +94,8 @@ class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate {
base::TimeTicks navigation_start, base::TimeTicks navigation_start,
NavigationControllerImpl* controller, NavigationControllerImpl* controller,
std::unique_ptr<NavigationUIData> navigation_ui_data, std::unique_ptr<NavigationUIData> navigation_ui_data,
base::TimeTicks input_start); base::TimeTicks input_start,
WasActivatedOption was_activated);
// Creates a request for a renderer-intiated navigation. // Creates a request for a renderer-intiated navigation.
// Note: |body| is sent to the IO thread when calling BeginNavigation, and // Note: |body| is sent to the IO thread when calling BeginNavigation, and
......
...@@ -450,7 +450,8 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness { ...@@ -450,7 +450,8 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
manager->frame_tree_node_, frame_entry->url(), manager->frame_tree_node_, frame_entry->url(),
frame_entry->referrer(), *frame_entry, entry, navigate_type, frame_entry->referrer(), *frame_entry, entry, navigate_type,
PREVIEWS_UNSPECIFIED, false, false, nullptr, base::TimeTicks::Now(), PREVIEWS_UNSPECIFIED, false, false, nullptr, base::TimeTicks::Now(),
controller, nullptr, base::TimeTicks()); controller, nullptr, base::TimeTicks(),
WasActivatedOption::kUnknown);
// Simulates request creation that triggers the 1st internal call to // Simulates request creation that triggers the 1st internal call to
// GetFrameHostForNavigation. // GetFrameHostForNavigation.
...@@ -2824,7 +2825,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation, ...@@ -2824,7 +2825,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation,
FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED, FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
false, false, nullptr, base::TimeTicks::Now(), false, false, nullptr, base::TimeTicks::Now(),
static_cast<NavigationControllerImpl*>(&controller()), nullptr, static_cast<NavigationControllerImpl*>(&controller()), nullptr,
base::TimeTicks()); base::TimeTicks(), WasActivatedOption::kUnknown);
manager->DidCreateNavigationRequest(navigation_request.get()); manager->DidCreateNavigationRequest(navigation_request.get());
// As the initial RenderFrame was not live, the new RenderFrameHost should be // As the initial RenderFrame was not live, the new RenderFrameHost should be
...@@ -2887,7 +2888,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation, ...@@ -2887,7 +2888,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation,
FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED, FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
false, false, nullptr, base::TimeTicks::Now(), false, false, nullptr, base::TimeTicks::Now(),
static_cast<NavigationControllerImpl*>(&controller()), nullptr, static_cast<NavigationControllerImpl*>(&controller()), nullptr,
base::TimeTicks()); base::TimeTicks(), WasActivatedOption::kUnknown);
manager->DidCreateNavigationRequest(navigation_request.get()); manager->DidCreateNavigationRequest(navigation_request.get());
// The current WebUI should still be in place and the pending WebUI should be // The current WebUI should still be in place and the pending WebUI should be
...@@ -2947,7 +2948,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation, ...@@ -2947,7 +2948,7 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation,
FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED, FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
false, false, nullptr, base::TimeTicks::Now(), false, false, nullptr, base::TimeTicks::Now(),
static_cast<NavigationControllerImpl*>(&controller()), nullptr, static_cast<NavigationControllerImpl*>(&controller()), nullptr,
base::TimeTicks()); base::TimeTicks(), WasActivatedOption::kUnknown);
manager->DidCreateNavigationRequest(navigation_request.get()); manager->DidCreateNavigationRequest(navigation_request.get());
// The current WebUI should still be in place and there should be a new // The current WebUI should still be in place and there should be a new
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "content/public/common/screen_info.h" #include "content/public/common/screen_info.h"
#include "content/public/common/stop_find_action.h" #include "content/public/common/stop_find_action.h"
#include "content/public/common/three_d_api_types.h" #include "content/public/common/three_d_api_types.h"
#include "content/public/common/was_activated_option.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
...@@ -142,6 +143,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::UserActivationUpdateType, ...@@ -142,6 +143,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::UserActivationUpdateType,
blink::UserActivationUpdateType::kMaxValue) blink::UserActivationUpdateType::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebMediaPlayerAction::Type, IPC_ENUM_TRAITS_MAX_VALUE(blink::WebMediaPlayerAction::Type,
blink::WebMediaPlayerAction::Type::kTypeLast) blink::WebMediaPlayerAction::Type::kTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(content::WasActivatedOption,
content::WasActivatedOption::kMaxValue)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScrollDirection, IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScrollDirection,
blink::kFirstScrollDirection, blink::kFirstScrollDirection,
blink::kLastScrollDirection) blink::kLastScrollDirection)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "content/public/common/page_state.h" #include "content/public/common/page_state.h"
#include "content/public/common/previews_state.h" #include "content/public/common/previews_state.h"
#include "content/public/common/referrer.h" #include "content/public/common/referrer.h"
#include "content/public/common/was_activated_option.h"
#include "net/url_request/redirect_info.h" #include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/resource_request_body.h" #include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/cpp/resource_response.h" #include "services/network/public/cpp/resource_response.h"
...@@ -300,15 +301,15 @@ struct CONTENT_EXPORT RequestNavigationParams { ...@@ -300,15 +301,15 @@ struct CONTENT_EXPORT RequestNavigationParams {
// The AppCache host id to be used to identify this navigation. // The AppCache host id to be used to identify this navigation.
int appcache_host_id = kAppCacheNoHostId; int appcache_host_id = kAppCacheNoHostId;
// True if a navigation is following the rules of user activation propagation. // Set to |kYes| if a navigation is following the rules of user activation
// This is different from |has_user_gesture| (in CommonNavigationParams) as // propagation. This is different from |has_user_gesture|
// the activation may have happened before the navigation was triggered, for // (in CommonNavigationParams) as the activation may have happened before
// example. // the navigation was triggered, for example.
// In other words, the distinction isn't regarding user activation and user // In other words, the distinction isn't regarding user activation and user
// gesture but whether there was an activation prior to the navigation or to // gesture but whether there was an activation prior to the navigation or to
// start it. `was_activated` will answer the former question while // start it. `was_activated` will answer the former question while
// `user_gesture` will answer the latter. // `user_gesture` will answer the latter.
bool was_activated = false; WasActivatedOption was_activated = WasActivatedOption::kUnknown;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// The real content of the data: URL. Only used in Android WebView for // The real content of the data: URL. Only used in Android WebView for
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/common/was_activated_option.h"
namespace content { namespace content {
...@@ -23,8 +24,8 @@ NavigationController::LoadURLParams::LoadURLParams(const GURL& url) ...@@ -23,8 +24,8 @@ NavigationController::LoadURLParams::LoadURLParams(const GURL& url)
has_user_gesture(false), has_user_gesture(false),
should_clear_history_list(false), should_clear_history_list(false),
started_from_context_menu(false), started_from_context_menu(false),
navigation_ui_data(nullptr) { navigation_ui_data(nullptr),
} was_activated(WasActivatedOption::kUnknown) {}
NavigationController::LoadURLParams::~LoadURLParams() { NavigationController::LoadURLParams::~LoadURLParams() {
} }
......
...@@ -36,6 +36,7 @@ class RefCountedString; ...@@ -36,6 +36,7 @@ class RefCountedString;
namespace content { namespace content {
enum class WasActivatedOption;
class BrowserContext; class BrowserContext;
class NavigationEntry; class NavigationEntry;
class WebContents; class WebContents;
...@@ -202,6 +203,10 @@ class NavigationController { ...@@ -202,6 +203,10 @@ class NavigationController {
// it for navigations it initiates. // it for navigations it initiates.
base::TimeTicks input_start; base::TimeTicks input_start;
// Set to |kYes| if the navigation should propagate user activation. This
// is used by embedders where the activation has occurred outside the page.
WasActivatedOption was_activated;
explicit LoadURLParams(const GURL& url); explicit LoadURLParams(const GURL& url);
~LoadURLParams(); ~LoadURLParams();
......
...@@ -216,6 +216,7 @@ jumbo_source_set("common_sources") { ...@@ -216,6 +216,7 @@ jumbo_source_set("common_sources") {
"use_zoom_for_dsf_policy.cc", "use_zoom_for_dsf_policy.cc",
"use_zoom_for_dsf_policy.h", "use_zoom_for_dsf_policy.h",
"user_agent.h", "user_agent.h",
"was_activated_option.h",
"web_preferences.cc", "web_preferences.cc",
"web_preferences.h", "web_preferences.h",
"webplugininfo.cc", "webplugininfo.cc",
......
// 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 CONTENT_PUBLIC_COMMON_WAS_ACTIVATED_OPTION_H_
#define CONTENT_PUBLIC_COMMON_WAS_ACTIVATED_OPTION_H_
namespace content {
// Whether the navigation should propagate user activation. This can be
// specified by embedders in NavigationController::LoadURLParams.
enum class WasActivatedOption {
// The content layer should make a decision about whether to propagate user
// activation.
kUnknown,
// The navigation should propagate user activation.
kYes,
// The navigation should not propagate user activation.
kNo,
kMaxValue = kNo,
};
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_WAS_ACTIVATED_OPTION_H_
...@@ -964,7 +964,8 @@ std::unique_ptr<blink::WebNavigationParams> BuildNavigationParams( ...@@ -964,7 +964,8 @@ std::unique_ptr<blink::WebNavigationParams> BuildNavigationParams(
common_params.source_location->column_number; common_params.source_location->column_number;
} }
navigation_params->is_user_activated = request_params.was_activated; navigation_params->is_user_activated =
request_params.was_activated == WasActivatedOption::kYes;
navigation_params->service_worker_network_provider = navigation_params->service_worker_network_provider =
std::move(service_worker_network_provider); std::move(service_worker_network_provider);
return navigation_params; return navigation_params;
......
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