| 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 browser ----------------------------------------------------- |
| 80 struct CONTENT_EXPORT BeginNavigationParams { | 81 // |
| 81 // TODO(clamy): See if it is possible to reuse this in | 82 // These structs are sent by the browser to the renderer to start (commit with |
| 82 // ResourceMsg_Request_Params. | 83 // PlzNavigate enabled) a navigation. Parameters used both in the current |
| 83 BeginNavigationParams(); | 84 // architecture and PlzNavigate should be put in CommitNavigationParams. |
| 84 BeginNavigationParams(std::string method, | 85 // Parameters only used by the current architecture should go in |
| 85 std::string headers, | 86 // StartNavigationParams. |
| 86 int load_flags, | |
| 87 bool has_user_gesture); | |
| 88 | 87 |
| 89 // The request method: GET, POST, etc. | 88 // Used by FrameMsg_Navigate, holds the parameters needed by the renderer to |
| 90 std::string method; | 89 // start a browser-initiated navigation besides those in CommonNavigationParams. |
| 90 // The difference with the CommitNavigationParams above is that they are only |
| 91 // used in the current architecture of navigation, and will not be used by |
| 92 // PlzNavigate. |
| 93 // PlzNavigate: These are not used. |
| 94 struct CONTENT_EXPORT StartNavigationParams { |
| 95 StartNavigationParams(); |
| 96 StartNavigationParams( |
| 97 bool is_post, |
| 98 const std::string& extra_headers, |
| 99 const std::vector<unsigned char>& browser_initiated_post_data, |
| 100 bool should_replace_current_entry, |
| 101 int transferred_request_child_id, |
| 102 int transferred_request_request_id); |
| 103 ~StartNavigationParams(); |
| 91 | 104 |
| 92 // Additional HTTP request headers. | 105 // Whether the navigation is a POST request (as opposed to a GET). |
| 93 std::string headers; | 106 bool is_post; |
| 94 | 107 |
| 95 // net::URLRequest load flags (net::LOAD_NORMAL) by default). | 108 // Extra headers (separated by \n) to send during the request. |
| 96 int load_flags; | 109 std::string extra_headers; |
| 97 | 110 |
| 98 // True if the request was user initiated. | 111 // If is_post is true, holds the post_data information from browser. Empty |
| 99 bool has_user_gesture; | 112 // otherwise. |
| 113 std::vector<unsigned char> browser_initiated_post_data; |
| 114 |
| 115 // Informs the RenderView the pending navigation should replace the current |
| 116 // history entry when it commits. This is used for cross-process redirects so |
| 117 // the transferred navigation can recover the navigation state. |
| 118 bool should_replace_current_entry; |
| 119 |
| 120 // The following two members identify a previous request that has been |
| 121 // created before this navigation is being transferred to a new render view. |
| 122 // This serves the purpose of recycling the old request. |
| 123 // Unless this refers to a transferred navigation, these values are -1 and -1. |
| 124 int transferred_request_child_id; |
| 125 int transferred_request_request_id; |
| 100 }; | 126 }; |
| 101 | 127 |
| 102 // Used by FrameMsg_Navigate. | 128 // Used by FrameMsg_Navigate, holds the parameters needed by the renderer to |
| 103 // PlzNavigate: sent to the renderer when the navigation is ready to commit. | 129 // start a browser-initiated navigation besides those in CommonNavigationParams. |
| 130 // PlzNavigate: sent to the renderer to commit a navigation. |
| 104 struct CONTENT_EXPORT CommitNavigationParams { | 131 struct CONTENT_EXPORT CommitNavigationParams { |
| 105 CommitNavigationParams(); | 132 CommitNavigationParams(); |
| 106 CommitNavigationParams(bool is_overriding_user_agent, | 133 CommitNavigationParams(bool is_overriding_user_agent, |
| 107 base::TimeTicks navigation_start, | 134 base::TimeTicks navigation_start, |
| 108 const std::vector<GURL>& redirects, | 135 const std::vector<GURL>& redirects, |
| 109 bool can_load_local_resources, | 136 bool can_load_local_resources, |
| 110 const std::string& frame_to_navigate, | 137 const std::string& frame_to_navigate, |
| 111 base::Time request_time); | 138 base::Time request_time, |
| 139 const PageState& page_state, |
| 140 int32 page_id, |
| 141 int pending_history_list_offset, |
| 142 int current_history_list_offset, |
| 143 int current_history_list_length, |
| 144 bool should_clear_history_list); |
| 112 ~CommitNavigationParams(); | 145 ~CommitNavigationParams(); |
| 113 | 146 |
| 114 // Whether or not the user agent override string should be used. | 147 // Whether or not the user agent override string should be used. |
| 115 bool is_overriding_user_agent; | 148 bool is_overriding_user_agent; |
| 116 | 149 |
| 117 // The navigationStart time to expose through the Navigation Timing API to JS. | 150 // The navigationStart time to expose through the Navigation Timing API to JS. |
| 118 base::TimeTicks browser_navigation_start; | 151 base::TimeTicks browser_navigation_start; |
| 119 | 152 |
| 120 // Any redirect URLs that occurred before |url|. Useful for cross-process | 153 // Any redirect URLs that occurred before |url|. Useful for cross-process |
| 121 // navigations; defaults to empty. | 154 // navigations; defaults to empty. |
| 122 std::vector<GURL> redirects; | 155 std::vector<GURL> redirects; |
| 123 | 156 |
| 124 // Whether or not this url should be allowed to access local file:// | 157 // Whether or not this url should be allowed to access local file:// |
| 125 // resources. | 158 // resources. |
| 126 bool can_load_local_resources; | 159 bool can_load_local_resources; |
| 127 | 160 |
| 128 // If not empty, which frame to navigate. | 161 // If not empty, which frame to navigate. |
| 129 std::string frame_to_navigate; | 162 std::string frame_to_navigate; |
| 130 | 163 |
| 131 // The time the request was created. This is used by the old performance | 164 // The time the request was created. This is used by the old performance |
| 132 // infrastructure to set up DocumentState associated with the RenderView. | 165 // infrastructure to set up DocumentState associated with the RenderView. |
| 133 // TODO(ppi): make it go away. | 166 // TODO(ppi): make it go away. |
| 134 base::Time request_time; | 167 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 | 168 |
| 149 // Opaque history state (received by ViewHostMsg_UpdateState). | 169 // Opaque history state (received by ViewHostMsg_UpdateState). |
| 150 PageState page_state; | 170 PageState page_state; |
| 151 | 171 |
| 152 // The page_id for this navigation, or -1 if it is a new navigation. Back, | 172 // 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 | 173 // 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 | 174 // succeeds, then this page_id will be reflected in the resultant |
| 155 // FrameHostMsg_DidCommitProvisionalLoad message. | 175 // FrameHostMsg_DidCommitProvisionalLoad message. |
| 156 int32 page_id; | 176 int32 page_id; |
| 157 | 177 |
| 158 // For history navigations, this is the offset in the history list of the | 178 // For history navigations, this is the offset in the history list of the |
| 159 // pending load. For non-history navigations, this will be ignored. | 179 // pending load. For non-history navigations, this will be ignored. |
| 160 int pending_history_list_offset; | 180 int pending_history_list_offset; |
| 161 | 181 |
| 162 // Where its current page contents reside in session history and the total | 182 // Where its current page contents reside in session history and the total |
| 163 // size of the session history list. | 183 // size of the session history list. |
| 164 int current_history_list_offset; | 184 int current_history_list_offset; |
| 165 int current_history_list_length; | 185 int current_history_list_length; |
| 166 | 186 |
| 167 // Whether session history should be cleared. In that case, the RenderView | 187 // Whether session history should be cleared. In that case, the RenderView |
| 168 // needs to notify the browser that the clearing was succesful when the | 188 // needs to notify the browser that the clearing was succesful when the |
| 169 // navigation commits. | 189 // navigation commits. |
| 170 bool should_clear_history_list; | 190 bool should_clear_history_list; |
| 171 }; | 191 }; |
| 172 | 192 |
| 173 // Parameters needed at the start of a navigation. Used by FrameMsg_Navigate. | 193 // Helper struct keeping track in one place of all parameters the browser need |
| 174 // PlzNavigate: these parameters are not used in navigation. | 194 // 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 { | 195 struct NavigationParams { |
| 210 NavigationParams(const CommonNavigationParams& common_params, | 196 NavigationParams(const CommonNavigationParams& common_params, |
| 211 const StartNavigationParams& start_params, | 197 const StartNavigationParams& start_params, |
| 212 const CommitNavigationParams& commit_params, | 198 const CommitNavigationParams& commit_params); |
| 213 const HistoryNavigationParams& history_params); | |
| 214 ~NavigationParams(); | 199 ~NavigationParams(); |
| 215 | 200 |
| 216 CommonNavigationParams common_params; | 201 CommonNavigationParams common_params; |
| 217 StartNavigationParams start_params; | 202 StartNavigationParams start_params; |
| 218 CommitNavigationParams commit_params; | 203 CommitNavigationParams commit_params; |
| 219 HistoryNavigationParams history_params; | |
| 220 }; | 204 }; |
| 205 |
| 206 // Provided by the renderer ---------------------------------------------------- |
| 207 // |
| 208 // This struct holds parameters sent by the renderer to the browser. It is only |
| 209 // used in PlzNavigate (since in the current architecture, the renderer does not |
| 210 // inform the browser of navigations until they commit). |
| 211 |
| 212 // This struct is not used outside of the PlzNavigate project. |
| 213 // PlzNavigate: parameters needed to start a navigation on the IO thread, |
| 214 // following a renderer-initiated navigation request. |
| 215 struct CONTENT_EXPORT BeginNavigationParams { |
| 216 // TODO(clamy): See if it is possible to reuse this in |
| 217 // ResourceMsg_Request_Params. |
| 218 BeginNavigationParams(); |
| 219 BeginNavigationParams(std::string method, |
| 220 std::string headers, |
| 221 int load_flags, |
| 222 bool has_user_gesture); |
| 223 |
| 224 // The request method: GET, POST, etc. |
| 225 std::string method; |
| 226 |
| 227 // Additional HTTP request headers. |
| 228 std::string headers; |
| 229 |
| 230 // net::URLRequest load flags (net::LOAD_NORMAL) by default). |
| 231 int load_flags; |
| 232 |
| 233 // True if the request was user initiated. |
| 234 bool has_user_gesture; |
| 235 }; |
| 236 |
| 221 } // namespace content | 237 } // namespace content |
| 222 | 238 |
| 223 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_ | 239 #endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_ |
| OLD | NEW |