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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/navigation_controller_impl.h" 5 #include "content/browser/web_contents/navigation_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 NavigationEntryImpl* entry = 486 NavigationEntryImpl* entry =
487 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); 487 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry());
488 if (!entry) 488 if (!entry)
489 return; 489 return;
490 490
491 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); 491 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
492 content::RenderWidgetHostView* view = render_view_host->GetView(); 492 content::RenderWidgetHostView* view = render_view_host->GetView();
493 if (!view) 493 if (!view)
494 return; 494 return;
495 495
496 if (!take_screenshot_callback_.is_null())
497 take_screenshot_callback_.Run(render_view_host);
498
496 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap; 499 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap;
497 render_view_host->CopyFromBackingStore(gfx::Rect(), 500 render_view_host->CopyFromBackingStore(gfx::Rect(),
498 view->GetViewBounds().size(), 501 view->GetViewBounds().size(),
499 base::Bind(&NavigationControllerImpl::OnScreenshotTaken, 502 base::Bind(&NavigationControllerImpl::OnScreenshotTaken,
500 base::Unretained(this), 503 base::Unretained(this),
501 entry->GetUniqueID(), 504 entry->GetUniqueID(),
502 base::Owned(temp_bitmap)), 505 base::Owned(temp_bitmap)),
503 temp_bitmap); 506 temp_bitmap);
504 } 507 }
505 508
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 LoadEntry(entry); 749 LoadEntry(entry);
747 } 750 }
748 751
749 void NavigationControllerImpl::DocumentLoadedInFrame() { 752 void NavigationControllerImpl::DocumentLoadedInFrame() {
750 is_initial_navigation_ = false; 753 is_initial_navigation_ = false;
751 } 754 }
752 755
753 bool NavigationControllerImpl::RendererDidNavigate( 756 bool NavigationControllerImpl::RendererDidNavigate(
754 const ViewHostMsg_FrameNavigate_Params& params, 757 const ViewHostMsg_FrameNavigate_Params& params,
755 LoadCommittedDetails* details) { 758 LoadCommittedDetails* details) {
756 // When navigating away from the current page, take a screenshot of it in the
757 // current state so that it can be used during an overscroll-navigation
758 // gesture.
759 if (details->is_main_frame)
760 TakeScreenshot();
761
762 // Save the previous state before we clobber it. 759 // Save the previous state before we clobber it.
763 if (GetLastCommittedEntry()) { 760 if (GetLastCommittedEntry()) {
764 details->previous_url = GetLastCommittedEntry()->GetURL(); 761 details->previous_url = GetLastCommittedEntry()->GetURL();
765 details->previous_entry_index = GetLastCommittedEntryIndex(); 762 details->previous_entry_index = GetLastCommittedEntryIndex();
766 } else { 763 } else {
767 details->previous_url = GURL(); 764 details->previous_url = GURL();
768 details->previous_entry_index = -1; 765 details->previous_entry_index = -1;
769 } 766 }
770 767
771 // If we have a pending entry at this point, it should have a SiteInstance. 768 // If we have a pending entry at this point, it should have a SiteInstance.
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 new NavigationEntryImpl(*source.entries_[i]))); 1673 new NavigationEntryImpl(*source.entries_[i])));
1677 } 1674 }
1678 } 1675 }
1679 } 1676 }
1680 1677
1681 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1678 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1682 const base::Callback<base::Time()>& get_timestamp_callback) { 1679 const base::Callback<base::Time()>& get_timestamp_callback) {
1683 get_timestamp_callback_ = get_timestamp_callback; 1680 get_timestamp_callback_ = get_timestamp_callback;
1684 } 1681 }
1685 1682
1683 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest(
1684 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) {
1685 take_screenshot_callback_ = take_screenshot_callback;
1686 }
1687
1686 } // namespace content 1688 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/navigation_controller_impl.h ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698