blob: 3d2ce662f613874290d3c24ea4a55bec075aca6e [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2014 The Chromium Authors
danakjc492bf82020-09-09 20:02:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_
6#define CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_
7
danakjc492bf82020-09-09 20:02:448#include "base/unguessable_token.h"
9#include "content/common/content_export.h"
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:3810#include "content/public/browser/global_routing_id.h"
Jeremy Roman04ad4e3f2021-12-22 18:54:5411#include "content/public/browser/weak_document_ptr.h"
danakjc492bf82020-09-09 20:02:4412#include "content/public/common/referrer.h"
13#include "net/base/isolation_info.h"
Hans Wennborg0d7c5ba2021-07-06 17:52:2014#include "net/filter/source_stream.h"
danakjc492bf82020-09-09 20:02:4415#include "net/http/http_request_headers.h"
16#include "services/network/public/cpp/shared_url_loader_factory.h"
Titouan Rigoudy97d9fd62020-09-28 16:16:4217#include "services/network/public/mojom/client_security_state.mojom-forward.h"
Lei Zhang698df03c2021-05-21 04:23:3418#include "third_party/abseil-cpp/absl/types/optional.h"
Minggang Wangb9f3fa92021-07-01 15:30:3119#include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h"
danakjc492bf82020-09-09 20:02:4420#include "url/gurl.h"
21#include "url/origin.h"
22
23namespace content {
24
25// A struct to hold the parameters needed to start a navigation request in
26// ResourceDispatcherHost. It is initialized on the UI thread, and then passed
27// to the IO thread by a NavigationRequest object.
28struct CONTENT_EXPORT NavigationRequestInfo {
Titouan Rigoudy97d9fd62020-09-28 16:16:4229 NavigationRequestInfo(
Minggang Wangb9f3fa92021-07-01 15:30:3130 blink::mojom::CommonNavigationParamsPtr common_params,
31 blink::mojom::BeginNavigationParamsPtr begin_params,
Arthur Sonzogni038f0de2021-10-07 13:51:3432 network::mojom::WebSandboxFlags sandbox_flags,
Titouan Rigoudy97d9fd62020-09-28 16:16:4233 const net::IsolationInfo& isolation_info,
Miyoung Shinff5aec92022-03-08 08:51:5034 bool is_primary_main_frame,
David Bokan98aabfe92022-04-14 02:10:1235 bool is_outermost_main_frame,
Titouan Rigoudy97d9fd62020-09-28 16:16:4236 bool is_main_frame,
Titouan Rigoudy97d9fd62020-09-28 16:16:4237 bool are_ancestors_secure,
38 int frame_tree_node_id,
Titouan Rigoudy97d9fd62020-09-28 16:16:4239 bool report_raw_headers,
Titouan Rigoudy97d9fd62020-09-28 16:16:4240 bool upgrade_if_insecure,
41 std::unique_ptr<network::PendingSharedURLLoaderFactory>
42 blob_url_loader_factory,
43 const base::UnguessableToken& devtools_navigation_token,
44 const base::UnguessableToken& devtools_frame_token,
Titouan Rigoudy97d9fd62020-09-28 16:16:4245 net::HttpRequestHeaders cors_exempt_headers,
Alex Rudenko0e632e472021-03-24 09:57:4046 network::mojom::ClientSecurityStatePtr client_security_state,
Anton Bikineevf62d1bf2021-05-15 17:56:0747 const absl::optional<std::vector<net::SourceStream::SourceType>>&
Daniel Hosseiniane58ff352021-10-01 05:13:4748 devtools_accepted_stream_types,
Jeremy Roman04ad4e3f2021-12-22 18:54:5449 bool is_pdf,
Igor Ruvinov0ea2ebb2022-12-01 16:33:0650 WeakDocumentPtr initiator_document,
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:3851 const GlobalRenderFrameHostId& previous_render_frame_host_id,
Igor Ruvinov0ea2ebb2022-12-01 16:33:0652 bool allow_cookies_from_browser);
danakjc492bf82020-09-09 20:02:4453 NavigationRequestInfo(const NavigationRequestInfo& other) = delete;
54 ~NavigationRequestInfo();
55
Minggang Wangb9f3fa92021-07-01 15:30:3156 blink::mojom::CommonNavigationParamsPtr common_params;
57 blink::mojom::BeginNavigationParamsPtr begin_params;
danakjc492bf82020-09-09 20:02:4458
Arthur Sonzogni038f0de2021-10-07 13:51:3459 // Sandbox flags inherited from the frame where this navigation occurs. In
60 // particular, this does not include:
61 // - Sandbox flags inherited from the creator via the PolicyContainer.
62 // - Sandbox flags forced for MHTML documents.
63 // - Sandbox flags from the future response via CSP.
64 // It is used by the ExternalProtocolHandler to ensure sandboxed iframe won't
65 // navigate the user toward a different application, which can be seen as a
66 // main frame navigation somehow.
67 const network::mojom::WebSandboxFlags sandbox_flags;
68
danakjc492bf82020-09-09 20:02:4469 // Contains information used to prevent sharing information from a navigation
70 // request across first party contexts. In particular, tracks the
71 // SiteForCookies, which controls what site's SameSite cookies may be set,
Brianna Goldsteind22b0642022-10-11 16:30:5072 // NetworkAnonymizationKey, which is used to restrict sharing of network
danakjc492bf82020-09-09 20:02:4473 // resources, and how to update them across redirects, which is different for
74 // main frames and subresources.
75 const net::IsolationInfo isolation_info;
76
David Bokan98aabfe92022-04-14 02:10:1277 // Whether this navigation is for the primary main frame of the web contents.
78 // That is, the one that the user can see and interact with (as opposed to,
79 // say, a prerendering main frame).
Miyoung Shinff5aec92022-03-08 08:51:5080 const bool is_primary_main_frame;
81
David Bokan98aabfe92022-04-14 02:10:1282 // Whether this navigation is for an outermost main frame. That is, a main
83 // frame that isn't embedded in another frame tree. A prerendering page will
84 // have an outermost main frame whereas a fenced frame will have an embedded
85 // main frame. A primary main frame is always outermost.
86 const bool is_outermost_main_frame;
87
88 // Whether this navigation is for a main frame; one that is the root of its
89 // own frame tree. This can include embedded frame trees such as Portals and
90 // FencedFrames. Both `is_primary_main_frame` and `is_outermost_main_frame`
91 // imply `is_main_frame`, however, `is_main_frame` does not imply either
92 // primary or outermost.
danakjc492bf82020-09-09 20:02:4493 const bool is_main_frame;
danakjc492bf82020-09-09 20:02:4494
95 // Whether all ancestor frames of the frame that is navigating have a secure
96 // origin. True for main frames.
97 const bool are_ancestors_secure;
98
99 const int frame_tree_node_id;
100
danakjc492bf82020-09-09 20:02:44101 const bool report_raw_headers;
102
danakjc492bf82020-09-09 20:02:44103 // If set to true, any HTTP redirects of this request will be upgraded to
104 // HTTPS. This only applies for subframe navigations.
105 const bool upgrade_if_insecure;
106
107 // URLLoaderFactory to facilitate loading blob URLs.
108 std::unique_ptr<network::PendingSharedURLLoaderFactory>
109 blob_url_loader_factory;
110
111 const base::UnguessableToken devtools_navigation_token;
112
113 const base::UnguessableToken devtools_frame_token;
114
danakjc492bf82020-09-09 20:02:44115 const net::HttpRequestHeaders cors_exempt_headers;
Titouan Rigoudy97d9fd62020-09-28 16:16:42116
117 // Specifies the security state applying to the navigation. For iframes, this
118 // is the security state of their parent. Nullptr otherwise.
Titouan Rigoudye10716b2020-09-29 13:29:55119 //
120 // TODO(https://crbug.com/1129326): Set this for top-level navigation requests
121 // too once the UX story is sorted out.
Titouan Rigoudy97d9fd62020-09-28 16:16:42122 const network::mojom::ClientSecurityStatePtr client_security_state;
Alex Rudenko0e632e472021-03-24 09:57:40123
124 // If not null, the network service will not advertise any stream types
125 // (via Accept-Encoding) that are not listed. Also, it will not attempt
126 // decoding any non-listed stream types.
Anton Bikineevf62d1bf2021-05-15 17:56:07127 absl::optional<std::vector<net::SourceStream::SourceType>>
Alex Rudenko0e632e472021-03-24 09:57:40128 devtools_accepted_stream_types;
Daniel Hosseiniane58ff352021-10-01 05:13:47129
130 // Indicates that this navigation is for PDF content in a renderer.
131 const bool is_pdf;
Jeremy Roman04ad4e3f2021-12-22 18:54:54132
133 // The initiator document, if still available.
134 const WeakDocumentPtr initiator_document;
Igor Ruvinov0ea2ebb2022-12-01 16:33:06135
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:38136 // The previous document's RenderFrameHostId, used for speculation rules
137 // prefetch.
138 // This corresponds to `NavigationRequest::GetPreviousRenderFrameHostId()`.
139 const GlobalRenderFrameHostId previous_render_frame_host_id;
140
Igor Ruvinov0ea2ebb2022-12-01 16:33:06141 // Whether a Cookie header added to this request should not be overwritten by
142 // the network service.
143 const bool allow_cookies_from_browser;
danakjc492bf82020-09-09 20:02:44144};
145
146} // namespace content
147
148#endif // CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_