[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 1 | // 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 | |||||
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 8 | #include <memory> |
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 9 | #include <string> |
10 | |||||
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 12 | #include "base/supports_user_data.h" |
Dmitry Gozman | 1a2cb24 | 2018-12-15 02:51:29 | [diff] [blame] | 13 | #include "net/nqe/effective_connection_type.h" |
Richard Li | e689995 | 2018-11-30 08:42:00 | [diff] [blame] | 14 | #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h" |
[email protected] | 707e1c4 | 2013-07-09 21:18:58 | [diff] [blame] | 15 | #include "url/gurl.h" |
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 16 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 17 | namespace blink { |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 18 | class WebDocumentLoader; |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 19 | } |
20 | |||||
21 | namespace content { | ||||
22 | |||||
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 23 | class DocumentState; |
Dmitry Gozman | 0a52713 | 2018-09-21 18:01:04 | [diff] [blame] | 24 | class NavigationState; |
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 25 | |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 26 | // Stores internal state per WebDocumentLoader. |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 27 | class InternalDocumentStateData : public base::SupportsUserData::Data { |
28 | public: | ||||
29 | InternalDocumentStateData(); | ||||
avi | cb129c0 | 2017-05-03 06:49:29 | [diff] [blame] | 30 | ~InternalDocumentStateData() override; |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 31 | |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 32 | static InternalDocumentStateData* FromDocumentLoader( |
33 | blink::WebDocumentLoader* document_loader); | ||||
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 34 | static InternalDocumentStateData* FromDocumentState(DocumentState* ds); |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 35 | |
Dmitry Gozman | 0a52713 | 2018-09-21 18:01:04 | [diff] [blame] | 36 | void CopyFrom(InternalDocumentStateData* other); |
37 | |||||
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 38 | // 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 Gozman | 1a2cb24 | 2018-12-15 02:51:29 | [diff] [blame] | 53 | 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 Gozman | 00fd5bb | 2019-01-25 20:25:33 | [diff] [blame] | 61 | // 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 Gozman | 0a52713 | 2018-09-21 18:01:04 | [diff] [blame] | 68 | NavigationState* navigation_state() { return navigation_state_.get(); } |
69 | void set_navigation_state(std::unique_ptr<NavigationState> navigation_state); | ||||
70 | |||||
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 71 | private: |
[email protected] | e20b88d | 2013-04-09 15:28:37 | [diff] [blame] | 72 | bool is_overriding_user_agent_; |
73 | bool must_reset_scroll_and_scale_state_; | ||||
Dmitry Gozman | 1a2cb24 | 2018-12-15 02:51:29 | [diff] [blame] | 74 | net::EffectiveConnectionType effective_connection_type_ = |
75 | net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN; | ||||
Dmitry Gozman | 00fd5bb | 2019-01-25 20:25:33 | [diff] [blame] | 76 | int request_id_ = -1; |
Dmitry Gozman | 0a52713 | 2018-09-21 18:01:04 | [diff] [blame] | 77 | std::unique_ptr<NavigationState> navigation_state_; |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 78 | |
79 | DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData); | ||||
80 | }; | ||||
81 | |||||
82 | } // namespace content | ||||
83 | |||||
84 | #endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_ |