OLD | NEW |
---|---|
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 Loading... | |
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 #if defined(USE_AURA) |
483 HasSwitch(switches::kEnableOverscrollHistoryNavigation); | 483 static bool overscroll_enabled = !CommandLine::ForCurrentProcess()-> |
484 HasSwitch(switches::kDisableOverscrollHistoryNavigation); | |
485 #else | |
486 static bool overscroll_enabled = false; | |
487 #endif | |
484 if (!overscroll_enabled) | 488 if (!overscroll_enabled) |
485 return; | 489 return; |
486 | 490 |
487 NavigationEntryImpl* entry = | 491 NavigationEntryImpl* entry = |
488 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); | 492 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); |
489 if (!entry) | 493 if (!entry) |
490 return; | 494 return; |
491 | 495 |
492 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); | 496 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); |
493 content::RenderWidgetHostView* view = render_view_host->GetView(); | 497 content::RenderWidgetHostView* view = render_view_host->GetView(); |
(...skipping 26 matching lines...) Expand all Loading... | |
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; | |
sadrul
2013/01/24 04:21:31
Removed this because it makes the tests too noisy.
| |
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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1757 const base::Callback<base::Time()>& get_timestamp_callback) { | 1759 const base::Callback<base::Time()>& get_timestamp_callback) { |
1758 get_timestamp_callback_ = get_timestamp_callback; | 1760 get_timestamp_callback_ = get_timestamp_callback; |
1759 } | 1761 } |
1760 | 1762 |
1761 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( | 1763 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( |
1762 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { | 1764 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { |
1763 take_screenshot_callback_ = take_screenshot_callback; | 1765 take_screenshot_callback_ = take_screenshot_callback; |
1764 } | 1766 } |
1765 | 1767 |
1766 } // namespace content | 1768 } // namespace content |
OLD | NEW |