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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 int error_code, | 314 int error_code, |
315 const base::string16& error_description) { | 315 const base::string16& error_description) { |
316 if (delegate_) { | 316 if (delegate_) { |
317 delegate_->DidFailLoadWithError( | 317 delegate_->DidFailLoadWithError( |
318 render_frame_host, url, error_code, | 318 render_frame_host, url, error_code, |
319 error_description); | 319 error_description); |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 bool NavigatorImpl::NavigateToEntry( | 323 bool NavigatorImpl::NavigateToEntry( |
324 RenderFrameHostImpl* render_frame_host, | 324 FrameTreeNode* frame_tree_node, |
325 const NavigationEntryImpl& entry, | 325 const NavigationEntryImpl& entry, |
326 NavigationController::ReloadType reload_type) { | 326 NavigationController::ReloadType reload_type) { |
327 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); | 327 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); |
328 | 328 |
329 // The renderer will reject IPC messages with URLs longer than | 329 // The renderer will reject IPC messages with URLs longer than |
330 // this limit, so don't attempt to navigate with a longer URL. | 330 // this limit, so don't attempt to navigate with a longer URL. |
331 if (entry.GetURL().spec().size() > GetMaxURLChars()) { | 331 if (entry.GetURL().spec().size() > GetMaxURLChars()) { |
332 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() | 332 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() |
333 << " characters."; | 333 << " characters."; |
334 return false; | 334 return false; |
335 } | 335 } |
336 | 336 |
337 // This will be used to set the Navigation Timing API navigationStart | 337 // This will be used to set the Navigation Timing API navigationStart |
338 // parameter for browser navigations in new tabs (intents, tabs opened through | 338 // parameter for browser navigations in new tabs (intents, tabs opened through |
339 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 339 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
340 // capture the time needed for the RenderFrameHost initialization. | 340 // capture the time needed for the RenderFrameHost initialization. |
341 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 341 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
342 | 342 |
343 RenderFrameHostManager* manager = | 343 RenderFrameHostManager* manager = frame_tree_node->render_manager(); |
344 render_frame_host->frame_tree_node()->render_manager(); | |
345 | 344 |
346 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 345 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
347 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 346 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
348 switches::kEnableBrowserSideNavigation)) { | 347 switches::kEnableBrowserSideNavigation)) { |
349 navigation_data_.reset(new NavigationMetricsData( | 348 navigation_data_.reset(new NavigationMetricsData( |
350 navigation_start, entry.GetURL(), entry.restore_type())); | 349 navigation_start, entry.GetURL(), entry.restore_type())); |
351 RequestNavigation(render_frame_host->frame_tree_node(), | 350 RequestNavigation(frame_tree_node, entry, reload_type, navigation_start); |
352 entry, | |
353 reload_type, | |
354 navigation_start); | |
355 return true; | 351 return true; |
356 } | 352 } |
357 | 353 |
358 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); | 354 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); |
359 if (!dest_render_frame_host) | 355 if (!dest_render_frame_host) |
360 return false; // Unable to create the desired RenderFrameHost. | 356 return false; // Unable to create the desired RenderFrameHost. |
361 | 357 |
362 // Make sure no code called via RFHM::Navigate clears the pending entry. | 358 // Make sure no code called via RFHM::Navigate clears the pending entry. |
363 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 359 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
364 | 360 |
365 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 361 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
366 // Double check that here. | 362 // Double check that here. |
367 CheckWebUIRendererDoesNotDisplayNormalURL( | 363 CheckWebUIRendererDoesNotDisplayNormalURL( |
368 dest_render_frame_host, entry.GetURL()); | 364 dest_render_frame_host, entry.GetURL()); |
369 | 365 |
370 // Notify observers that we will navigate in this RenderFrame. | 366 // Notify observers that we will navigate in this RenderFrame. |
371 if (delegate_) { | 367 if (delegate_) { |
372 delegate_->AboutToNavigateRenderFrame(render_frame_host, | 368 delegate_->AboutToNavigateRenderFrame(frame_tree_node->current_frame_host(), |
373 dest_render_frame_host); | 369 dest_render_frame_host); |
374 } | 370 } |
375 | 371 |
376 // Create the navigation parameters. | 372 // Create the navigation parameters. |
377 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once | 373 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once |
378 // http://crbug.com/408684 is fixed. | 374 // http://crbug.com/408684 is fixed. |
379 FrameMsg_Navigate_Params navigate_params; | 375 FrameMsg_Navigate_Params navigate_params; |
380 MakeNavigateParams( | 376 MakeNavigateParams( |
381 entry, controller_, reload_type, navigation_start, &navigate_params); | 377 entry, controller_, reload_type, navigation_start, &navigate_params); |
382 | 378 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 if (delegate_) { | 412 if (delegate_) { |
417 delegate_->DidStartNavigationToPendingEntry(dest_render_frame_host, | 413 delegate_->DidStartNavigationToPendingEntry(dest_render_frame_host, |
418 entry.GetURL(), | 414 entry.GetURL(), |
419 reload_type); | 415 reload_type); |
420 } | 416 } |
421 | 417 |
422 return true; | 418 return true; |
423 } | 419 } |
424 | 420 |
425 bool NavigatorImpl::NavigateToPendingEntry( | 421 bool NavigatorImpl::NavigateToPendingEntry( |
426 RenderFrameHostImpl* render_frame_host, | 422 FrameTreeNode* frame_tree_node, |
427 NavigationController::ReloadType reload_type) { | 423 NavigationController::ReloadType reload_type) { |
428 return NavigateToEntry( | 424 return NavigateToEntry( |
429 render_frame_host, | 425 frame_tree_node, |
430 *NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()), | 426 *NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()), |
431 reload_type); | 427 reload_type); |
432 } | 428 } |
433 | 429 |
434 void NavigatorImpl::DidNavigate( | 430 void NavigatorImpl::DidNavigate( |
435 RenderFrameHostImpl* render_frame_host, | 431 RenderFrameHostImpl* render_frame_host, |
436 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { | 432 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { |
437 // PlzNavigate | 433 // PlzNavigate |
438 // The navigation request has been committed so the browser process doesn't | 434 // The navigation request has been committed so the browser process doesn't |
439 // need to care about it anymore. | 435 // need to care about it anymore. |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 926 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
931 time_to_commit); | 927 time_to_commit); |
932 UMA_HISTOGRAM_TIMES( | 928 UMA_HISTOGRAM_TIMES( |
933 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 929 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
934 time_to_network); | 930 time_to_network); |
935 } | 931 } |
936 navigation_data_.reset(); | 932 navigation_data_.reset(); |
937 } | 933 } |
938 | 934 |
939 } // namespace content | 935 } // namespace content |
OLD | NEW |