Chromium Code Reviews| 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, |
|
alexmos
2015/02/20 00:53:47
Nit: seems like it should fit on one line now.
Charlie Reis
2015/02/20 00:58:50
Done.
| |
| 352 entry, | 351 entry, |
| 353 reload_type, | 352 reload_type, |
| 354 navigation_start); | 353 navigation_start); |
| 355 return true; | 354 return true; |
| 356 } | 355 } |
| 357 | 356 |
| 358 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); | 357 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); |
| 359 if (!dest_render_frame_host) | 358 if (!dest_render_frame_host) |
| 360 return false; // Unable to create the desired RenderFrameHost. | 359 return false; // Unable to create the desired RenderFrameHost. |
| 361 | 360 |
| 362 // Make sure no code called via RFHM::Navigate clears the pending entry. | 361 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 363 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 362 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 364 | 363 |
| 365 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 364 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 366 // Double check that here. | 365 // Double check that here. |
| 367 CheckWebUIRendererDoesNotDisplayNormalURL( | 366 CheckWebUIRendererDoesNotDisplayNormalURL( |
| 368 dest_render_frame_host, entry.GetURL()); | 367 dest_render_frame_host, entry.GetURL()); |
| 369 | 368 |
| 370 // Notify observers that we will navigate in this RenderFrame. | 369 // Notify observers that we will navigate in this RenderFrame. |
| 371 if (delegate_) { | 370 if (delegate_) { |
| 372 delegate_->AboutToNavigateRenderFrame(render_frame_host, | 371 delegate_->AboutToNavigateRenderFrame(frame_tree_node->current_frame_host(), |
|
Charlie Reis
2015/02/19 23:44:26
This notification is deprecated, but it needs the
| |
| 373 dest_render_frame_host); | 372 dest_render_frame_host); |
| 374 } | 373 } |
| 375 | 374 |
| 376 // Create the navigation parameters. | 375 // Create the navigation parameters. |
| 377 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once | 376 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once |
| 378 // http://crbug.com/408684 is fixed. | 377 // http://crbug.com/408684 is fixed. |
| 379 FrameMsg_Navigate_Params navigate_params; | 378 FrameMsg_Navigate_Params navigate_params; |
| 380 MakeNavigateParams( | 379 MakeNavigateParams( |
| 381 entry, controller_, reload_type, navigation_start, &navigate_params); | 380 entry, controller_, reload_type, navigation_start, &navigate_params); |
| 382 | 381 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 if (delegate_) { | 415 if (delegate_) { |
| 417 delegate_->DidStartNavigationToPendingEntry(dest_render_frame_host, | 416 delegate_->DidStartNavigationToPendingEntry(dest_render_frame_host, |
| 418 entry.GetURL(), | 417 entry.GetURL(), |
| 419 reload_type); | 418 reload_type); |
| 420 } | 419 } |
| 421 | 420 |
| 422 return true; | 421 return true; |
| 423 } | 422 } |
| 424 | 423 |
| 425 bool NavigatorImpl::NavigateToPendingEntry( | 424 bool NavigatorImpl::NavigateToPendingEntry( |
| 426 RenderFrameHostImpl* render_frame_host, | 425 FrameTreeNode* frame_tree_node, |
| 427 NavigationController::ReloadType reload_type) { | 426 NavigationController::ReloadType reload_type) { |
| 428 return NavigateToEntry( | 427 return NavigateToEntry( |
| 429 render_frame_host, | 428 frame_tree_node, |
| 430 *NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()), | 429 *NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()), |
| 431 reload_type); | 430 reload_type); |
| 432 } | 431 } |
| 433 | 432 |
| 434 void NavigatorImpl::DidNavigate( | 433 void NavigatorImpl::DidNavigate( |
| 435 RenderFrameHostImpl* render_frame_host, | 434 RenderFrameHostImpl* render_frame_host, |
| 436 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { | 435 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { |
| 437 // PlzNavigate | 436 // PlzNavigate |
| 438 // The navigation request has been committed so the browser process doesn't | 437 // The navigation request has been committed so the browser process doesn't |
| 439 // need to care about it anymore. | 438 // need to care about it anymore. |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 929 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 931 time_to_commit); | 930 time_to_commit); |
| 932 UMA_HISTOGRAM_TIMES( | 931 UMA_HISTOGRAM_TIMES( |
| 933 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 932 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 934 time_to_network); | 933 time_to_network); |
| 935 } | 934 } |
| 936 navigation_data_.reset(); | 935 navigation_data_.reset(); |
| 937 } | 936 } |
| 938 | 937 |
| 939 } // namespace content | 938 } // namespace content |
| OLD | NEW |