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 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 8 | #include "base/unguessable_token.h" |
| 9 | #include "content/common/content_export.h" |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame^] | 10 | #include "content/public/browser/global_routing_id.h" |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 11 | #include "content/public/browser/weak_document_ptr.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 12 | #include "content/public/common/referrer.h" |
| 13 | #include "net/base/isolation_info.h" |
Hans Wennborg | 0d7c5ba | 2021-07-06 17:52:20 | [diff] [blame] | 14 | #include "net/filter/source_stream.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 15 | #include "net/http/http_request_headers.h" |
| 16 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 17 | #include "services/network/public/mojom/client_security_state.mojom-forward.h" |
Lei Zhang | 698df03c | 2021-05-21 04:23:34 | [diff] [blame] | 18 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 19 | #include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 20 | #include "url/gurl.h" |
| 21 | #include "url/origin.h" |
| 22 | |
| 23 | namespace 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. |
| 28 | struct CONTENT_EXPORT NavigationRequestInfo { |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 29 | NavigationRequestInfo( |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 30 | blink::mojom::CommonNavigationParamsPtr common_params, |
| 31 | blink::mojom::BeginNavigationParamsPtr begin_params, |
Arthur Sonzogni | 038f0de | 2021-10-07 13:51:34 | [diff] [blame] | 32 | network::mojom::WebSandboxFlags sandbox_flags, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 33 | const net::IsolationInfo& isolation_info, |
Miyoung Shin | ff5aec9 | 2022-03-08 08:51:50 | [diff] [blame] | 34 | bool is_primary_main_frame, |
David Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 35 | bool is_outermost_main_frame, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 36 | bool is_main_frame, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 37 | bool are_ancestors_secure, |
| 38 | int frame_tree_node_id, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 39 | bool report_raw_headers, |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 40 | 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 Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 45 | net::HttpRequestHeaders cors_exempt_headers, |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 46 | network::mojom::ClientSecurityStatePtr client_security_state, |
Anton Bikineev | f62d1bf | 2021-05-15 17:56:07 | [diff] [blame] | 47 | const absl::optional<std::vector<net::SourceStream::SourceType>>& |
Daniel Hosseinian | e58ff35 | 2021-10-01 05:13:47 | [diff] [blame] | 48 | devtools_accepted_stream_types, |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 49 | bool is_pdf, |
Igor Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 50 | WeakDocumentPtr initiator_document, |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame^] | 51 | const GlobalRenderFrameHostId& previous_render_frame_host_id, |
Igor Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 52 | bool allow_cookies_from_browser); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 53 | NavigationRequestInfo(const NavigationRequestInfo& other) = delete; |
| 54 | ~NavigationRequestInfo(); |
| 55 | |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 56 | blink::mojom::CommonNavigationParamsPtr common_params; |
| 57 | blink::mojom::BeginNavigationParamsPtr begin_params; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 58 | |
Arthur Sonzogni | 038f0de | 2021-10-07 13:51:34 | [diff] [blame] | 59 | // 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 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 69 | // 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 Goldstein | d22b064 | 2022-10-11 16:30:50 | [diff] [blame] | 72 | // NetworkAnonymizationKey, which is used to restrict sharing of network |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 73 | // 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 Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 77 | // 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 Shin | ff5aec9 | 2022-03-08 08:51:50 | [diff] [blame] | 80 | const bool is_primary_main_frame; |
| 81 | |
David Bokan | 98aabfe9 | 2022-04-14 02:10:12 | [diff] [blame] | 82 | // 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. |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 93 | const bool is_main_frame; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 94 | |
| 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 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 101 | const bool report_raw_headers; |
| 102 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 103 | // 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 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 115 | const net::HttpRequestHeaders cors_exempt_headers; |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 116 | |
| 117 | // Specifies the security state applying to the navigation. For iframes, this |
| 118 | // is the security state of their parent. Nullptr otherwise. |
Titouan Rigoudy | e10716b | 2020-09-29 13:29:55 | [diff] [blame] | 119 | // |
| 120 | // TODO(https://crbug.com/1129326): Set this for top-level navigation requests |
| 121 | // too once the UX story is sorted out. |
Titouan Rigoudy | 97d9fd6 | 2020-09-28 16:16:42 | [diff] [blame] | 122 | const network::mojom::ClientSecurityStatePtr client_security_state; |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 123 | |
| 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 Bikineev | f62d1bf | 2021-05-15 17:56:07 | [diff] [blame] | 127 | absl::optional<std::vector<net::SourceStream::SourceType>> |
Alex Rudenko | 0e632e47 | 2021-03-24 09:57:40 | [diff] [blame] | 128 | devtools_accepted_stream_types; |
Daniel Hosseinian | e58ff35 | 2021-10-01 05:13:47 | [diff] [blame] | 129 | |
| 130 | // Indicates that this navigation is for PDF content in a renderer. |
| 131 | const bool is_pdf; |
Jeremy Roman | 04ad4e3f | 2021-12-22 18:54:54 | [diff] [blame] | 132 | |
| 133 | // The initiator document, if still available. |
| 134 | const WeakDocumentPtr initiator_document; |
Igor Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 135 | |
Hiroshige Hayashizaki | 6e9a189 | 2023-04-17 06:47:38 | [diff] [blame^] | 136 | // 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 Ruvinov | 0ea2ebb | 2022-12-01 16:33:06 | [diff] [blame] | 141 | // Whether a Cookie header added to this request should not be overwritten by |
| 142 | // the network service. |
| 143 | const bool allow_cookies_from_browser; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | } // namespace content |
| 147 | |
| 148 | #endif // CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_ |