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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_NAVIGATION_PARAMS_H_
6 #define CONTENT_COMMON_NAVIGATION_PARAMS_H_
10 #include "base/basictypes.h"
11 #include "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "content/common/frame_message_enums.h"
14 #include "content/public/common/page_state.h"
15 #include "content/public/common/referrer.h"
16 #include "ui/base/page_transition_types.h"
20 class RefCountedMemory
;
25 // The following structures hold parameters used during a navigation. In
26 // particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and
27 // FrameHostMsg_BeginNavigation.
29 // Provided by the browser or the renderer -------------------------------------
31 // Used by all navigation IPCs.
32 struct CONTENT_EXPORT CommonNavigationParams
{
33 CommonNavigationParams();
34 CommonNavigationParams(const GURL
& url
,
35 const Referrer
& referrer
,
36 ui::PageTransition transition
,
37 FrameMsg_Navigate_Type::Value navigation_type
,
39 base::TimeTicks ui_timestamp
,
40 FrameMsg_UILoadMetricsReportType::Value report_type
,
41 const GURL
& base_url_for_data_url
,
42 const GURL
& history_url_for_data_url
);
43 ~CommonNavigationParams();
45 // The URL to navigate to.
46 // PlzNavigate: May be modified when the navigation is ready to commit.
49 // The URL to send in the "Referer" header field. Can be empty if there is
53 // The type of transition.
54 ui::PageTransition transition
;
56 // Type of navigation.
57 FrameMsg_Navigate_Type::Value navigation_type
;
59 // Allows the URL to be downloaded (true by default).
60 // Avoid downloading when in view-source mode.
63 // Timestamp of the user input event that triggered this navigation. Empty if
64 // the navigation was not triggered by clicking on a link or by receiving an
66 base::TimeTicks ui_timestamp
;
68 // The report type to be used when recording the metric using |ui_timestamp|.
69 FrameMsg_UILoadMetricsReportType::Value report_type
;
71 // Base URL for use in Blink's SubstituteData.
72 // Is only used with data: URLs.
73 GURL base_url_for_data_url
;
75 // History URL for use in Blink's SubstituteData.
76 // Is only used with data: URLs.
77 GURL history_url_for_data_url
;
80 // Provided by the renderer ----------------------------------------------------
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).
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.
89 struct CONTENT_EXPORT BeginNavigationParams
{
90 // TODO(clamy): See if it is possible to reuse this in
91 // ResourceMsg_Request_Params.
92 BeginNavigationParams();
93 BeginNavigationParams(std::string method
,
96 bool has_user_gesture
);
98 // The request method: GET, POST, etc.
101 // Additional HTTP request headers.
104 // net::URLRequest load flags (net::LOAD_NORMAL) by default).
107 // True if the request was user initiated.
108 bool has_user_gesture
;
111 // Provided by the browser -----------------------------------------------------
113 // These structs are sent by the browser to the renderer to start/commit a
114 // navigation depending on whether browser-side navigation is enabled.
115 // Parameters used both in the current architecture and PlzNavigate should be
116 // put in RequestNavigationParams. Parameters only used by the current
117 // architecture should go in StartNavigationParams.
119 // Used by FrameMsg_Navigate. Holds the parameters needed by the renderer to
120 // start a browser-initiated navigation besides those in CommonNavigationParams.
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
124 // PlzNavigate: These are not used.
125 struct CONTENT_EXPORT StartNavigationParams
{
126 StartNavigationParams();
127 StartNavigationParams(
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();
136 // Whether the navigation is a POST request (as opposed to a GET).
139 // Extra headers (separated by \n) to send during the request.
140 std::string extra_headers
;
142 // If is_post is true, holds the post_data information from browser. Empty
144 std::vector
<unsigned char> browser_initiated_post_data
;
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
;
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
;
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 base::Time request_time
,
170 const PageState
& page_state
,
173 bool has_committed_real_load
,
174 bool intended_as_new_entry
,
175 int pending_history_list_offset
,
176 int current_history_list_offset
,
177 int current_history_list_length
,
178 bool should_clear_history_list
);
179 ~RequestNavigationParams();
181 // Whether or not the user agent override string should be used.
182 bool is_overriding_user_agent
;
184 // The navigationStart time to expose through the Navigation Timing API to JS.
185 base::TimeTicks browser_navigation_start
;
187 // Any redirect URLs that occurred before |url|. Useful for cross-process
188 // navigations; defaults to empty.
189 std::vector
<GURL
> redirects
;
191 // Whether or not this url should be allowed to access local file://
193 bool can_load_local_resources
;
195 // The time the request was created. This is used by the old performance
196 // infrastructure to set up DocumentState associated with the RenderView.
197 // TODO(ppi): make it go away.
198 base::Time request_time
;
200 // Opaque history state (received by ViewHostMsg_UpdateState).
201 PageState page_state
;
203 // The page_id for this navigation, or -1 if it is a new navigation. Back,
204 // Forward, and Reload navigations should have a valid page_id. If the load
205 // succeeds, then this page_id will be reflected in the resultant
206 // FrameHostMsg_DidCommitProvisionalLoad message.
209 // For browser-initiated navigations, this is the unique id of the
210 // NavigationEntry being navigated to. (For renderer-initiated navigations it
211 // is 0.) If the load succeeds, then this nav_entry_id will be reflected in
212 // the resulting FrameHostMsg_DidCommitProvisionalLoad message.
215 // Whether the frame being navigated has already committed a real page, which
216 // affects how new navigations are classified in the renderer process.
217 // This currently is only ever set to true in --site-per-process mode.
218 // TODO(creis): Create FrameNavigationEntries by default so this always works.
219 bool has_committed_real_load
;
221 // For browser-initiated navigations, this is true if this is a new entry
222 // being navigated to. This is false otherwise. TODO(avi): Remove this when
223 // the pending entry situation is made sane and the browser keeps them around
224 // long enough to match them via nav_entry_id, above.
225 bool intended_as_new_entry
;
227 // For history navigations, this is the offset in the history list of the
228 // pending load. For non-history navigations, this will be ignored.
229 int pending_history_list_offset
;
231 // Where its current page contents reside in session history and the total
232 // size of the session history list.
233 int current_history_list_offset
;
234 int current_history_list_length
;
236 // Whether session history should be cleared. In that case, the RenderView
237 // needs to notify the browser that the clearing was succesful when the
238 // navigation commits.
239 bool should_clear_history_list
;
242 // Helper struct keeping track in one place of all the parameters the browser
243 // needs to provide to the renderer.
244 struct NavigationParams
{
245 NavigationParams(const CommonNavigationParams
& common_params
,
246 const StartNavigationParams
& start_params
,
247 const RequestNavigationParams
& request_params
);
250 CommonNavigationParams common_params
;
251 StartNavigationParams start_params
;
252 RequestNavigationParams request_params
;
255 } // namespace content
257 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_