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

Side by Side Diff: content/browser/web_contents/navigation_controller_impl.cc

Issue 12036074: overscroll: Enable overscroll navigation by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return NULL; 472 return NULL;
473 473
474 return entries_[index].get(); 474 return entries_[index].get();
475 } 475 }
476 476
477 int NavigationControllerImpl::GetIndexForOffset(int offset) const { 477 int NavigationControllerImpl::GetIndexForOffset(int offset) const {
478 return GetCurrentEntryIndex() + offset; 478 return GetCurrentEntryIndex() + offset;
479 } 479 }
480 480
481 void NavigationControllerImpl::TakeScreenshot() { 481 void NavigationControllerImpl::TakeScreenshot() {
482 static bool overscroll_enabled = CommandLine::ForCurrentProcess()-> 482 static bool overscroll_enabled = !CommandLine::ForCurrentProcess()->
483 HasSwitch(switches::kEnableOverscrollHistoryNavigation); 483 HasSwitch(switches::kDisableOverscrollHistoryNavigation);
484 if (!overscroll_enabled) 484 if (!overscroll_enabled)
485 return; 485 return;
486 486
487 NavigationEntryImpl* entry = 487 NavigationEntryImpl* entry =
488 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); 488 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry());
489 if (!entry) 489 if (!entry)
490 return; 490 return;
491 491
492 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); 492 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
493 if (!static_cast<RenderViewHostImpl*>
494 (render_view_host)->overscroll_controller()) {
495 return;
496 }
493 content::RenderWidgetHostView* view = render_view_host->GetView(); 497 content::RenderWidgetHostView* view = render_view_host->GetView();
494 if (!view) 498 if (!view)
495 return; 499 return;
496 500
497 if (!take_screenshot_callback_.is_null()) 501 if (!take_screenshot_callback_.is_null())
498 take_screenshot_callback_.Run(render_view_host); 502 take_screenshot_callback_.Run(render_view_host);
499 503
500 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap; 504 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap;
501 render_view_host->CopyFromBackingStore(gfx::Rect(), 505 render_view_host->CopyFromBackingStore(gfx::Rect(),
502 view->GetViewBounds().size(), 506 view->GetViewBounds().size(),
(...skipping 17 matching lines...) Expand all
520 break; 524 break;
521 } 525 }
522 } 526 }
523 527
524 if (!entry) { 528 if (!entry) {
525 LOG(ERROR) << "Invalid entry with unique id: " << unique_id; 529 LOG(ERROR) << "Invalid entry with unique id: " << unique_id;
526 return; 530 return;
527 } 531 }
528 532
529 if (!success) { 533 if (!success) {
530 LOG(ERROR) << "Taking snapshot was unsuccessful for "
531 << unique_id;
532 ClearScreenshot(entry); 534 ClearScreenshot(entry);
533 return; 535 return;
534 } 536 }
535 537
536 std::vector<unsigned char> data; 538 std::vector<unsigned char> data;
537 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap->GetBitmap(), true, &data)) { 539 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap->GetBitmap(), true, &data)) {
538 if (!entry->screenshot()) 540 if (!entry->screenshot())
539 ++screenshot_count_; 541 ++screenshot_count_;
540 entry->SetScreenshotPNGData(data); 542 entry->SetScreenshotPNGData(data);
541 PurgeScreenshotsIfNecessary(); 543 PurgeScreenshotsIfNecessary();
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 const base::Callback<base::Time()>& get_timestamp_callback) { 1769 const base::Callback<base::Time()>& get_timestamp_callback) {
1768 get_timestamp_callback_ = get_timestamp_callback; 1770 get_timestamp_callback_ = get_timestamp_callback;
1769 } 1771 }
1770 1772
1771 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( 1773 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest(
1772 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { 1774 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) {
1773 take_screenshot_callback_ = take_screenshot_callback; 1775 take_screenshot_callback_ = take_screenshot_callback;
1774 } 1776 }
1775 1777
1776 } // namespace content 1778 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698