OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #endif | 181 #endif |
182 | 182 |
183 ViewMsg_Navigate_Type::Value GetNavigationType( | 183 ViewMsg_Navigate_Type::Value GetNavigationType( |
184 content::BrowserContext* browser_context, const NavigationEntryImpl& entry, | 184 content::BrowserContext* browser_context, const NavigationEntryImpl& entry, |
185 NavigationController::ReloadType reload_type) { | 185 NavigationController::ReloadType reload_type) { |
186 switch (reload_type) { | 186 switch (reload_type) { |
187 case NavigationControllerImpl::RELOAD: | 187 case NavigationControllerImpl::RELOAD: |
188 return ViewMsg_Navigate_Type::RELOAD; | 188 return ViewMsg_Navigate_Type::RELOAD; |
189 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: | 189 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |
190 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 190 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 191 case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: |
| 192 return ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
191 case NavigationControllerImpl::NO_RELOAD: | 193 case NavigationControllerImpl::NO_RELOAD: |
192 break; // Fall through to rest of function. | 194 break; // Fall through to rest of function. |
193 } | 195 } |
194 | 196 |
195 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates | 197 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates |
196 // between |RESTORE_WITH_POST| and |RESTORE|. | 198 // between |RESTORE_WITH_POST| and |RESTORE|. |
197 if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && | 199 if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && |
198 browser_context->DidLastSessionExitCleanly()) { | 200 browser_context->DidLastSessionExitCleanly()) { |
199 if (entry.GetHasPostData()) | 201 if (entry.GetHasPostData()) |
200 return ViewMsg_Navigate_Type::RESTORE_WITH_POST; | 202 return ViewMsg_Navigate_Type::RESTORE_WITH_POST; |
201 return ViewMsg_Navigate_Type::RESTORE; | 203 return ViewMsg_Navigate_Type::RESTORE; |
202 } | 204 } |
203 | 205 |
204 return ViewMsg_Navigate_Type::NORMAL; | 206 return ViewMsg_Navigate_Type::NORMAL; |
205 } | 207 } |
206 | 208 |
207 void MakeNavigateParams(const NavigationEntryImpl& entry, | 209 void MakeNavigateParams(const NavigationEntryImpl& entry, |
208 const NavigationControllerImpl& controller, | 210 const NavigationControllerImpl& controller, |
209 content::WebContentsDelegate* delegate, | 211 content::WebContentsDelegate* delegate, |
210 NavigationController::ReloadType reload_type, | 212 NavigationController::ReloadType reload_type, |
211 const std::string& embedder_channel_name, | 213 const std::string& embedder_channel_name, |
212 int embedder_container_id, | 214 int embedder_container_id, |
213 ViewMsg_Navigate_Params* params) { | 215 ViewMsg_Navigate_Params* params) { |
214 params->page_id = entry.GetPageID(); | 216 params->page_id = entry.GetPageID(); |
215 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 217 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
216 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); | 218 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); |
217 params->current_history_list_length = controller.GetEntryCount(); | 219 params->current_history_list_length = controller.GetEntryCount(); |
218 params->url = entry.GetURL(); | |
219 params->referrer = entry.GetReferrer(); | 220 params->referrer = entry.GetReferrer(); |
220 params->transition = entry.GetTransitionType(); | 221 params->transition = entry.GetTransitionType(); |
221 params->state = entry.GetContentState(); | 222 params->state = entry.GetContentState(); |
222 params->navigation_type = | 223 params->navigation_type = |
223 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 224 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); |
224 params->request_time = base::Time::Now(); | 225 params->request_time = base::Time::Now(); |
225 params->extra_headers = entry.extra_headers(); | 226 params->extra_headers = entry.extra_headers(); |
226 params->transferred_request_child_id = | 227 params->transferred_request_child_id = |
227 entry.transferred_global_request_id().child_id; | 228 entry.transferred_global_request_id().child_id; |
228 params->transferred_request_request_id = | 229 params->transferred_request_request_id = |
229 entry.transferred_global_request_id().request_id; | 230 entry.transferred_global_request_id().request_id; |
230 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); | 231 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |
231 // Avoid downloading when in view-source mode. | 232 // Avoid downloading when in view-source mode. |
232 params->allow_download = !entry.IsViewSourceMode(); | 233 params->allow_download = !entry.IsViewSourceMode(); |
233 params->embedder_channel_name = embedder_channel_name; | 234 params->embedder_channel_name = embedder_channel_name; |
234 params->embedder_container_id = embedder_container_id; | 235 params->embedder_container_id = embedder_container_id; |
235 | 236 |
| 237 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && |
| 238 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
| 239 // We may have been redirected when navigating to the current URL. |
| 240 // Use the URL the user originally intended to visit, if it's valid and if a |
| 241 // POST wasn't involved; the latter case avoids issues with sending data to |
| 242 // the wrong page. |
| 243 params->url = entry.GetOriginalRequestURL(); |
| 244 } else { |
| 245 params->url = entry.GetURL(); |
| 246 } |
| 247 |
236 if (delegate) | 248 if (delegate) |
237 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 249 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |
238 } | 250 } |
239 | 251 |
240 int GetSwitchValueAsInt( | 252 int GetSwitchValueAsInt( |
241 const CommandLine& command_line, | 253 const CommandLine& command_line, |
242 const std::string& switch_string, | 254 const std::string& switch_string, |
243 int min_value) { | 255 int min_value) { |
244 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 256 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
245 int int_value; | 257 int int_value; |
(...skipping 2834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 browser_plugin_host()->embedder_render_process_host(); | 3092 browser_plugin_host()->embedder_render_process_host(); |
3081 *embedder_container_id = browser_plugin_host()->instance_id(); | 3093 *embedder_container_id = browser_plugin_host()->instance_id(); |
3082 int embedder_process_id = | 3094 int embedder_process_id = |
3083 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3095 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3084 if (embedder_process_id != -1) { | 3096 if (embedder_process_id != -1) { |
3085 *embedder_channel_name = | 3097 *embedder_channel_name = |
3086 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3098 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3087 embedder_process_id); | 3099 embedder_process_id); |
3088 } | 3100 } |
3089 } | 3101 } |
OLD | NEW |