Commit 6ab4b359 authored by Kouhei Ueno's avatar Kouhei Ueno Committed by Commit Bot

NavigationHandle: Mark if target is a signed exchange

This CL prepares for measuring PageLoadMetrics for pages loaded through
SignedExchange.

This CL adds |NavigationHandle::IsSignedExchangeInnerResponse()| getter,
which can be used to distinguish signed exchange navigations.
The getter will be used in the following CL to selectively enable
the signed exchange page load metrics observer for recording drill-down
UMAs.

Bug: 863305
Change-Id: Ia3bad8d6c9daeef237879538fb8999b7f3df4a46
Reviewed-on: https://chromium-review.googlesource.com/1212375Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589493}
parent aec50d02
......@@ -220,6 +220,7 @@ NavigationHandleImpl::NavigationHandleImpl(
should_replace_current_entry_(false),
is_download_(false),
is_stream_(false),
is_signed_exchange_inner_response_(false),
started_from_context_menu_(started_from_context_menu),
is_same_process_(true),
weak_factory_(this) {
......@@ -545,7 +546,10 @@ NavigationHandleImpl::CallWillProcessResponseForTesting(
WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host),
headers, net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN,
net::HostPortPair(), net::SSLInfo(), GlobalRequestID(),
false, false, false,
/* should_replace_current_entry=*/false,
/* is_download=*/false,
/* is_stream=*/false,
/* is_signed_exchange_inner_response=*/false,
base::Bind(&UpdateThrottleCheckResult, &result));
// Reset the callback to ensure it will not be called later.
......@@ -632,6 +636,10 @@ bool NavigationHandleImpl::IsFormSubmission() {
return is_form_submission_;
}
bool NavigationHandleImpl::IsSignedExchangeInnerResponse() {
return is_signed_exchange_inner_response_;
}
void NavigationHandleImpl::InitServiceWorkerHandle(
ServiceWorkerContextWrapper* service_worker_context) {
service_worker_handle_.reset(
......@@ -793,6 +801,7 @@ void NavigationHandleImpl::WillProcessResponse(
bool should_replace_current_entry,
bool is_download,
bool is_stream,
bool is_signed_exchange_inner_response,
const ThrottleChecksFinishedCallback& callback) {
TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
"WillProcessResponse");
......@@ -805,6 +814,7 @@ void NavigationHandleImpl::WillProcessResponse(
should_replace_current_entry_ = should_replace_current_entry;
is_download_ = is_download;
is_stream_ = is_stream;
is_signed_exchange_inner_response_ = is_signed_exchange_inner_response;
state_ = WILL_PROCESS_RESPONSE;
ssl_info_ = ssl_info;
socket_address_ = socket_address;
......
......@@ -164,6 +164,9 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
bool IsDownload() override;
bool IsFormSubmission() override;
// TODO(kouhei): Add public interface in NavigationHandle.
bool IsSignedExchangeInnerResponse();
const std::string& origin_policy() const { return origin_policy_; }
void set_origin_policy(const std::string& origin_policy) {
origin_policy_ = origin_policy;
......@@ -305,6 +308,7 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
bool should_replace_current_entry,
bool is_download,
bool is_stream,
bool is_signed_exchange_inner_response,
const ThrottleChecksFinishedCallback& callback);
// Returns the FrameTreeNode this navigation is happening in.
......@@ -606,6 +610,9 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
bool is_download_;
bool is_stream_;
// True if the target is an inner response of a signed exchange.
bool is_signed_exchange_inner_response_;
// False by default unless the navigation started within a context menu.
bool started_from_context_menu_;
......
......@@ -167,7 +167,7 @@ class NavigationHandleImplTest : public RenderViewHostImplTestHarness {
test_handle_->WillProcessResponse(
main_test_rfh(), scoped_refptr<net::HttpResponseHeaders>(),
net::HttpResponseInfo::CONNECTION_INFO_QUIC_35, net::HostPortPair(),
net::SSLInfo(), GlobalRequestID(), false, false, false,
net::SSLInfo(), GlobalRequestID(), false, false, false, false,
base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult,
base::Unretained(this)));
}
......
......@@ -1108,7 +1108,7 @@ void NavigationRequest::OnResponseStarted(
render_frame_host, response->head.headers.get(),
response->head.connection_info, response->head.socket_address, ssl_info_,
request_id, common_params_.should_replace_current_entry, is_download,
is_stream,
is_stream, response->head.is_signed_exchange_inner_response,
base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete,
base::Unretained(this)));
}
......
......@@ -9,6 +9,7 @@
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/web_package/signed_exchange_handler.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
......@@ -64,6 +65,20 @@ class RedirectObserver : public WebContentsObserver {
DISALLOW_COPY_AND_ASSIGN(RedirectObserver);
};
class AssertNavigationHandleFlagObserver : public WebContentsObserver {
public:
explicit AssertNavigationHandleFlagObserver(WebContents* web_contents)
: WebContentsObserver(web_contents) {}
~AssertNavigationHandleFlagObserver() override = default;
void DidFinishNavigation(NavigationHandle* handle) override {
EXPECT_TRUE(static_cast<NavigationHandleImpl*>(handle)->IsSignedExchangeInnerResponse());
}
private:
DISALLOW_COPY_AND_ASSIGN(AssertNavigationHandleFlagObserver);
};
} // namespace
class SignedExchangeRequestHandlerBrowserTest : public CertVerifierBrowserTest {
......@@ -178,6 +193,8 @@ IN_PROC_BROWSER_TEST_F(SignedExchangeRequestHandlerBrowserTest, Simple) {
base::string16 title = base::ASCIIToUTF16("https://test.example.org/test/");
TitleWatcher title_watcher(shell()->web_contents(), title);
RedirectObserver redirect_observer(shell()->web_contents());
AssertNavigationHandleFlagObserver assert_navigation_handle_flag_observer(
shell()->web_contents());
NavigateToURL(shell(), url);
EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
......
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