summaryrefslogtreecommitdiff
path: root/chromium/content/common/navigation_params.mojom
blob: 872d11d8fda6b86886b6e39b28352719afdb58db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
// Copyright 2017 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.

module content.mojom;

import "content/common/prefetched_signed_exchange_info.mojom";
import "content/public/common/was_activated_option.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "mojo/public/mojom/base/values.mojom";
import "services/network/public/mojom/content_security_policy.mojom";
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/ip_address_space.mojom";
import "services/network/public/mojom/source_location.mojom";
import "services/network/public/mojom/trust_tokens.mojom";
import "services/network/public/mojom/url_loader.mojom";
import "services/network/public/mojom/url_response_head.mojom";
import "third_party/blink/public/mojom/feature_policy/feature_policy.mojom";
import "third_party/blink/public/mojom/fetch/fetch_api_request.mojom";
import "third_party/blink/public/mojom/frame/frame_policy.mojom";
import "third_party/blink/public/mojom/referrer.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";

[Native]
struct Impression;

[Native]
enum MixedContentContextType;

[Native]
struct NavigationDownloadPolicy;

[Native]
struct PageState;

[Native]
enum PageTransition;

// Represents the Content Security Policy of the initator of the navigation.
struct InitiatorCSPInfo {
  // Whether or not the CSP of the main world should apply. When the navigation
  // is initiated from a content script in an isolated world, the CSP defined
  // in the main world should not apply.
  // TODO(arthursonzogni): Instead of this boolean, the origin of the isolated
  // world which has initiated the navigation should be passed.
  // See https://crbug.com/702540
  network.mojom.CSPDisposition should_check_main_world_csp =
      network.mojom.CSPDisposition.CHECK;

  // The relevant CSP policies and the initiator 'self' source to be used.
  array<network.mojom.ContentSecurityPolicy> initiator_csp;
  network.mojom.CSPSource? initiator_self_source;
};

enum NavigationType {
  // Reload the page, validating only cache entry for the main resource.
  RELOAD,

  // Reload the page, bypassing any cache entries.
  RELOAD_BYPASSING_CACHE,

  // Reload the page using the original request URL.
  RELOAD_ORIGINAL_REQUEST_URL,

  // The navigation is the result of session restore and should honor the
  // page's cache policy while restoring form state. This is set to true if
  // restoring a tab/session from the previous session and the previous
  // session did not crash. If this is not set and the page was restored then
  // the page's cache policy is ignored and we load from the cache.
  RESTORE,

  // Like RESTORE, except that the navigation contains POST data.
  RESTORE_WITH_POST,

  // History navigation inside the same document.
  HISTORY_SAME_DOCUMENT,

  // History navigation to a different document.
  HISTORY_DIFFERENT_DOCUMENT,

  // Navigation inside the same document. It occurs when the part of the url
  // that is modified is after the '#' part.
  SAME_DOCUMENT,

  // Navigation to another document.
  DIFFERENT_DOCUMENT,
};

// Provided by the renderer ----------------------------------------------------
//
// This struct holds parameters sent by the renderer to the browser, that are
// needed to start a navigation.
struct BeginNavigationParams {
  // Routing id of the initiator of the navigation. This routing id may no
  // longer be valid by the time the navigation is seen by the browser process,
  // if the initiator frame is deleted before the navigation IPC arrives. A
  // value of MSG_ROUTING_NONE indicates this navigation is not associated
  // with a frame.
  int32 initiator_routing_id;

  // Additional HTTP request headers.
  string headers;

  // net::URLRequest load flags (net::LOAD_NORMAL) by default).
  int32 load_flags;

  // True if the ServiceWorker should be skipped.
  bool skip_service_worker;

  // Indicates the request context type.
  blink.mojom.RequestContextType request_context_type;

  // Indicates the request destination.
  network.mojom.RequestDestination request_destination;

  // The mixed content context type for potential mixed content checks.
  MixedContentContextType mixed_content_context_type;

  // Whether or not the navigation has been initiated by a form submission.
  bool is_form_submission;

  // Whether or not the navigation has been initiated by a link click.
  bool was_initiated_by_link_click;

  // See WebSearchableFormData for a description of these.
  url.mojom.Url searchable_form_url;
  string searchable_form_encoding;

  // If the transition type is a client side redirect, then this holds the URL
  // of the page that had the client side redirect.
  url.mojom.Url client_side_redirect_url;

  // If the navigation is renderer-initiated and the renderer is being
  // inspected by DevTools, this field is non-null and contains the
  // initiator information in DevTools protocol format. See
  // https://chromedevtools.github.io/devtools-protocol/tot/Network#type-Initiator
  // for details.
  mojo_base.mojom.DictionaryValue? devtools_initiator;

  // Whether or not this navigation should unconditionally attach SameSite
  // cookies, bypassing the usual site_for_cookies checks. Setting this to true
  // causes SameSite cookies to be attached for cross-site requests (or requests
  // that "look" cross-site). See the field of the same name in
  // network::ResourceRequest.
  bool force_ignore_site_for_cookies = false;

  // Specifies whether, and how, the navigation should execute a Trust Tokens
  // operation (https://github.com/wicg/trust-token-api) and attach headers
  // conveying the result of the operation. Set on some child frame navigations.
  network.mojom.TrustTokenParams? trust_token_params;

  // Carries optional information associated with conversion measurement for
  // this navigation. Only set on navigations originating from anchors with
  // relevant impression attributes set.
  Impression? impression;
};

// Provided by the browser or the renderer -------------------------------------

// Used by all navigation IPCs.
struct CommonNavigationParams {
  // The URL to navigate to.
  // May be modified when the navigation is ready to commit.
  url.mojom.Url url;

  // When a frame navigates another frame, this is the origin of the document
  // which initiated the navigation. This parameter can be null for
  // browser-initiated navigations.
  url.mojom.Origin? initiator_origin;

  // The URL to send in the "Referer" header field. Can be empty if there is
  // no referrer.
  blink.mojom.Referrer referrer;

  // The type of transition.
  PageTransition transition;

  // Type of navigation.
  NavigationType navigation_type = DIFFERENT_DOCUMENT;

  // Governs how downloads are handled by this navigation.
  NavigationDownloadPolicy download_policy;

  // Informs the RenderView the pending navigation should replace the current
  // history entry when it commits.  This is used by client-side redirects to
  // indicate that when the navigation commits, it should commit in the existing
  // page.
  bool should_replace_current_entry = false;

  // Base URL for use in Blink's SubstituteData.
  // Is only used with data: URLs.
  url.mojom.Url base_url_for_data_url;

  // History URL for use in Blink's SubstituteData.
  // Is only used with data: URLs.
  url.mojom.Url history_url_for_data_url;

  // Bitmask that has whether or not to request a Preview version of the
  // document for various preview types or let the browser decide.
  // Defined in content/public/common/previews_state.h.
  int32 previews_state;

  // The navigationStart time exposed through the Navigation Timing API to JS.
  mojo_base.mojom.TimeTicks navigation_start;

  // The request method: GET, POST, etc.
  string method = "GET";

  // Body of HTTP POST request.
  network.mojom.URLRequestBody? post_data;

  // Information about the Javascript source for this navigation. Used for
  // providing information in console error messages triggered by the
  // navigation. If the navigation is not caused by Javascript, the
  // SourceLocation's URL is empty.
  network.mojom.SourceLocation source_location;

  // Whether or not this navigation was started from a context menu.
  bool started_from_context_menu = false;

  // True if the request was user initiated.
  bool has_user_gesture = false;

  // We require a copy of the relevant CSP to perform navigation checks.
  InitiatorCSPInfo initiator_csp_info;

  // The origin trial features activated in the initiator that should be applied
  // in the document being navigated to. The int values are blink
  // OriginTrialFeature enum values. OriginTrialFeature enum is not visible
  // outside of blink (and doesn't need to be) so these values are casted to int
  // as they are passed through content across navigations.
  array<int32> initiator_origin_trial_features;

  // The value of the hrefTranslate attribute if this navigation was initiated
  // from a link that had that attribute set.
  string href_translate;

  // Whether this is a history navigation in a newly created child frame, in
  // which case the browser process is instructing the renderer process to load
  // a URL from a session history item.  Defaults to false.
  // TODO(ahemery): Move this to BeginNavigationParams once we default to
  // IsPerNavigationMojoInterface().
  bool is_history_navigation_in_new_child_frame = false;

  // The time the input event leading to the navigation occurred. This will
  // not always be set; it depends on the creator of the CommonNavigationParams
  // setting it.
  mojo_base.mojom.TimeTicks input_start;
};

// Provided by the browser -----------------------------------------------------

// Timings collected in the browser during navigation for the
// Navigation Timing API. Sent to Blink in CommitNavigationParams when
// the navigation is ready to be committed.
struct NavigationTiming {
  mojo_base.mojom.TimeTicks redirect_start;
  mojo_base.mojom.TimeTicks redirect_end;
  mojo_base.mojom.TimeTicks fetch_start;
};

// Used by commit IPC messages. Holds the parameters needed by the renderer to
// commit a navigation besides those in CommonNavigationParams.
struct CommitNavigationParams {
  // The origin to be used for committing the navigation, if specified.
  // This will be an origin that's compatible with the |url| in the
  // CommonNavigationParams; if |url| is data: or about:blank, or the frame has
  // sandbox attributes, this determines the origin of the resulting document.
  // It is specified for session history navigations, for which the origin is
  // known and saved in the FrameNavigationEntry.
  url.mojom.Origin? origin_to_commit;

  // Whether or not the user agent override string should be used.
  bool is_overriding_user_agent = false;

  // Any redirect URLs that occurred before |url|. Useful for cross-process
  // navigations; defaults to empty.
  array<url.mojom.Url> redirects;

  // The ResourceResponseInfos received during redirects.
  array<network.mojom.URLResponseHead> redirect_response;

  // The RedirectInfos received during redirects.
  array<network.mojom.URLRequestRedirectInfo> redirect_infos;

  // The content type from the request headers for POST requests.
  string post_content_type;

  // The original URL & method for this navigation.
  url.mojom.Url original_url;
  string original_method;

  // Whether or not this url should be allowed to access local file://
  // resources.
  bool can_load_local_resources = false;

  // Opaque history state (received by UpdateState Mojo message).
  PageState page_state;

  // For browser-initiated navigations, this is the unique id of the
  // NavigationEntry being navigated to. (For renderer-initiated navigations it
  // is 0.) If the load succeeds, then this nav_entry_id will be reflected in
  // the resulting FrameHostMsg_DidCommitProvisionalLoad_Params.
  int32 nav_entry_id = 0;

  // If this is a history navigation, this contains a map of frame unique names
  // to |is_about_blank| for immediate children of the frame being navigated for
  // which there are history items.  The renderer process only needs to check
  // with the browser process for newly created subframes that have these unique
  // names (and only when not staying on about:blank).
  // TODO(creis): Expand this to a data structure including corresponding
  // same-process PageStates for the whole subtree in https://crbug.com/639842.
  map<string, bool> subframe_unique_names;

  // For browser-initiated navigations, this is true if this is a new entry
  // being navigated to. This is false otherwise. TODO(avi): Remove this when
  // the pending entry situation is made sane and the browser keeps them around
  // long enough to match them via nav_entry_id, above.
  bool intended_as_new_entry = false;

  // For history navigations, this is the offset in the history list of the
  // pending load. For non-history navigations, this will be ignored.
  int32 pending_history_list_offset = -1;

  // Where its current page contents reside in session history and the total
  // size of the session history list.
  int32 current_history_list_offset = -1;
  int32 current_history_list_length = 0;

  // Indicates that the tab was previously discarded.
  // wasDiscarded is exposed on Document after discard, see:
  // https://github.com/WICG/web-lifecycle
  bool was_discarded = false;

  // Indicates whether the navigation is to a view-source:// scheme or not.
  // It is a separate boolean as the view-source scheme is stripped from the
  // URL before it is sent to the renderer process and the RenderFrame needs
  // to be put in special view source mode.
  bool is_view_source = false;

  // Whether session history should be cleared. In that case, the RenderView
  // needs to notify the browser that the clearing was successful when the
  // navigation commits.
  bool should_clear_history_list = false;

  // Timing of navigation events.
  NavigationTiming navigation_timing;

  // The AppCache host id to be used to identify this navigation.
  mojo_base.mojom.UnguessableToken? appcache_host_id;

  // Set to |kYes| if a navigation is following the rules of user activation
  // propagation. This is different from |has_user_gesture|
  // (in CommonNavigationParams) as the activation may have happened before
  // the navigation was triggered, for example.
  // 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
  // start it. `was_activated` will answer the former question while
  // `user_gesture` will answer the latter.
  WasActivatedOption was_activated = kUnknown;

  // A token that should be passed to the browser process in
  // DidCommitProvisionalLoadParams.
  // TODO(clamy): Remove this once NavigationClient has shipped and
  // same-document browser-initiated navigations are properly handled as well.
  mojo_base.mojom.UnguessableToken navigation_token;

  // Prefetched signed exchanges. Used when SignedExchangeSubresourcePrefetch
  // feature is enabled.
  array<PrefetchedSignedExchangeInfo> prefetched_signed_exchanges;

  // The real content of the data: URL. Only used in Android WebView for
  // implementing LoadDataWithBaseUrl API method to circumvent the restriction
  // on the GURL max length in the IPC layer. Short data: URLs can still be
  // passed in the |CommonNavigationParams::url| field.
  [EnableIf=is_android]
  string data_url_as_string;

  // Whether this navigation was browser initiated.
  bool is_browser_initiated = false;

  // The IP address space into which this document is committing.
  // https://wicg.github.io/cors-rfc1918/#address-space
  network.mojom.IPAddressSpace ip_address_space =
      network.mojom.IPAddressSpace.kUnknown;

  // The physical URL of Web Bundle from which the document is loaded.
  // Used as an additional identifier for MemoryCache.
  url.mojom.Url web_bundle_physical_url;

  // The claimed URL inside Web Bundle from which the document is loaded.
  url.mojom.Url web_bundle_claimed_url;

  // A snapshot value of frame policy(both sandbox flags and container policy)
  // of the frame that is being navigated. The snapshot value is captured at the
  // start of navigation.
  // - The value is set to null for top-level browser-initiated navigation.
  // - The value is also set to null when Ctrl-click was used to create a new
  // tab and navigate, i.e. the document in new tab will inherit no
  // frame_policy.
  // - For navigation created from NavigationControllerImpl::
  // CreateNavigationRequestFromEntry which corresponds to history navigation,
  // the value is set to current FrameTreeNode::pending_frame_policy in
  // frame_tree_node. This behavior is currently undocumented and probably need
  // further discussion. Another potential approach is to record frame policy
  // value in NavigationEntry and reuse the historical value.
  // - For local frame navigation, the value is set at NavigationRequest::
  // CreateRendererInitiated.
  // - For remote frame navigation, the value is set at
  // NavigationControllerImpl::CreateNavigationRequestFromLoadParams.
  blink.mojom.FramePolicy? frame_policy;

  // The names of origin trials to be force enabled for this navigation.
  array<string> force_enabled_origin_trials;

  // Whether origin isolation is restricting certain cross-origin web APIs.
  bool origin_isolation_restricted = false;
};