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 const std::string
& frame_to_navigate
,
170 base::Time request_time
,
171 const PageState
& page_state
,
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();
179 // Whether or not the user agent override string should be used.
180 bool is_overriding_user_agent
;
182 // The navigationStart time to expose through the Navigation Timing API to JS.
183 base::TimeTicks browser_navigation_start
;
185 // Any redirect URLs that occurred before |url|. Useful for cross-process
186 // navigations; defaults to empty.
187 std::vector
<GURL
> redirects
;
189 // Whether or not this url should be allowed to access local file://
191 bool can_load_local_resources
;
193 // If not empty, which frame to navigate.
194 std::string frame_to_navigate
;
196 // The time the request was created. This is used by the old performance
197 // infrastructure to set up DocumentState associated with the RenderView.
198 // TODO(ppi): make it go away.
199 base::Time request_time
;
201 // Opaque history state (received by ViewHostMsg_UpdateState).
202 PageState page_state
;
204 // The page_id for this navigation, or -1 if it is a new navigation. Back,
205 // Forward, and Reload navigations should have a valid page_id. If the load
206 // succeeds, then this page_id will be reflected in the resultant
207 // FrameHostMsg_DidCommitProvisionalLoad message.
210 // For history navigations, this is the offset in the history list of the
211 // pending load. For non-history navigations, this will be ignored.
212 int pending_history_list_offset
;
214 // Where its current page contents reside in session history and the total
215 // size of the session history list.
216 int current_history_list_offset
;
217 int current_history_list_length
;
219 // Whether session history should be cleared. In that case, the RenderView
220 // needs to notify the browser that the clearing was succesful when the
221 // navigation commits.
222 bool should_clear_history_list
;
225 // Helper struct keeping track in one place of all the parameters the browser
226 // needs to provide to the renderer.
227 struct NavigationParams
{
228 NavigationParams(const CommonNavigationParams
& common_params
,
229 const StartNavigationParams
& start_params
,
230 const RequestNavigationParams
& request_params
);
233 CommonNavigationParams common_params
;
234 StartNavigationParams start_params
;
235 RequestNavigationParams request_params
;
238 } // namespace content
240 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_