1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3  * Copyright (C) 2011 Google Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_DOCUMENT_LOADER_H_
31 #define THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_DOCUMENT_LOADER_H_
32 
33 #include <memory>
34 
35 #include "base/memory/scoped_refptr.h"
36 #include "base/optional.h"
37 #include "base/unguessable_token.h"
38 #include "mojo/public/cpp/base/big_buffer.h"
39 #include "services/metrics/public/cpp/ukm_source_id.h"
40 #include "third_party/blink/public/common/feature_policy/document_policy.h"
41 #include "third_party/blink/public/common/loader/loading_behavior_flag.h"
42 #include "third_party/blink/public/mojom/loader/content_security_notifier.mojom-blink.h"
43 #include "third_party/blink/public/mojom/loader/mhtml_load_result.mojom-blink-forward.h"
44 #include "third_party/blink/public/mojom/page_state/page_state.mojom-blink.h"
45 #include "third_party/blink/public/mojom/timing/worker_timing_container.mojom-blink-forward.h"
46 #include "third_party/blink/public/platform/scheduler/web_scoped_virtual_time_pauser.h"
47 #include "third_party/blink/public/platform/web_navigation_body_loader.h"
48 #include "third_party/blink/public/web/web_document_loader.h"
49 #include "third_party/blink/public/web/web_frame_load_type.h"
50 #include "third_party/blink/public/web/web_history_commit_type.h"
51 #include "third_party/blink/public/web/web_navigation_params.h"
52 #include "third_party/blink/public/web/web_navigation_type.h"
53 #include "third_party/blink/public/web/web_origin_policy.h"
54 #include "third_party/blink/renderer/bindings/core/v8/source_location.h"
55 #include "third_party/blink/renderer/core/core_export.h"
56 #include "third_party/blink/renderer/core/dom/weak_identifier_map.h"
57 #include "third_party/blink/renderer/core/feature_policy/policy_helper.h"
58 #include "third_party/blink/renderer/core/frame/dactyloscoper.h"
59 #include "third_party/blink/renderer/core/frame/frame_types.h"
60 #include "third_party/blink/renderer/core/frame/use_counter_helper.h"
61 #include "third_party/blink/renderer/core/html/parser/parser_synchronization_policy.h"
62 #include "third_party/blink/renderer/core/loader/document_load_timing.h"
63 #include "third_party/blink/renderer/core/loader/frame_loader_types.h"
64 #include "third_party/blink/renderer/core/loader/navigation_policy.h"
65 #include "third_party/blink/renderer/core/loader/preload_helper.h"
66 #include "third_party/blink/renderer/core/loader/previews_resource_loading_hints.h"
67 #include "third_party/blink/renderer/core/page/viewport_description.h"
68 #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
69 #include "third_party/blink/renderer/platform/loader/fetch/client_hints_preferences.h"
70 #include "third_party/blink/renderer/platform/loader/fetch/resource_error.h"
71 #include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
72 #include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
73 #include "third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.h"
74 #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
75 #include "third_party/blink/renderer/platform/weborigin/referrer.h"
76 #include "third_party/blink/renderer/platform/wtf/hash_set.h"
77 #include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
78 namespace base {
79 class TickClock;
80 }
81 
82 namespace blink {
83 
84 class ApplicationCacheHostForFrame;
85 class ContentSecurityPolicy;
86 class Document;
87 class DocumentParser;
88 class FrameLoader;
89 class HistoryItem;
90 class LocalDOMWindow;
91 class LocalFrame;
92 class LocalFrameClient;
93 class MHTMLArchive;
94 class PrefetchedSignedExchangeManager;
95 class ResourceTimingInfo;
96 class SerializedScriptValue;
97 class SubresourceFilter;
98 class WebServiceWorkerNetworkProvider;
99 
100 namespace mojom {
101 enum class CommitResult : int32_t;
102 }
103 
104 // The DocumentLoader fetches a main resource and handles the result.
105 // TODO(https://crbug.com/855189). This was originally structured to have a
106 // provisional load, then commit but that is no longer necessary and this class
107 // can be simplified.
108 class CORE_EXPORT DocumentLoader : public GarbageCollected<DocumentLoader>,
109                                    public UseCounter,
110                                    public WebNavigationBodyLoader::Client {
111  public:
112   DocumentLoader(LocalFrame*,
113                  WebNavigationType navigation_type,
114                  ContentSecurityPolicy* content_security_policy,
115                  std::unique_ptr<WebNavigationParams> navigation_params);
116   ~DocumentLoader() override;
117 
118   static bool WillLoadUrlAsEmpty(const KURL&);
119 
GetFrame()120   LocalFrame* GetFrame() const { return frame_; }
121 
122   ResourceTimingInfo* GetNavigationTimingInfo() const;
123 
124   virtual void DetachFromFrame(bool flush_microtask_queue);
125 
126   uint64_t MainResourceIdentifier() const;
127 
128   const AtomicString& MimeType() const;
129 
130   const KURL& OriginalUrl() const;
131   const Referrer& OriginalReferrer() const;
132 
Archive()133   MHTMLArchive* Archive() const { return archive_.Get(); }
134 
135   void SetSubresourceFilter(SubresourceFilter*);
GetSubresourceFilter()136   SubresourceFilter* GetSubresourceFilter() const {
137     return subresource_filter_.Get();
138   }
SetPreviewsResourceLoadingHints(PreviewsResourceLoadingHints * resource_loading_hints)139   void SetPreviewsResourceLoadingHints(
140       PreviewsResourceLoadingHints* resource_loading_hints) {
141     resource_loading_hints_ = resource_loading_hints;
142   }
GetPreviewsResourceLoadingHints()143   PreviewsResourceLoadingHints* GetPreviewsResourceLoadingHints() const {
144     return resource_loading_hints_;
145   }
146 
147   const KURL& Url() const;
148   const KURL& UrlForHistory() const;
149   const AtomicString& HttpMethod() const;
150   const Referrer& GetReferrer() const;
151   const KURL& UnreachableURL() const;
152   const base::Optional<blink::mojom::FetchCacheMode>& ForceFetchCacheMode()
153       const;
154 
155   void DidChangePerformanceTiming();
156   void DidObserveInputDelay(base::TimeDelta input_delay);
157   void DidObserveLoadingBehavior(LoadingBehaviorFlag);
158   void UpdateForSameDocumentNavigation(const KURL&,
159                                        SameDocumentNavigationSource,
160                                        scoped_refptr<SerializedScriptValue>,
161                                        mojom::blink::ScrollRestorationType,
162                                        WebFrameLoadType,
163                                        bool is_content_initiated);
GetResponse()164   const ResourceResponse& GetResponse() const { return response_; }
IsClientRedirect()165   bool IsClientRedirect() const { return is_client_redirect_; }
ReplacesCurrentHistoryItem()166   bool ReplacesCurrentHistoryItem() const {
167     return replaces_current_history_item_;
168   }
169 
IsCommittedButEmpty()170   bool IsCommittedButEmpty() const {
171     return state_ >= kCommitted && !data_received_;
172   }
173 
SetSentDidFinishLoad()174   void SetSentDidFinishLoad() { state_ = kSentDidFinishLoad; }
SentDidFinishLoad()175   bool SentDidFinishLoad() const { return state_ == kSentDidFinishLoad; }
176 
LoadType()177   WebFrameLoadType LoadType() const { return load_type_; }
SetLoadType(WebFrameLoadType load_type)178   void SetLoadType(WebFrameLoadType load_type) { load_type_ = load_type; }
179 
GetNavigationType()180   WebNavigationType GetNavigationType() const { return navigation_type_; }
SetNavigationType(WebNavigationType navigation_type)181   void SetNavigationType(WebNavigationType navigation_type) {
182     navigation_type_ = navigation_type;
183   }
184 
GetHistoryItem()185   HistoryItem* GetHistoryItem() const { return history_item_; }
186 
187   void StartLoading();
188   void StopLoading();
189 
190   // CommitNavigation() does the work of creating a Document and
191   // DocumentParser, as well as creating a new LocalDOMWindow if needed. It also
192   // initializes a bunch of state on the Document (e.g., the state based on
193   // response headers).
194   void CommitNavigation();
195 
196   // Called when the browser process has asked this renderer process to commit a
197   // same document navigation in that frame. Returns false if the navigation
198   // cannot commit, true otherwise.
199   mojom::CommitResult CommitSameDocumentNavigation(
200       const KURL&,
201       WebFrameLoadType,
202       HistoryItem*,
203       ClientRedirectPolicy,
204       LocalDOMWindow* origin_window,
205       bool has_event,
206       std::unique_ptr<WebDocumentLoader::ExtraData>);
207 
208   void SetDefersLoading(WebURLLoader::DeferType defers);
209 
GetTiming()210   DocumentLoadTiming& GetTiming() { return document_load_timing_; }
211 
GetApplicationCacheHost()212   ApplicationCacheHostForFrame* GetApplicationCacheHost() const {
213     return application_cache_host_.Get();
214   }
215 
GetPreviewsState()216   PreviewsState GetPreviewsState() const { return previews_state_; }
217 
218   struct InitialScrollState {
219     DISALLOW_NEW();
InitialScrollStateInitialScrollState220     InitialScrollState()
221         : was_scrolled_by_user(false), did_restore_from_history(false) {}
222 
223     bool was_scrolled_by_user;
224     bool did_restore_from_history;
225   };
GetInitialScrollState()226   InitialScrollState& GetInitialScrollState() { return initial_scroll_state_; }
227 
228   void DispatchLinkHeaderPreloads(const ViewportDescription*,
229                                   PreloadHelper::MediaPreloadPolicy);
230 
231   void SetServiceWorkerNetworkProvider(
232       std::unique_ptr<WebServiceWorkerNetworkProvider>);
233 
234   // May return null before the first HTML tag is inserted by the
235   // parser (before didCreateDataSource is called), after the document
236   // is detached from frame, or in tests.
GetServiceWorkerNetworkProvider()237   WebServiceWorkerNetworkProvider* GetServiceWorkerNetworkProvider() {
238     return service_worker_network_provider_.get();
239   }
240 
241   void LoadFailed(const ResourceError&);
242 
243   void Trace(Visitor*) const override;
244 
245   // For automation driver-initiated navigations over the devtools protocol,
246   // |devtools_navigation_token_| is used to tag the navigation. This navigation
247   // token is then sent into the renderer and lands on the DocumentLoader. That
248   // way subsequent Blink-level frame lifecycle events can be associated with
249   // the concrete navigation.
250   // - The value should not be sent back to the browser.
251   // - The value on DocumentLoader may be generated in the renderer in some
252   // cases, and thus shouldn't be trusted.
253   // TODO(crbug.com/783506): Replace devtools navigation token with the generic
254   // navigation token that can be passed from renderer to the browser.
GetDevToolsNavigationToken()255   const base::UnguessableToken& GetDevToolsNavigationToken() {
256     return devtools_navigation_token_;
257   }
258 
259   // Can be used to temporarily suspend feeding the parser with new data. The
260   // parser will be allowed to read new data when ResumeParser() is called the
261   // same number of time than BlockParser().
262   void BlockParser();
263   void ResumeParser();
264 
IsListingFtpDirectory()265   bool IsListingFtpDirectory() const { return listing_ftp_directory_; }
266 
GetUseCounterHelper()267   UseCounterHelper& GetUseCounterHelper() { return use_counter_; }
GetDactyloscoper()268   Dactyloscoper& GetDactyloscoper() { return dactyloscoper_; }
269 
270   PrefetchedSignedExchangeManager* GetPrefetchedSignedExchangeManager() const;
271 
272   // UseCounter
273   void CountUse(mojom::WebFeature) override;
274 
SetApplicationCacheHostForTesting(ApplicationCacheHostForFrame * host)275   void SetApplicationCacheHostForTesting(ApplicationCacheHostForFrame* host) {
276     application_cache_host_ = host;
277   }
278 
SetCommitReason(CommitReason reason)279   void SetCommitReason(CommitReason reason) { commit_reason_ = reason; }
280 
HadTransientActivation()281   bool HadTransientActivation() const { return had_transient_activation_; }
282 
283   // Whether the navigation originated from the browser process. Note: history
284   // navigation is always considered to be browser initiated, even if the
285   // navigation was started using the history API in the renderer.
IsBrowserInitiated()286   bool IsBrowserInitiated() const { return is_browser_initiated_; }
287 
IsSameOriginNavigation()288   bool IsSameOriginNavigation() const { return is_same_origin_navigation_; }
289 
290   // TODO(dcheng, japhet): Some day, Document::Url() will always match
291   // DocumentLoader::Url(), and one of them will be removed. Today is not that
292   // day though.
UpdateUrlForDocumentOpen(const KURL & url)293   void UpdateUrlForDocumentOpen(const KURL& url) { url_ = url; }
294 
295   enum class HistoryNavigationType {
296     kDifferentDocument,
297     kFragment,
298     kHistoryApi
299   };
300 
301   void SetHistoryItemStateForCommit(HistoryItem* old_item,
302                                     WebFrameLoadType,
303                                     HistoryNavigationType);
304 
305   mojo::PendingReceiver<mojom::blink::WorkerTimingContainer>
306   TakePendingWorkerTimingReceiver(int request_id);
307 
WebBundlePhysicalUrl()308   const KURL& WebBundlePhysicalUrl() const { return web_bundle_physical_url_; }
309 
NavigationScrollAllowed()310   bool NavigationScrollAllowed() const { return navigation_scroll_allowed_; }
311 
312   // We want to make sure that the largest content is painted before the "LCP
313   // limit", so that we get a good LCP value. This returns the remaining time to
314   // the LCP limit. See crbug.com/1065508 for details.
315   base::TimeDelta RemainingTimeToLCPLimit() const;
316 
317   mojom::blink::ContentSecurityNotifier& GetContentSecurityNotifier();
318 
319   // Returns the value of the text fragment token and then resets it to false
320   // to ensure the token can only be used to invoke a single text fragment.
321   bool ConsumeTextFragmentToken();
322 
323  protected:
324   Vector<KURL> redirect_chain_;
325 
326   // Based on its MIME type, if the main document's response corresponds to an
327   // MHTML archive, then every resources will be loaded from this archive.
328   //
329   // This includes:
330   // - The main document.
331   // - Every nested document.
332   // - Every subresource.
333   //
334   // This excludes:
335   // - data-URLs documents and subresources.
336   // - about:srcdoc documents.
337   // - Error pages.
338   //
339   // Whether about:blank and derivative should be loaded from the archive is
340   // weird edge case: Please refer to the tests:
341   // - NavigationMhtmlBrowserTest.IframeAboutBlankNotFound
342   // - NavigationMhtmlBrowserTest.IframeAboutBlankFound
343   //
344   // Nested documents are loaded in the same process and grab a reference to the
345   // same `archive_` as their parent.
346   //
347   // Resources:
348   // - https://tools.ietf.org/html/rfc822
349   // - https://tools.ietf.org/html/rfc2387
350   Member<MHTMLArchive> archive_;
351 
352  private:
353   network::mojom::blink::WebSandboxFlags CalculateSandboxFlags();
354   scoped_refptr<SecurityOrigin> CalculateOrigin(
355       Document* owner_document,
356       network::mojom::blink::WebSandboxFlags);
357   void InitializeWindow(Document* owner_document);
358   void DidInstallNewDocument(Document*);
359   void WillCommitNavigation();
360   void DidCommitNavigation();
361   void RecordUseCountersForCommit();
362   void RecordConsoleMessagesForCommit();
363 
364   void CreateParserPostCommit();
365 
366   void CommitSameDocumentNavigationInternal(
367       const KURL&,
368       WebFrameLoadType,
369       HistoryItem*,
370       ClientRedirectPolicy,
371       bool is_content_initiated,
372       bool has_event,
373       std::unique_ptr<WebDocumentLoader::ExtraData>);
374 
375   // Use these method only where it's guaranteed that |m_frame| hasn't been
376   // cleared.
377   FrameLoader& GetFrameLoader() const;
378   LocalFrameClient& GetLocalFrameClient() const;
379 
380   void ConsoleError(const String& message);
381 
382   // Replace the current document with a empty one and the URL with a unique
383   // opaque origin.
384   void ReplaceWithEmptyDocument();
385 
386   DocumentPolicy::ParsedDocumentPolicy CreateDocumentPolicy();
387 
388   void StartLoadingInternal();
389   void StartLoadingResponse();
390   void FinishedLoading(base::TimeTicks finish_time);
391   void CancelLoadAfterCSPDenied(const ResourceResponse&);
392 
393   void HandleRedirect(const KURL& current_request_url);
394   void HandleResponse();
395 
396   void InitializeEmptyResponse();
397 
398   bool ShouldReportTimingInfoToParent();
399 
400   void CommitData(const char* bytes, size_t length);
401   // Processes the data stored in the data_buffer_, used to avoid appending data
402   // to the parser in a nested message loop.
403   void ProcessDataBuffer(const char* bytes = nullptr, size_t length = 0);
404 
405   // Sends an intervention report if the page is being served as a preview.
406   void ReportPreviewsIntervention() const;
407 
408   // WebNavigationBodyLoader::Client
409   void BodyCodeCacheReceived(mojo_base::BigBuffer data) override;
410   void BodyDataReceived(base::span<const char> data) override;
411   void BodyLoadingFinished(base::TimeTicks completion_time,
412                            int64_t total_encoded_data_length,
413                            int64_t total_encoded_body_length,
414                            int64_t total_decoded_body_length,
415                            bool should_report_corb_blocking,
416                            const base::Optional<WebURLError>& error) override;
417 
418   void ApplyClientHintsConfig(
419       const WebVector<network::mojom::WebClientHintsType>&
420           enabled_client_hints);
421 
422   // For SignedExchangeSubresourcePrefetch feature. If the page was loaded from
423   // a signed exchage which has "allowed-alt-sxg" link headers in the inner
424   // response and PrefetchedSignedExchanges were passed from the previous page,
425   // initializes a PrefetchedSignedExchangeManager which will hold the
426   // subresource signed exchange related headers ("alternate" link header in the
427   // outer response and "allowed-alt-sxg" link header in the inner response of
428   // the page's signed exchange), and the passed PrefetchedSignedExchanges.
429   // The created PrefetchedSignedExchangeManager will be used to load the
430   // prefetched signed exchanges for matching requests.
431   void InitializePrefetchedSignedExchangeManager();
432 
IsJavaScriptURLOrXSLTCommit()433   bool IsJavaScriptURLOrXSLTCommit() const {
434     return commit_reason_ == CommitReason::kJavascriptUrl ||
435            commit_reason_ == CommitReason::kXSLT;
436   }
437 
438   // Params are saved in constructor and are cleared after StartLoading().
439   // TODO(dgozman): remove once StartLoading is merged with constructor.
440   std::unique_ptr<WebNavigationParams> params_;
441 
442   // These fields are copied from WebNavigationParams, see there for definition.
443   KURL url_;
444   AtomicString http_method_;
445   Referrer referrer_;
446   scoped_refptr<EncodedFormData> http_body_;
447   AtomicString http_content_type_;
448   PreviewsState previews_state_;
449   base::Optional<WebOriginPolicy> origin_policy_;
450   const scoped_refptr<const SecurityOrigin> requestor_origin_;
451   const KURL unreachable_url_;
452   std::unique_ptr<WebNavigationBodyLoader> body_loader_;
453   const network::mojom::IPAddressSpace ip_address_space_ =
454       network::mojom::IPAddressSpace::kUnknown;
455   const bool grant_load_local_resources_ = false;
456   const base::Optional<blink::mojom::FetchCacheMode> force_fetch_cache_mode_;
457   const FramePolicy frame_policy_;
458 
459   Member<LocalFrame> frame_;
460 
461   Member<HistoryItem> history_item_;
462 
463   // The parser that was created when the current Document was installed.
464   // document.open() may create a new parser at a later point, but this
465   // will not be updated.
466   Member<DocumentParser> parser_;
467 
468   Member<SubresourceFilter> subresource_filter_;
469 
470   // Stores the resource loading hints for this document.
471   Member<PreviewsResourceLoadingHints> resource_loading_hints_;
472 
473   // A reference to actual request's url and referrer used to
474   // inititate this load.
475   KURL original_url_;
476   const Referrer original_referrer_;
477 
478   ResourceResponse response_;
479 
480   WebFrameLoadType load_type_;
481 
482   bool is_client_redirect_;
483   bool replaces_current_history_item_;
484   bool data_received_;
485 
486   const Member<ContentSecurityPolicy> content_security_policy_;
487   const bool was_blocked_by_csp_;
488   mojo::Remote<mojom::blink::ContentSecurityNotifier>
489       content_security_notifier_;
490 
491   const scoped_refptr<SecurityOrigin> origin_to_commit_;
492   WebNavigationType navigation_type_;
493 
494   DocumentLoadTiming document_load_timing_;
495 
496   base::TimeTicks time_of_last_data_received_;
497 
498   Member<ApplicationCacheHostForFrame> application_cache_host_;
499 
500   std::unique_ptr<WebServiceWorkerNetworkProvider>
501       service_worker_network_provider_;
502 
503   DocumentPolicy::ParsedDocumentPolicy document_policy_;
504   bool was_blocked_by_document_policy_;
505   Vector<PolicyParserMessageBuffer::Message> document_policy_parsing_messages_;
506 
507   ClientHintsPreferences client_hints_preferences_;
508   InitialScrollState initial_scroll_state_;
509 
510   enum State { kNotStarted, kProvisional, kCommitted, kSentDidFinishLoad };
511   State state_;
512 
513   // Used to block the parser.
514   int parser_blocked_count_ = 0;
515   bool finish_loading_when_parser_resumed_ = false;
516 
517   // Used to protect against reentrancy into CommitData().
518   bool in_commit_data_;
519   scoped_refptr<SharedBuffer> data_buffer_;
520   const base::UnguessableToken devtools_navigation_token_;
521 
522   WebURLLoader::DeferType defers_loading_ =
523       WebURLLoader::DeferType::kNotDeferred;
524 
525   // Whether this load request comes with a sitcky user activation.
526   const bool had_sticky_activation_ = false;
527   // Whether this load request had a user activation when created.
528   const bool had_transient_activation_ = false;
529 
530   // Whether this load request was initiated by the browser.
531   const bool is_browser_initiated_ = false;
532 
533   // Whether this load request was initiated by the same origin.
534   bool is_same_origin_navigation_ = false;
535 
536   // If true, the navigation loading this document should allow a text fragment
537   // to invoke. This token may be instead consumed to pass this permission
538   // through a redirect.
539   bool has_text_fragment_token_ = false;
540 
541   // See WebNavigationParams for definition.
542   const bool was_discarded_ = false;
543 
544   bool listing_ftp_directory_ = false;
545 
546   // True when loading the main document from the MHTML archive. It implies an
547   // |archive_| to be created. Nested documents will also inherit from the same
548   // |archive_|, but won't have |loading_main_document_from_mhtml_archive_| set.
549   bool loading_main_document_from_mhtml_archive_ = false;
550   const bool loading_srcdoc_ = false;
551   const bool loading_url_as_empty_document_ = false;
552   CommitReason commit_reason_ = CommitReason::kRegular;
553   uint64_t main_resource_identifier_ = 0;
554   scoped_refptr<ResourceTimingInfo> navigation_timing_info_;
555   bool report_timing_info_to_parent_ = false;
556   WebScopedVirtualTimePauser virtual_time_pauser_;
557   Member<SourceKeyedCachedMetadataHandler> cached_metadata_handler_;
558   Member<PrefetchedSignedExchangeManager> prefetched_signed_exchange_manager_;
559   const KURL web_bundle_physical_url_;
560   const KURL web_bundle_claimed_url_;
561   ukm::SourceId ukm_source_id_;
562 
563   // This UseCounterHelper tracks feature usage associated with the lifetime of
564   // the document load. Features recorded prior to commit will be recorded
565   // locally. Once committed, feature usage will be piped to the browser side
566   // page load metrics that aggregates usage from frames to one page load and
567   // report feature usage to UMA histograms per page load.
568   UseCounterHelper use_counter_;
569 
570   Dactyloscoper dactyloscoper_;
571 
572   const base::TickClock* clock_;
573 
574   const Vector<OriginTrialFeature> initiator_origin_trial_features_;
575 
576   const Vector<String> force_enabled_origin_trials_;
577 
578   // Whether the document can be scrolled on load
579   bool navigation_scroll_allowed_ = true;
580 
581   bool origin_isolated_ = false;
582 
583   // Whether this load request is cross browsing context group.
584   bool is_cross_browsing_context_group_navigation_ = false;
585 };
586 
587 DECLARE_WEAK_IDENTIFIER_MAP(DocumentLoader);
588 
589 }  // namespace blink
590 
591 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_DOCUMENT_LOADER_H_
592