blob: 7aa1cfc743799d7e22acd85c3403296227c9af4e [file] [log] [blame]
[email protected]92d457802013-04-01 19:18:491// Copyright (c) 2013 The Chromium Authors. All rights reserved.
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_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_
6#define CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_
7
dchengcedca5612016-04-09 01:40:158#include <memory>
[email protected]e20b88d2013-04-09 15:28:379#include <string>
10
avi1023d012015-12-25 02:39:1411#include "base/macros.h"
[email protected]92d457802013-04-01 19:18:4912#include "base/supports_user_data.h"
Dmitry Gozman1a2cb242018-12-15 02:51:2913#include "net/nqe/effective_connection_type.h"
Richard Lie6899952018-11-30 08:42:0014#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
[email protected]707e1c42013-07-09 21:18:5815#include "url/gurl.h"
[email protected]e20b88d2013-04-09 15:28:3716
[email protected]180ef242013-11-07 06:50:4617namespace blink {
Takeshi Yoshino41b671a2017-08-01 12:17:5118class WebDocumentLoader;
[email protected]92d457802013-04-01 19:18:4919}
20
21namespace content {
22
[email protected]e20b88d2013-04-09 15:28:3723class DocumentState;
Dmitry Gozman0a527132018-09-21 18:01:0424class NavigationState;
[email protected]e20b88d2013-04-09 15:28:3725
Takeshi Yoshino41b671a2017-08-01 12:17:5126// Stores internal state per WebDocumentLoader.
[email protected]92d457802013-04-01 19:18:4927class InternalDocumentStateData : public base::SupportsUserData::Data {
28 public:
29 InternalDocumentStateData();
avicb129c02017-05-03 06:49:2930 ~InternalDocumentStateData() override;
[email protected]92d457802013-04-01 19:18:4931
Takeshi Yoshino41b671a2017-08-01 12:17:5132 static InternalDocumentStateData* FromDocumentLoader(
33 blink::WebDocumentLoader* document_loader);
[email protected]e20b88d2013-04-09 15:28:3734 static InternalDocumentStateData* FromDocumentState(DocumentState* ds);
[email protected]92d457802013-04-01 19:18:4935
Dmitry Gozman0a527132018-09-21 18:01:0436 void CopyFrom(InternalDocumentStateData* other);
37
[email protected]e20b88d2013-04-09 15:28:3738 // True if the user agent was overridden for this page.
39 bool is_overriding_user_agent() const { return is_overriding_user_agent_; }
40 void set_is_overriding_user_agent(bool state) {
41 is_overriding_user_agent_ = state;
42 }
43
44 // True if we have to reset the scroll and scale state of the page
45 // after the provisional load has been committed.
46 bool must_reset_scroll_and_scale_state() const {
47 return must_reset_scroll_and_scale_state_;
48 }
49 void set_must_reset_scroll_and_scale_state(bool state) {
50 must_reset_scroll_and_scale_state_ = state;
51 }
52
Dmitry Gozman1a2cb242018-12-15 02:51:2953 net::EffectiveConnectionType effective_connection_type() const {
54 return effective_connection_type_;
55 }
56 void set_effective_connection_type(
57 net::EffectiveConnectionType effective_connection_type) {
58 effective_connection_type_ = effective_connection_type;
59 }
60
Dmitry Gozman00fd5bb2019-01-25 20:25:3361 // This is a fake navigation request id, which we send to the browser process
62 // together with metrics. Note that renderer does not actually issue a request
63 // for navigation (browser does it instead), but still reports metrics for it.
64 // See content::mojom::ResourceLoadInfo.
65 int request_id() const { return request_id_; }
66 void set_request_id(int request_id) { request_id_ = request_id; }
67
Dmitry Gozman0a527132018-09-21 18:01:0468 NavigationState* navigation_state() { return navigation_state_.get(); }
69 void set_navigation_state(std::unique_ptr<NavigationState> navigation_state);
70
[email protected]92d457802013-04-01 19:18:4971 private:
[email protected]e20b88d2013-04-09 15:28:3772 bool is_overriding_user_agent_;
73 bool must_reset_scroll_and_scale_state_;
Dmitry Gozman1a2cb242018-12-15 02:51:2974 net::EffectiveConnectionType effective_connection_type_ =
75 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
Dmitry Gozman00fd5bb2019-01-25 20:25:3376 int request_id_ = -1;
Dmitry Gozman0a527132018-09-21 18:01:0477 std::unique_ptr<NavigationState> navigation_state_;
[email protected]92d457802013-04-01 19:18:4978
79 DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData);
80};
81
82} // namespace content
83
84#endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_