Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 2 | // 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 | |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 8 | #include <optional> |
| 9 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 10 | #include "base/unguessable_token.h" |
| 11 | #include "content/common/content_export.h" |
Avi Drissman | bd15364 | 2024-09-03 18:58:05 | [diff] [blame] | 12 | #include "content/public/browser/frame_tree_node_id.h" |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame] | 13 | #include "content/public/browser/global_routing_id.h" |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 14 | #include "content/public/browser/weak_document_ptr.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 15 | #include "content/public/common/referrer.h" |
| 16 | #include "net/base/isolation_info.h" |
Tsuyoshi Horo | 17846bf | 2025-02-20 23:28:13 | [diff] [blame] | 17 | #include "net/filter/source_stream_type.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 18 | #include "net/http/http_request_headers.h" |
| 19 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 20 | #include "services/network/public/mojom/client_security_state.mojom-forward.h" |
Hiroshige Hayashizaki | 2df4529 | 2023-10-10 22:59:03 | [diff] [blame] | 21 | #include "third_party/blink/public/common/tokens/tokens.h" |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 22 | #include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 23 | #include "url/origin.h" |
| 24 | |
| 25 | namespace content { |
| 26 | |
Hiroshige Hayashizaki | 6a2bc75 | 2023-10-31 19:08:11 | [diff] [blame] | 27 | class PrefetchServingPageMetricsContainer; |
| 28 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 29 | // A struct to hold the parameters needed to start a navigation request in |
| 30 | // ResourceDispatcherHost. It is initialized on the UI thread, and then passed |
| 31 | // to the IO thread by a NavigationRequest object. |
| 32 | struct CONTENT_EXPORT NavigationRequestInfo { |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 33 | NavigationRequestInfo( |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 34 | blink::mojom::CommonNavigationParamsPtr common_params, |
| 35 | blink::mojom::BeginNavigationParamsPtr begin_params, |
Arthur Sonzogni | 038f0de | 2021-10-07 13:51:34 | [diff] [blame] | 36 | network::mojom::WebSandboxFlags sandbox_flags, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 37 | const net::IsolationInfo& isolation_info, |
Miyoung Shin | ff5aec9 | 2022-03-08 08:51:50 | [diff] [blame] | 38 | bool is_primary_main_frame, |
David Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 39 | bool is_outermost_main_frame, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 40 | bool is_main_frame, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 41 | bool are_ancestors_secure, |
Avi Drissman | bd15364 | 2024-09-03 18:58:05 | [diff] [blame] | 42 | FrameTreeNodeId frame_tree_node_id, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 43 | bool report_raw_headers, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 44 | bool upgrade_if_insecure, |
| 45 | std::unique_ptr<network::PendingSharedURLLoaderFactory> |
| 46 | blob_url_loader_factory, |
| 47 | const base::UnguessableToken& devtools_navigation_token, |
| 48 | const base::UnguessableToken& devtools_frame_token, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 49 | net::HttpRequestHeaders cors_exempt_headers, |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 50 | network::mojom::ClientSecurityStatePtr client_security_state, |
Tsuyoshi Horo | 17846bf | 2025-02-20 23:28:13 | [diff] [blame] | 51 | const std::optional<std::vector<net::SourceStreamType>>& |
Daniel Hosseinian | e58ff35 | 2021-10-01 05:13:47 | [diff] [blame] | 52 | devtools_accepted_stream_types, |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 53 | bool is_pdf, |
Hiroshige Hayashizaki | 2df4529 | 2023-10-10 22:59:03 | [diff] [blame] | 54 | int initiator_process_id, |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 55 | std::optional<blink::DocumentToken> initiator_document_token, |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame] | 56 | const GlobalRenderFrameHostId& previous_render_frame_host_id, |
Hiroshige Hayashizaki | 6a2bc75 | 2023-10-31 19:08:11 | [diff] [blame] | 57 | base::WeakPtr<PrefetchServingPageMetricsContainer> |
| 58 | prefetch_serving_page_metrics_container, |
Max Curran | 7c0fc83d | 2023-06-07 22:59:28 | [diff] [blame] | 59 | bool allow_cookies_from_browser, |
Camillia Smith Barnes | 6d2966c8 | 2023-08-23 21:16:18 | [diff] [blame] | 60 | int64_t navigation_id, |
John Delaney | 4cf7d6ea | 2023-11-09 17:29:56 | [diff] [blame] | 61 | bool shared_storage_writable, |
Mustafa Emre Acer | 1001b3d | 2024-07-09 23:10:43 | [diff] [blame] | 62 | bool is_ad_tagged, |
| 63 | bool force_no_https_upgrade); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 64 | NavigationRequestInfo(const NavigationRequestInfo& other) = delete; |
| 65 | ~NavigationRequestInfo(); |
| 66 | |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 67 | blink::mojom::CommonNavigationParamsPtr common_params; |
| 68 | blink::mojom::BeginNavigationParamsPtr begin_params; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 69 | |
Arthur Sonzogni | 038f0de | 2021-10-07 13:51:34 | [diff] [blame] | 70 | // Sandbox flags inherited from the frame where this navigation occurs. In |
| 71 | // particular, this does not include: |
| 72 | // - Sandbox flags inherited from the creator via the PolicyContainer. |
| 73 | // - Sandbox flags forced for MHTML documents. |
| 74 | // - Sandbox flags from the future response via CSP. |
| 75 | // It is used by the ExternalProtocolHandler to ensure sandboxed iframe won't |
| 76 | // navigate the user toward a different application, which can be seen as a |
| 77 | // main frame navigation somehow. |
| 78 | const network::mojom::WebSandboxFlags sandbox_flags; |
| 79 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 80 | // Contains information used to prevent sharing information from a navigation |
| 81 | // request across first party contexts. In particular, tracks the |
| 82 | // SiteForCookies, which controls what site's SameSite cookies may be set, |
Brianna Goldstein | d22b064 | 2022-10-11 16:30:50 | [diff] [blame] | 83 | // NetworkAnonymizationKey, which is used to restrict sharing of network |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 84 | // resources, and how to update them across redirects, which is different for |
| 85 | // main frames and subresources. |
| 86 | const net::IsolationInfo isolation_info; |
| 87 | |
David Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 88 | // Whether this navigation is for the primary main frame of the web contents. |
| 89 | // That is, the one that the user can see and interact with (as opposed to, |
| 90 | // say, a prerendering main frame). |
Miyoung Shin | ff5aec9 | 2022-03-08 08:51:50 | [diff] [blame] | 91 | const bool is_primary_main_frame; |
| 92 | |
David Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 93 | // Whether this navigation is for an outermost main frame. That is, a main |
| 94 | // frame that isn't embedded in another frame tree. A prerendering page will |
| 95 | // have an outermost main frame whereas a fenced frame will have an embedded |
| 96 | // main frame. A primary main frame is always outermost. |
| 97 | const bool is_outermost_main_frame; |
| 98 | |
| 99 | // Whether this navigation is for a main frame; one that is the root of its |
Adithya Srinivasan | 39c8191 | 2024-07-11 20:44:21 | [diff] [blame] | 100 | // own frame tree. This can include embedded frame trees such as FencedFrames. |
| 101 | // Both `is_primary_main_frame` and `is_outermost_main_frame` imply |
| 102 | // `is_main_frame`, however, `is_main_frame` does not imply either primary or |
| 103 | // outermost. |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 104 | const bool is_main_frame; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 105 | |
| 106 | // Whether all ancestor frames of the frame that is navigating have a secure |
| 107 | // origin. True for main frames. |
| 108 | const bool are_ancestors_secure; |
| 109 | |
Avi Drissman | bd15364 | 2024-09-03 18:58:05 | [diff] [blame] | 110 | const FrameTreeNodeId frame_tree_node_id; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 111 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 112 | const bool report_raw_headers; |
| 113 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 114 | // If set to true, any HTTP redirects of this request will be upgraded to |
| 115 | // HTTPS. This only applies for subframe navigations. |
| 116 | const bool upgrade_if_insecure; |
| 117 | |
| 118 | // URLLoaderFactory to facilitate loading blob URLs. |
| 119 | std::unique_ptr<network::PendingSharedURLLoaderFactory> |
| 120 | blob_url_loader_factory; |
| 121 | |
| 122 | const base::UnguessableToken devtools_navigation_token; |
| 123 | |
| 124 | const base::UnguessableToken devtools_frame_token; |
| 125 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 126 | const net::HttpRequestHeaders cors_exempt_headers; |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 127 | |
| 128 | // Specifies the security state applying to the navigation. For iframes, this |
| 129 | // is the security state of their parent. Nullptr otherwise. |
Titouan Rigoudy | e10716b | 2020-09-29 13:29:55 | [diff] [blame] | 130 | // |
Alison Gale | 47d1537d | 2024-04-19 21:31:46 | [diff] [blame] | 131 | // TODO(crbug.com/40149351): Set this for top-level navigation requests |
Titouan Rigoudy | e10716b | 2020-09-29 13:29:55 | [diff] [blame] | 132 | // too once the UX story is sorted out. |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 133 | const network::mojom::ClientSecurityStatePtr client_security_state; |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 134 | |
| 135 | // If not null, the network service will not advertise any stream types |
| 136 | // (via Accept-Encoding) that are not listed. Also, it will not attempt |
| 137 | // decoding any non-listed stream types. |
Tsuyoshi Horo | 17846bf | 2025-02-20 23:28:13 | [diff] [blame] | 138 | std::optional<std::vector<net::SourceStreamType>> |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 139 | devtools_accepted_stream_types; |
Daniel Hosseinian | e58ff35 | 2021-10-01 05:13:47 | [diff] [blame] | 140 | |
| 141 | // Indicates that this navigation is for PDF content in a renderer. |
| 142 | const bool is_pdf; |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 143 | |
Hiroshige Hayashizaki | 2df4529 | 2023-10-10 22:59:03 | [diff] [blame] | 144 | // The initiator document's token and its process ID. |
| 145 | const int initiator_process_id; |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 146 | const std::optional<blink::DocumentToken> initiator_document_token; |
Igor Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 147 | |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame] | 148 | // The previous document's RenderFrameHostId, used for speculation rules |
| 149 | // prefetch. |
| 150 | // This corresponds to `NavigationRequest::GetPreviousRenderFrameHostId()`. |
| 151 | const GlobalRenderFrameHostId previous_render_frame_host_id; |
| 152 | |
Hiroshige Hayashizaki | 6a2bc75 | 2023-10-31 19:08:11 | [diff] [blame] | 153 | // For per-navigation metrics of speculation rules prefetch. |
| 154 | base::WeakPtr<PrefetchServingPageMetricsContainer> |
| 155 | prefetch_serving_page_metrics_container; |
| 156 | |
Igor Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 157 | // Whether a Cookie header added to this request should not be overwritten by |
| 158 | // the network service. |
| 159 | const bool allow_cookies_from_browser; |
Max Curran | 7c0fc83d | 2023-06-07 22:59:28 | [diff] [blame] | 160 | |
| 161 | // Unique id that identifies the navigation. |
| 162 | const int64_t navigation_id; |
Camillia Smith Barnes | 6d2966c8 | 2023-08-23 21:16:18 | [diff] [blame] | 163 | |
| 164 | // Whether or not the request is eligible to write to shared storage from |
| 165 | // response headers. See |
| 166 | // https://github.com/WICG/shared-storage#from-response-headers. |
Camillia Smith Barnes | 3cad1ba | 2023-10-30 20:10:16 | [diff] [blame] | 167 | bool shared_storage_writable_eligible; |
John Delaney | 4cf7d6ea | 2023-11-09 17:29:56 | [diff] [blame] | 168 | |
| 169 | // Whether the embedder indicated this navigation is being used for |
| 170 | // advertising purposes. |
| 171 | bool is_ad_tagged; |
Mustafa Emre Acer | 1001b3d | 2024-07-09 23:10:43 | [diff] [blame] | 172 | |
| 173 | // If true, the navigation will not be upgraded to HTTPS. |
| 174 | bool force_no_https_upgrade; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | } // namespace content |
| 178 | |
| 179 | #endif // CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_ |