Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / common / navigation_params.h
blob1862377868f85c2e92af217f4943068288e519d9
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_
8 #include <string>
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"
17 #include "url/gurl.h"
19 namespace base {
20 class RefCountedMemory;
23 namespace content {
25 // PlzNavigate
26 // Helper function to determine if the navigation to |url| should make a request
27 // to the network stack. A request should not be sent for data URLs, JavaScript
28 // URLs or about:blank. In these cases, no request needs to be sent.
29 bool ShouldMakeNetworkRequestForURL(const GURL& url);
31 // The following structures hold parameters used during a navigation. In
32 // particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and
33 // FrameHostMsg_BeginNavigation.
35 // Provided by the browser or the renderer -------------------------------------
37 // Used by all navigation IPCs.
38 struct CONTENT_EXPORT CommonNavigationParams {
39 CommonNavigationParams();
40 CommonNavigationParams(const GURL& url,
41 const Referrer& referrer,
42 ui::PageTransition transition,
43 FrameMsg_Navigate_Type::Value navigation_type,
44 bool allow_download,
45 bool should_replace_current_entry,
46 base::TimeTicks ui_timestamp,
47 FrameMsg_UILoadMetricsReportType::Value report_type,
48 const GURL& base_url_for_data_url,
49 const GURL& history_url_for_data_url);
50 ~CommonNavigationParams();
52 // The URL to navigate to.
53 // PlzNavigate: May be modified when the navigation is ready to commit.
54 GURL url;
56 // The URL to send in the "Referer" header field. Can be empty if there is
57 // no referrer.
58 Referrer referrer;
60 // The type of transition.
61 ui::PageTransition transition;
63 // Type of navigation.
64 FrameMsg_Navigate_Type::Value navigation_type;
66 // Allows the URL to be downloaded (true by default).
67 // Avoid downloading when in view-source mode.
68 bool allow_download;
70 // Informs the RenderView the pending navigation should replace the current
71 // history entry when it commits. This is used for cross-process redirects so
72 // the transferred navigation can recover the navigation state.
73 // PlzNavigate: this is used by client-side redirects to indicate that when
74 // the navigation commits, it should commit in the existing page.
75 bool should_replace_current_entry;
77 // Timestamp of the user input event that triggered this navigation. Empty if
78 // the navigation was not triggered by clicking on a link or by receiving an
79 // intent on Android.
80 base::TimeTicks ui_timestamp;
82 // The report type to be used when recording the metric using |ui_timestamp|.
83 FrameMsg_UILoadMetricsReportType::Value report_type;
85 // Base URL for use in Blink's SubstituteData.
86 // Is only used with data: URLs.
87 GURL base_url_for_data_url;
89 // History URL for use in Blink's SubstituteData.
90 // Is only used with data: URLs.
91 GURL history_url_for_data_url;
94 // Provided by the renderer ----------------------------------------------------
96 // This struct holds parameters sent by the renderer to the browser. It is only
97 // used in PlzNavigate (since in the current architecture, the renderer does not
98 // inform the browser of navigations until they commit).
100 // This struct is not used outside of the PlzNavigate project.
101 // PlzNavigate: parameters needed to start a navigation on the IO thread,
102 // following a renderer-initiated navigation request.
103 struct CONTENT_EXPORT BeginNavigationParams {
104 // TODO(clamy): See if it is possible to reuse this in
105 // ResourceMsg_Request_Params.
106 BeginNavigationParams();
107 BeginNavigationParams(std::string method,
108 std::string headers,
109 int load_flags,
110 bool has_user_gesture);
112 // The request method: GET, POST, etc.
113 std::string method;
115 // Additional HTTP request headers.
116 std::string headers;
118 // net::URLRequest load flags (net::LOAD_NORMAL) by default).
119 int load_flags;
121 // True if the request was user initiated.
122 bool has_user_gesture;
125 // Provided by the browser -----------------------------------------------------
127 // These structs are sent by the browser to the renderer to start/commit a
128 // navigation depending on whether browser-side navigation is enabled.
129 // Parameters used both in the current architecture and PlzNavigate should be
130 // put in RequestNavigationParams. Parameters only used by the current
131 // architecture should go in StartNavigationParams.
133 // Used by FrameMsg_Navigate. Holds the parameters needed by the renderer to
134 // start a browser-initiated navigation besides those in CommonNavigationParams.
135 // The difference with the RequestNavigationParams below is that they are only
136 // used in the current architecture of navigation, and will not be used by
137 // PlzNavigate.
138 // PlzNavigate: These are not used.
139 struct CONTENT_EXPORT StartNavigationParams {
140 StartNavigationParams();
141 StartNavigationParams(
142 bool is_post,
143 const std::string& extra_headers,
144 const std::vector<unsigned char>& browser_initiated_post_data,
145 int transferred_request_child_id,
146 int transferred_request_request_id);
147 ~StartNavigationParams();
149 // Whether the navigation is a POST request (as opposed to a GET).
150 bool is_post;
152 // Extra headers (separated by \n) to send during the request.
153 std::string extra_headers;
155 // If is_post is true, holds the post_data information from browser. Empty
156 // otherwise.
157 std::vector<unsigned char> browser_initiated_post_data;
159 // The following two members identify a previous request that has been
160 // created before this navigation is being transferred to a new render view.
161 // This serves the purpose of recycling the old request.
162 // Unless this refers to a transferred navigation, these values are -1 and -1.
163 int transferred_request_child_id;
164 int transferred_request_request_id;
167 // Used by FrameMsg_Navigate. Holds the parameters needed by the renderer to
168 // start a browser-initiated navigation besides those in CommonNavigationParams.
169 // PlzNavigate: sent to the renderer to make it issue a stream request for a
170 // navigation that is ready to commit.
171 struct CONTENT_EXPORT RequestNavigationParams {
172 RequestNavigationParams();
173 RequestNavigationParams(bool is_overriding_user_agent,
174 base::TimeTicks navigation_start,
175 const std::vector<GURL>& redirects,
176 bool can_load_local_resources,
177 base::Time request_time,
178 const PageState& page_state,
179 int32 page_id,
180 int nav_entry_id,
181 bool is_same_document_history_load,
182 bool has_committed_real_load,
183 bool intended_as_new_entry,
184 int pending_history_list_offset,
185 int current_history_list_offset,
186 int current_history_list_length,
187 bool should_clear_history_list);
188 ~RequestNavigationParams();
190 // Whether or not the user agent override string should be used.
191 bool is_overriding_user_agent;
193 // The navigationStart time to expose through the Navigation Timing API to JS.
194 base::TimeTicks browser_navigation_start;
196 // Any redirect URLs that occurred before |url|. Useful for cross-process
197 // navigations; defaults to empty.
198 std::vector<GURL> redirects;
200 // Whether or not this url should be allowed to access local file://
201 // resources.
202 bool can_load_local_resources;
204 // The time the request was created. This is used by the old performance
205 // infrastructure to set up DocumentState associated with the RenderView.
206 // TODO(ppi): make it go away.
207 base::Time request_time;
209 // Opaque history state (received by ViewHostMsg_UpdateState).
210 PageState page_state;
212 // The page_id for this navigation, or -1 if it is a new navigation. Back,
213 // Forward, and Reload navigations should have a valid page_id. If the load
214 // succeeds, then this page_id will be reflected in the resultant
215 // FrameHostMsg_DidCommitProvisionalLoad message.
216 int32 page_id;
218 // For browser-initiated navigations, this is the unique id of the
219 // NavigationEntry being navigated to. (For renderer-initiated navigations it
220 // is 0.) If the load succeeds, then this nav_entry_id will be reflected in
221 // the resulting FrameHostMsg_DidCommitProvisionalLoad message.
222 int nav_entry_id;
224 // For history navigations, this indicates whether the load will stay within
225 // the same document. Defaults to false.
226 bool is_same_document_history_load;
228 // Whether the frame being navigated has already committed a real page, which
229 // affects how new navigations are classified in the renderer process.
230 // This currently is only ever set to true in --site-per-process mode.
231 // TODO(creis): Create FrameNavigationEntries by default so this always works.
232 bool has_committed_real_load;
234 // For browser-initiated navigations, this is true if this is a new entry
235 // being navigated to. This is false otherwise. TODO(avi): Remove this when
236 // the pending entry situation is made sane and the browser keeps them around
237 // long enough to match them via nav_entry_id, above.
238 bool intended_as_new_entry;
240 // For history navigations, this is the offset in the history list of the
241 // pending load. For non-history navigations, this will be ignored.
242 int pending_history_list_offset;
244 // Where its current page contents reside in session history and the total
245 // size of the session history list.
246 int current_history_list_offset;
247 int current_history_list_length;
249 // Whether session history should be cleared. In that case, the RenderView
250 // needs to notify the browser that the clearing was succesful when the
251 // navigation commits.
252 bool should_clear_history_list;
255 // Helper struct keeping track in one place of all the parameters the browser
256 // needs to provide to the renderer.
257 struct NavigationParams {
258 NavigationParams(const CommonNavigationParams& common_params,
259 const StartNavigationParams& start_params,
260 const RequestNavigationParams& request_params);
261 ~NavigationParams();
263 CommonNavigationParams common_params;
264 StartNavigationParams start_params;
265 RequestNavigationParams request_params;
268 } // namespace content
270 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_