OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_NAVIGATION_PARAMS_H_ | 5 #ifndef CONTENT_COMMON_NAVIGATION_PARAMS_H_ |
6 #define CONTENT_COMMON_NAVIGATION_PARAMS_H_ | 6 #define CONTENT_COMMON_NAVIGATION_PARAMS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "content/common/frame_message_enums.h" | 13 #include "content/common/frame_message_enums.h" |
14 #include "content/public/common/page_state.h" | 14 #include "content/public/common/page_state.h" |
15 #include "content/public/common/referrer.h" | 15 #include "content/public/common/referrer.h" |
16 #include "ui/base/page_transition_types.h" | 16 #include "ui/base/page_transition_types.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class RefCountedMemory; | 20 class RefCountedMemory; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 class NavigationEntry; | |
25 | 24 |
26 // The following structures hold parameters used during a navigation. In | 25 // The following structures hold parameters used during a navigation. In |
27 // particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and | 26 // particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and |
28 // FrameHostMsg_BeginNavigation. | 27 // FrameHostMsg_BeginNavigation. |
29 | 28 |
| 29 // Provided by the browser or the renderer ------------------------------------- |
| 30 |
30 // Used by all navigation IPCs. | 31 // Used by all navigation IPCs. |
31 struct CONTENT_EXPORT CommonNavigationParams { | 32 struct CONTENT_EXPORT CommonNavigationParams { |
32 CommonNavigationParams(); | 33 CommonNavigationParams(); |
33 CommonNavigationParams(const GURL& url, | 34 CommonNavigationParams(const GURL& url, |
34 const Referrer& referrer, | 35 const Referrer& referrer, |
35 ui::PageTransition transition, | 36 ui::PageTransition transition, |
36 FrameMsg_Navigate_Type::Value navigation_type, | 37 FrameMsg_Navigate_Type::Value navigation_type, |
37 bool allow_download, | 38 bool allow_download, |
38 base::TimeTicks ui_timestamp, | 39 base::TimeTicks ui_timestamp, |
39 FrameMsg_UILoadMetricsReportType::Value report_type, | 40 FrameMsg_UILoadMetricsReportType::Value report_type, |
(...skipping 29 matching lines...) Expand all Loading... |
69 | 70 |
70 // Base URL for use in Blink's SubstituteData. | 71 // Base URL for use in Blink's SubstituteData. |
71 // Is only used with data: URLs. | 72 // Is only used with data: URLs. |
72 GURL base_url_for_data_url; | 73 GURL base_url_for_data_url; |
73 | 74 |
74 // History URL for use in Blink's SubstituteData. | 75 // History URL for use in Blink's SubstituteData. |
75 // Is only used with data: URLs. | 76 // Is only used with data: URLs. |
76 GURL history_url_for_data_url; | 77 GURL history_url_for_data_url; |
77 }; | 78 }; |
78 | 79 |
79 // PlzNavigate: parameters needed to start a navigation on the IO thread. | 80 // Provided by the renderer ---------------------------------------------------- |
| 81 // |
| 82 // This struct holds parameters sent by the renderer to the browser. It is only |
| 83 // used in PlzNavigate (since in the current architecture, the renderer does not |
| 84 // inform the browser of navigations until they commit). |
| 85 |
| 86 // This struct is not used outside of the PlzNavigate project. |
| 87 // PlzNavigate: parameters needed to start a navigation on the IO thread, |
| 88 // following a renderer-initiated navigation request. |
80 struct CONTENT_EXPORT BeginNavigationParams { | 89 struct CONTENT_EXPORT BeginNavigationParams { |
81 // TODO(clamy): See if it is possible to reuse this in | 90 // TODO(clamy): See if it is possible to reuse this in |
82 // ResourceMsg_Request_Params. | 91 // ResourceMsg_Request_Params. |
83 BeginNavigationParams(); | 92 BeginNavigationParams(); |
84 BeginNavigationParams(std::string method, | 93 BeginNavigationParams(std::string method, |
85 std::string headers, | 94 std::string headers, |
86 int load_flags, | 95 int load_flags, |
87 bool has_user_gesture); | 96 bool has_user_gesture); |
88 | 97 |
89 // The request method: GET, POST, etc. | 98 // The request method: GET, POST, etc. |
90 std::string method; | 99 std::string method; |
91 | 100 |
92 // Additional HTTP request headers. | 101 // Additional HTTP request headers. |
93 std::string headers; | 102 std::string headers; |
94 | 103 |
95 // net::URLRequest load flags (net::LOAD_NORMAL) by default). | 104 // net::URLRequest load flags (net::LOAD_NORMAL) by default). |
96 int load_flags; | 105 int load_flags; |
97 | 106 |
98 // True if the request was user initiated. | 107 // True if the request was user initiated. |
99 bool has_user_gesture; | 108 bool has_user_gesture; |
100 }; | 109 }; |
101 | 110 |
102 // Used by FrameMsg_Navigate. | 111 // Provided by the browser ----------------------------------------------------- |
103 // PlzNavigate: sent to the renderer when the navigation is ready to commit. | 112 // |
104 struct CONTENT_EXPORT CommitNavigationParams { | 113 // These structs are sent by the browser to the renderer to start/commit a |
105 CommitNavigationParams(); | 114 // navigation depending on whether browser-side navigation is enabled. |
106 CommitNavigationParams(bool is_overriding_user_agent, | 115 // Parameters used both in the current architecture and PlzNavigate should be |
107 base::TimeTicks navigation_start, | 116 // put in RequestNavigationParams. Parameters only used by the current |
108 const std::vector<GURL>& redirects, | 117 // architecture should go in StartNavigationParams. |
109 bool can_load_local_resources, | 118 |
110 const std::string& frame_to_navigate, | 119 // Used by FrameMsg_Navigate. Holds the parameters needed by the renderer to |
111 base::Time request_time); | 120 // start a browser-initiated navigation besides those in CommonNavigationParams. |
112 ~CommitNavigationParams(); | 121 // The difference with the RequestNavigationParams below is that they are only |
| 122 // used in the current architecture of navigation, and will not be used by |
| 123 // PlzNavigate. |
| 124 // PlzNavigate: These are not used. |
| 125 struct CONTENT_EXPORT StartNavigationParams { |
| 126 StartNavigationParams(); |
| 127 StartNavigationParams( |
| 128 bool is_post, |
| 129 const std::string& extra_headers, |
| 130 const std::vector<unsigned char>& browser_initiated_post_data, |
| 131 bool should_replace_current_entry, |
| 132 int transferred_request_child_id, |
| 133 int transferred_request_request_id); |
| 134 ~StartNavigationParams(); |
| 135 |
| 136 // Whether the navigation is a POST request (as opposed to a GET). |
| 137 bool is_post; |
| 138 |
| 139 // Extra headers (separated by \n) to send during the request. |
| 140 std::string extra_headers; |
| 141 |
| 142 // If is_post is true, holds the post_data information from browser. Empty |
| 143 // otherwise. |
| 144 std::vector<unsigned char> browser_initiated_post_data; |
| 145 |
| 146 // Informs the RenderView the pending navigation should replace the current |
| 147 // history entry when it commits. This is used for cross-process redirects so |
| 148 // the transferred navigation can recover the navigation state. |
| 149 bool should_replace_current_entry; |
| 150 |
| 151 // The following two members identify a previous request that has been |
| 152 // created before this navigation is being transferred to a new render view. |
| 153 // This serves the purpose of recycling the old request. |
| 154 // Unless this refers to a transferred navigation, these values are -1 and -1. |
| 155 int transferred_request_child_id; |
| 156 int transferred_request_request_id; |
| 157 }; |
| 158 |
| 159 // Used by FrameMsg_Navigate. Holds the parameters needed by the renderer to |
| 160 // start a browser-initiated navigation besides those in CommonNavigationParams. |
| 161 // PlzNavigate: sent to the renderer to make it issue a stream request for a |
| 162 // navigation that is ready to commit. |
| 163 struct CONTENT_EXPORT RequestNavigationParams { |
| 164 RequestNavigationParams(); |
| 165 RequestNavigationParams(bool is_overriding_user_agent, |
| 166 base::TimeTicks navigation_start, |
| 167 const std::vector<GURL>& redirects, |
| 168 bool can_load_local_resources, |
| 169 const std::string& frame_to_navigate, |
| 170 base::Time request_time, |
| 171 const PageState& page_state, |
| 172 int32 page_id, |
| 173 int pending_history_list_offset, |
| 174 int current_history_list_offset, |
| 175 int current_history_list_length, |
| 176 bool should_clear_history_list); |
| 177 ~RequestNavigationParams(); |
113 | 178 |
114 // Whether or not the user agent override string should be used. | 179 // Whether or not the user agent override string should be used. |
115 bool is_overriding_user_agent; | 180 bool is_overriding_user_agent; |
116 | 181 |
117 // The navigationStart time to expose through the Navigation Timing API to JS. | 182 // The navigationStart time to expose through the Navigation Timing API to JS. |
118 base::TimeTicks browser_navigation_start; | 183 base::TimeTicks browser_navigation_start; |
119 | 184 |
120 // Any redirect URLs that occurred before |url|. Useful for cross-process | 185 // Any redirect URLs that occurred before |url|. Useful for cross-process |
121 // navigations; defaults to empty. | 186 // navigations; defaults to empty. |
122 std::vector<GURL> redirects; | 187 std::vector<GURL> redirects; |
123 | 188 |
124 // Whether or not this url should be allowed to access local file:// | 189 // Whether or not this url should be allowed to access local file:// |
125 // resources. | 190 // resources. |
126 bool can_load_local_resources; | 191 bool can_load_local_resources; |
127 | 192 |
128 // If not empty, which frame to navigate. | 193 // If not empty, which frame to navigate. |
129 std::string frame_to_navigate; | 194 std::string frame_to_navigate; |
130 | 195 |
131 // The time the request was created. This is used by the old performance | 196 // The time the request was created. This is used by the old performance |
132 // infrastructure to set up DocumentState associated with the RenderView. | 197 // infrastructure to set up DocumentState associated with the RenderView. |
133 // TODO(ppi): make it go away. | 198 // TODO(ppi): make it go away. |
134 base::Time request_time; | 199 base::Time request_time; |
135 }; | |
136 | |
137 // Used by FrameMsg_Navigate. | |
138 // PlzNavigate: sent to the renderer when the navigation is ready to commit. | |
139 struct CONTENT_EXPORT HistoryNavigationParams { | |
140 HistoryNavigationParams(); | |
141 HistoryNavigationParams(const PageState& page_state, | |
142 int32 page_id, | |
143 int pending_history_list_offset, | |
144 int current_history_list_offset, | |
145 int current_history_list_length, | |
146 bool should_clear_history_list); | |
147 ~HistoryNavigationParams(); | |
148 | 200 |
149 // Opaque history state (received by ViewHostMsg_UpdateState). | 201 // Opaque history state (received by ViewHostMsg_UpdateState). |
150 PageState page_state; | 202 PageState page_state; |
151 | 203 |
152 // The page_id for this navigation, or -1 if it is a new navigation. Back, | 204 // The page_id for this navigation, or -1 if it is a new navigation. Back, |
153 // Forward, and Reload navigations should have a valid page_id. If the load | 205 // Forward, and Reload navigations should have a valid page_id. If the load |
154 // succeeds, then this page_id will be reflected in the resultant | 206 // succeeds, then this page_id will be reflected in the resultant |
155 // FrameHostMsg_DidCommitProvisionalLoad message. | 207 // FrameHostMsg_DidCommitProvisionalLoad message. |
156 int32 page_id; | 208 int32 page_id; |
157 | 209 |
158 // For history navigations, this is the offset in the history list of the | 210 // For history navigations, this is the offset in the history list of the |
159 // pending load. For non-history navigations, this will be ignored. | 211 // pending load. For non-history navigations, this will be ignored. |
160 int pending_history_list_offset; | 212 int pending_history_list_offset; |
161 | 213 |
162 // Where its current page contents reside in session history and the total | 214 // Where its current page contents reside in session history and the total |
163 // size of the session history list. | 215 // size of the session history list. |
164 int current_history_list_offset; | 216 int current_history_list_offset; |
165 int current_history_list_length; | 217 int current_history_list_length; |
166 | 218 |
167 // Whether session history should be cleared. In that case, the RenderView | 219 // Whether session history should be cleared. In that case, the RenderView |
168 // needs to notify the browser that the clearing was succesful when the | 220 // needs to notify the browser that the clearing was succesful when the |
169 // navigation commits. | 221 // navigation commits. |
170 bool should_clear_history_list; | 222 bool should_clear_history_list; |
171 }; | 223 }; |
172 | 224 |
173 // Parameters needed at the start of a navigation. Used by FrameMsg_Navigate. | 225 // Helper struct keeping track in one place of all the parameters the browser |
174 // PlzNavigate: these parameters are not used in navigation. | 226 // needs to provide to the renderer. |
175 struct CONTENT_EXPORT StartNavigationParams { | |
176 StartNavigationParams(); | |
177 StartNavigationParams( | |
178 bool is_post, | |
179 const std::string& extra_headers, | |
180 const std::vector<unsigned char>& browser_initiated_post_data, | |
181 bool should_replace_current_entry, | |
182 int transferred_request_child_id, | |
183 int transferred_request_request_id); | |
184 ~StartNavigationParams(); | |
185 | |
186 // Whether the navigation is a POST request (as opposed to a GET). | |
187 bool is_post; | |
188 | |
189 // Extra headers (separated by \n) to send during the request. | |
190 std::string extra_headers; | |
191 | |
192 // If is_post is true, holds the post_data information from browser. Empty | |
193 // otherwise. | |
194 std::vector<unsigned char> browser_initiated_post_data; | |
195 | |
196 // Informs the RenderView the pending navigation should replace the current | |
197 // history entry when it commits. This is used for cross-process redirects so | |
198 // the transferred navigation can recover the navigation state. | |
199 bool should_replace_current_entry; | |
200 | |
201 // The following two members identify a previous request that has been | |
202 // created before this navigation is being transferred to a new render view. | |
203 // This serves the purpose of recycling the old request. | |
204 // Unless this refers to a transferred navigation, these values are -1 and -1. | |
205 int transferred_request_child_id; | |
206 int transferred_request_request_id; | |
207 }; | |
208 | |
209 struct NavigationParams { | 227 struct NavigationParams { |
210 NavigationParams(const CommonNavigationParams& common_params, | 228 NavigationParams(const CommonNavigationParams& common_params, |
211 const StartNavigationParams& start_params, | 229 const StartNavigationParams& start_params, |
212 const CommitNavigationParams& commit_params, | 230 const RequestNavigationParams& request_params); |
213 const HistoryNavigationParams& history_params); | |
214 ~NavigationParams(); | 231 ~NavigationParams(); |
215 | 232 |
216 CommonNavigationParams common_params; | 233 CommonNavigationParams common_params; |
217 StartNavigationParams start_params; | 234 StartNavigationParams start_params; |
218 CommitNavigationParams commit_params; | 235 RequestNavigationParams request_params; |
219 HistoryNavigationParams history_params; | |
220 }; | 236 }; |
| 237 |
221 } // namespace content | 238 } // namespace content |
222 | 239 |
223 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_ | 240 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_ |
OLD | NEW |