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

Unified Diff: content/browser/web_contents/navigation_controller_impl.cc

Issue 11776010: overscroll: Take a screenshot at more appropriate times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/navigation_entry_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/navigation_controller_impl.cc
diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc
index bd6971646b8d428103ed5fcb13eb1b9d226ebf1e..6b0a86631d6226927a588ff45ee783054f4bc2d8 100644
--- a/content/browser/web_contents/navigation_controller_impl.cc
+++ b/content/browser/web_contents/navigation_controller_impl.cc
@@ -137,6 +137,29 @@ bool ShouldKeepOverride(const NavigationEntry* last_entry) {
return last_entry && last_entry->GetIsOverridingUserAgent();
}
+// Returns whether a screenshot should be taken because of the page transition.
Charlie Reis 2013/01/07 19:50:23 What's the intention here? You're returning no fo
+bool ShouldTakeScreenshotForTransition(PageTransition transition) {
+ // Never take a screenshot if the main page didn't navigate.
+ if (!PageTransitionIsMainFrame(transition))
+ return false;
+
+ int core = transition & PAGE_TRANSITION_CORE_MASK;
+ switch (core) {
+ case PAGE_TRANSITION_TYPED:
+ case PAGE_TRANSITION_AUTO_BOOKMARK:
+ case PAGE_TRANSITION_RELOAD:
+ return false;
+ }
+
+ int qualifier = transition & PAGE_TRANSITION_QUALIFIER_MASK;
+ if (qualifier & (PAGE_TRANSITION_FORWARD_BACK |
+ PAGE_TRANSITION_FROM_ADDRESS_BAR)) {
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
// NavigationControllerImpl ----------------------------------------------------
@@ -530,6 +553,8 @@ void NavigationControllerImpl::OnScreenshotTaken(
std::vector<unsigned char> data;
if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap->GetBitmap(), true, &data))
entry->SetScreenshotPNGData(data);
+ else
+ entry->SetScreenshotPNGData(std::vector<unsigned char>());
}
bool NavigationControllerImpl::CanGoBack() const {
@@ -755,7 +780,7 @@ bool NavigationControllerImpl::RendererDidNavigate(
// When navigating away from the current page, take a screenshot of it in the
// current state so that it can be used during an overscroll-navigation
// gesture.
- if (details->is_main_frame)
+ if (ShouldTakeScreenshotForTransition(params.transition))
TakeScreenshot();
// Save the previous state before we clobber it.
@@ -1548,6 +1573,8 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) {
if (!web_contents_->NavigateToPendingEntry(reload_type))
DiscardNonCommittedEntries();
+ else if (reload_type == NO_RELOAD)
Charlie Reis 2013/01/07 19:50:23 We should put a return after DiscardNonCommittedEn
sadrul 2013/01/08 00:16:29 The issue here is that, in some cases (especially
+ TakeScreenshot();
// If the entry is being restored and doesn't have a SiteInstance yet, fill
// it in now that we know. This allows us to find the entry when it commits.
« no previous file with comments | « no previous file | content/browser/web_contents/navigation_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698