Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 417343003: Don't capture screenshots for in-page navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time/time.h" 8 #include "base/time/time.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 if (PageTransitionIsMainFrame(params.transition)) { 435 if (PageTransitionIsMainFrame(params.transition)) {
436 if (delegate_) { 436 if (delegate_) {
437 // When overscroll navigation gesture is enabled, a screenshot of the page 437 // When overscroll navigation gesture is enabled, a screenshot of the page
438 // in its current state is taken so that it can be used during the 438 // in its current state is taken so that it can be used during the
439 // nav-gesture. It is necessary to take the screenshot here, before 439 // nav-gesture. It is necessary to take the screenshot here, before
440 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can 440 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can
441 // change WebContents::GetRenderViewHost to return the new host, instead 441 // change WebContents::GetRenderViewHost to return the new host, instead
442 // of the one that may have just been swapped out. 442 // of the one that may have just been swapped out.
443 if (delegate_->CanOverscrollContent()) { 443 if (delegate_->CanOverscrollContent()) {
444 bool page_id_changed; 444 // Don't take screenshots if we are staying on the same page. We want
445 bool url_changed; 445 // in-page navigations to be super fast, and taking a screenshot
446 NavigationEntry* current_entry = controller_->GetLastCommittedEntry(); 446 // currently blocks GPU for a longer time than we are willing to
447 if (current_entry) { 447 // tolerate in this use case.
448 page_id_changed = params.page_id > 0 && 448 if (!params.was_within_same_page)
449 params.page_id != current_entry->GetPageID();
450 url_changed = params.url != current_entry->GetURL();
451 } else {
452 page_id_changed = params.page_id > 0;
453 url_changed = params.url != GURL::EmptyGURL();
454 }
455
456 // We only want to take the screenshot if the are navigating to a
457 // different history entry than the current one. So if neither the
458 // page id nor the url changed - don't take the screenshot.
459 if (page_id_changed || url_changed)
460 controller_->TakeScreenshot(); 449 controller_->TakeScreenshot();
461 } 450 }
462 451
463 // Run tasks that must execute just before the commit. 452 // Run tasks that must execute just before the commit.
464 bool is_navigation_within_page = controller_->IsURLInPageNavigation( 453 bool is_navigation_within_page = controller_->IsURLInPageNavigation(
465 params.url, params.was_within_same_page, render_frame_host); 454 params.url, params.was_within_same_page, render_frame_host);
466 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); 455 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page);
467 } 456 }
468 457
469 if (!use_site_per_process) 458 if (!use_site_per_process)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 631
643 // Navigations in Web UI pages count as browser-initiated navigations. 632 // Navigations in Web UI pages count as browser-initiated navigations.
644 params.is_renderer_initiated = false; 633 params.is_renderer_initiated = false;
645 } 634 }
646 635
647 if (delegate_) 636 if (delegate_)
648 delegate_->RequestOpenURL(render_frame_host, params); 637 delegate_->RequestOpenURL(render_frame_host, params);
649 } 638 }
650 639
651 } // namespace content 640 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698