OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 bool NavigatorImpl::NavigateToEntry( | 226 bool NavigatorImpl::NavigateToEntry( |
227 FrameTreeNode* frame_tree_node, | 227 FrameTreeNode* frame_tree_node, |
228 const FrameNavigationEntry& frame_entry, | 228 const FrameNavigationEntry& frame_entry, |
229 const NavigationEntryImpl& entry, | 229 const NavigationEntryImpl& entry, |
230 NavigationController::ReloadType reload_type, | 230 NavigationController::ReloadType reload_type, |
231 bool is_same_document_history_load) { | 231 bool is_same_document_history_load) { |
232 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); | 232 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); |
233 | 233 |
234 // The renderer will reject IPC messages with URLs longer than | 234 // The renderer will reject IPC messages with URLs longer than |
235 // this limit, so don't attempt to navigate with a longer URL. | 235 // this limit, so don't attempt to navigate with a longer URL. |
236 if (frame_entry.url().spec().size() > GetMaxURLChars()) { | 236 if (frame_entry.url().spec().size() > GetMaxURLChars()) { |
Charlie Reis
2015/07/08 23:23:37
There's a lot of frame_entry.url() uses in here th
lfg
2015/07/14 18:58:31
Done.
| |
237 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() | 237 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() |
238 << " characters."; | 238 << " characters."; |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 // This will be used to set the Navigation Timing API navigationStart | 242 // This will be used to set the Navigation Timing API navigationStart |
243 // parameter for browser navigations in new tabs (intents, tabs opened through | 243 // parameter for browser navigations in new tabs (intents, tabs opened through |
244 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 244 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
245 // capture the time needed for the RenderFrameHost initialization. | 245 // capture the time needed for the RenderFrameHost initialization. |
246 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 246 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
247 | 247 |
248 RenderFrameHostManager* manager = frame_tree_node->render_manager(); | 248 RenderFrameHostManager* manager = frame_tree_node->render_manager(); |
249 | 249 |
250 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 250 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
251 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 251 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
252 switches::kEnableBrowserSideNavigation)) { | 252 switches::kEnableBrowserSideNavigation)) { |
253 navigation_data_.reset(new NavigationMetricsData( | 253 navigation_data_.reset(new NavigationMetricsData( |
254 navigation_start, frame_entry.url(), entry.restore_type())); | 254 navigation_start, frame_entry.url(), entry.restore_type())); |
Charlie Reis
2015/07/08 23:23:37
dest_url
lfg
2015/07/14 18:58:31
Done.
| |
255 RequestNavigation(frame_tree_node, frame_entry, entry, reload_type, | 255 RequestNavigation(frame_tree_node, frame_entry, entry, reload_type, |
256 is_same_document_history_load, navigation_start); | 256 is_same_document_history_load, navigation_start); |
257 | 257 |
258 // Notify observers about navigation. | 258 // Notify observers about navigation. |
259 if (delegate_) { | 259 if (delegate_) { |
260 delegate_->DidStartNavigationToPendingEntry(frame_entry.url(), | 260 delegate_->DidStartNavigationToPendingEntry( |
261 reload_type); | 261 frame_tree_node->navigation_request()->common_params().url, |
Charlie Reis
2015/07/08 23:23:37
dest_url
lfg
2015/07/14 18:58:31
Done.
| |
262 reload_type); | |
262 } | 263 } |
263 | 264 |
264 return true; | 265 return true; |
265 } | 266 } |
266 | 267 |
267 RenderFrameHostImpl* dest_render_frame_host = | 268 RenderFrameHostImpl* dest_render_frame_host = |
268 manager->Navigate(frame_entry, entry); | 269 manager->Navigate(frame_entry, entry); |
269 if (!dest_render_frame_host) | 270 if (!dest_render_frame_host) |
270 return false; // Unable to create the desired RenderFrameHost. | 271 return false; // Unable to create the desired RenderFrameHost. |
271 | 272 |
272 // Make sure no code called via RFHM::Navigate clears the pending entry. | 273 // Make sure no code called via RFHM::Navigate clears the pending entry. |
273 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 274 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
274 | 275 |
275 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 276 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
276 // Double check that here. | 277 // Double check that here. |
277 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, | 278 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, |
278 frame_entry.url()); | 279 frame_entry.url()); |
Charlie Reis
2015/07/08 23:23:37
dest_url
lfg
2015/07/14 18:58:31
Done.
| |
279 | 280 |
280 // Notify observers that we will navigate in this RenderFrame. | 281 // Notify observers that we will navigate in this RenderFrame. |
281 if (delegate_) { | 282 if (delegate_) { |
282 delegate_->AboutToNavigateRenderFrame(frame_tree_node->current_frame_host(), | 283 delegate_->AboutToNavigateRenderFrame(frame_tree_node->current_frame_host(), |
283 dest_render_frame_host); | 284 dest_render_frame_host); |
284 } | 285 } |
285 | 286 |
286 // Navigate in the desired RenderFrameHost. | 287 // Navigate in the desired RenderFrameHost. |
287 // We can skip this step in the rare case that this is a transfer navigation | 288 // We can skip this step in the rare case that this is a transfer navigation |
288 // which began in the chosen RenderFrameHost, since the request has already | 289 // which began in the chosen RenderFrameHost, since the request has already |
289 // been issued. In that case, simply resume the response. | 290 // been issued. In that case, simply resume the response. |
290 bool is_transfer_to_same = | 291 bool is_transfer_to_same = |
291 entry.transferred_global_request_id().child_id != -1 && | 292 entry.transferred_global_request_id().child_id != -1 && |
292 entry.transferred_global_request_id().child_id == | 293 entry.transferred_global_request_id().child_id == |
293 dest_render_frame_host->GetProcess()->GetID(); | 294 dest_render_frame_host->GetProcess()->GetID(); |
295 GURL pending_url = frame_entry.url(); | |
294 if (!is_transfer_to_same) { | 296 if (!is_transfer_to_same) { |
295 navigation_data_.reset(new NavigationMetricsData( | 297 navigation_data_.reset(new NavigationMetricsData( |
296 navigation_start, frame_entry.url(), entry.restore_type())); | 298 navigation_start, frame_entry.url(), entry.restore_type())); |
297 // Create the navigation parameters. | 299 // Create the navigation parameters. |
298 FrameMsg_Navigate_Type::Value navigation_type = | 300 FrameMsg_Navigate_Type::Value navigation_type = |
299 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 301 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
302 CommonNavigationParams common_navigation_params = | |
303 entry.ConstructCommonNavigationParams(frame_entry, navigation_type); | |
304 pending_url = common_navigation_params.url; | |
300 dest_render_frame_host->Navigate( | 305 dest_render_frame_host->Navigate( |
301 entry.ConstructCommonNavigationParams(frame_entry, navigation_type), | 306 common_navigation_params, entry.ConstructStartNavigationParams(), |
302 entry.ConstructStartNavigationParams(), | |
303 entry.ConstructRequestNavigationParams( | 307 entry.ConstructRequestNavigationParams( |
304 frame_entry, navigation_start, is_same_document_history_load, | 308 frame_entry, navigation_start, is_same_document_history_load, |
305 controller_->HasCommittedRealLoad(frame_tree_node), | 309 controller_->HasCommittedRealLoad(frame_tree_node), |
306 controller_->GetPendingEntryIndex() == -1, | 310 controller_->GetPendingEntryIndex() == -1, |
307 controller_->GetIndexOfEntry(&entry), | 311 controller_->GetIndexOfEntry(&entry), |
308 controller_->GetLastCommittedEntryIndex(), | 312 controller_->GetLastCommittedEntryIndex(), |
309 controller_->GetEntryCount())); | 313 controller_->GetEntryCount())); |
310 } else { | 314 } else { |
311 // No need to navigate again. Just resume the deferred request. | 315 // No need to navigate again. Just resume the deferred request. |
312 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 316 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
313 entry.transferred_global_request_id()); | 317 entry.transferred_global_request_id()); |
314 } | 318 } |
315 | 319 |
316 // Make sure no code called via RFH::Navigate clears the pending entry. | 320 // Make sure no code called via RFH::Navigate clears the pending entry. |
317 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 321 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
318 | 322 |
319 if (controller_->GetPendingEntryIndex() == -1 && | 323 if (controller_->GetPendingEntryIndex() == -1 && |
320 frame_entry.url().SchemeIs(url::kJavaScriptScheme)) { | 324 frame_entry.url().SchemeIs(url::kJavaScriptScheme)) { |
Charlie Reis
2015/07/08 23:23:37
dest_url
(Not sure if javascript: URLs can actual
lfg
2015/07/14 18:58:31
Done.
| |
321 // If the pending entry index is -1 (which means a new navigation rather | 325 // If the pending entry index is -1 (which means a new navigation rather |
322 // than a history one), and the user typed in a javascript: URL, don't add | 326 // than a history one), and the user typed in a javascript: URL, don't add |
323 // it to the session history. | 327 // it to the session history. |
324 // | 328 // |
325 // This is a hack. What we really want is to avoid adding to the history any | 329 // This is a hack. What we really want is to avoid adding to the history any |
326 // URL that doesn't generate content, and what would be great would be if we | 330 // URL that doesn't generate content, and what would be great would be if we |
327 // had a message from the renderer telling us that a new page was not | 331 // had a message from the renderer telling us that a new page was not |
328 // created. The same message could be used for mailto: URLs and the like. | 332 // created. The same message could be used for mailto: URLs and the like. |
329 return false; | 333 return false; |
330 } | 334 } |
331 | 335 |
332 // Notify observers about navigation. | 336 // Notify observers about navigation. |
333 if (delegate_) { | 337 if (delegate_) { |
334 delegate_->DidStartNavigationToPendingEntry(frame_entry.url(), reload_type); | 338 delegate_->DidStartNavigationToPendingEntry(pending_url, reload_type); |
335 } | 339 } |
336 | 340 |
337 return true; | 341 return true; |
338 } | 342 } |
339 | 343 |
340 bool NavigatorImpl::NavigateToPendingEntry( | 344 bool NavigatorImpl::NavigateToPendingEntry( |
341 FrameTreeNode* frame_tree_node, | 345 FrameTreeNode* frame_tree_node, |
342 const FrameNavigationEntry& frame_entry, | 346 const FrameNavigationEntry& frame_entry, |
343 NavigationController::ReloadType reload_type, | 347 NavigationController::ReloadType reload_type, |
344 bool is_same_document_history_load) { | 348 bool is_same_document_history_load) { |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 908 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
905 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 909 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
906 } | 910 } |
907 controller_->SetPendingEntry(entry.Pass()); | 911 controller_->SetPendingEntry(entry.Pass()); |
908 if (delegate_) | 912 if (delegate_) |
909 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 913 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
910 } | 914 } |
911 } | 915 } |
912 | 916 |
913 } // namespace content | 917 } // namespace content |
OLD | NEW |