OLD | NEW |
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/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "content/public/browser/render_widget_host.h" | 34 #include "content/public/browser/render_widget_host.h" |
35 #include "content/public/browser/render_widget_host_view.h" | 35 #include "content/public/browser/render_widget_host_view.h" |
36 #include "content/public/browser/storage_partition.h" | 36 #include "content/public/browser/storage_partition.h" |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/common/content_client.h" | 38 #include "content/public/common/content_client.h" |
39 #include "content/public/common/content_constants.h" | 39 #include "content/public/common/content_constants.h" |
40 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
41 #include "net/base/mime_util.h" | 41 #include "net/base/mime_util.h" |
42 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
43 #include "skia/ext/platform_canvas.h" | 43 #include "skia/ext/platform_canvas.h" |
| 44 #include "ui/base/touch/touch_device.h" |
| 45 #include "ui/base/touch/touch_enabled.h" |
44 #include "url/url_constants.h" | 46 #include "url/url_constants.h" |
45 | 47 |
46 namespace content { | 48 namespace content { |
47 namespace { | 49 namespace { |
48 | 50 |
49 // Invoked when entries have been pruned, or removed. For example, if the | 51 // Invoked when entries have been pruned, or removed. For example, if the |
50 // current entries are [google, digg, yahoo], with the current entry google, | 52 // current entries are [google, digg, yahoo], with the current entry google, |
51 // and the user types in cnet, then digg and yahoo are pruned. | 53 // and the user types in cnet, then digg and yahoo are pruned. |
52 void NotifyPrunedEntries(NavigationControllerImpl* nav_controller, | 54 void NotifyPrunedEntries(NavigationControllerImpl* nav_controller, |
53 bool from_front, | 55 bool from_front, |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 514 } |
513 | 515 |
514 int NavigationControllerImpl::GetIndexForOffset(int offset) const { | 516 int NavigationControllerImpl::GetIndexForOffset(int offset) const { |
515 return GetCurrentEntryIndex() + offset; | 517 return GetCurrentEntryIndex() + offset; |
516 } | 518 } |
517 | 519 |
518 void NavigationControllerImpl::TakeScreenshot() { | 520 void NavigationControllerImpl::TakeScreenshot() { |
519 screenshot_manager_->TakeScreenshot(); | 521 screenshot_manager_->TakeScreenshot(); |
520 } | 522 } |
521 | 523 |
| 524 bool NavigationControllerImpl::ShouldTakeScreenshotOnNavigation() { |
| 525 if (!delegate_->CanOverscrollContent()) |
| 526 return false; |
| 527 |
| 528 // Don't take screenshots on navigation on Windows and Unix machines unless |
| 529 // they have a touch screen as these machines typically don't have a touchpad |
| 530 // capable of horizontal scrolling. We are purposefully biased towards "no" |
| 531 // here, so that we don't waste resources unnecessarily. |
| 532 #if defined(OS_BSD) || defined(OS_FREEBSD) || defined(OS_LINUX) \ |
| 533 || defined(OS_OPENBSD) || defined(OS_POSIX) || defined(OS_QNX) \ |
| 534 || defined(OS_WIN) |
| 535 return ui::IsTouchDevicePresent() && ui::AreTouchEventsEnabled(); |
| 536 #else |
| 537 return true; |
| 538 #endif |
| 539 } |
| 540 |
522 void NavigationControllerImpl::SetScreenshotManager( | 541 void NavigationControllerImpl::SetScreenshotManager( |
523 NavigationEntryScreenshotManager* manager) { | 542 NavigationEntryScreenshotManager* manager) { |
524 screenshot_manager_.reset(manager ? manager : | 543 screenshot_manager_.reset(manager ? manager : |
525 new NavigationEntryScreenshotManager(this)); | 544 new NavigationEntryScreenshotManager(this)); |
526 } | 545 } |
527 | 546 |
528 bool NavigationControllerImpl::CanGoBack() const { | 547 bool NavigationControllerImpl::CanGoBack() const { |
529 return entries_.size() > 1 && GetCurrentEntryIndex() > 0; | 548 return entries_.size() > 1 && GetCurrentEntryIndex() > 0; |
530 } | 549 } |
531 | 550 |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 } | 1807 } |
1789 } | 1808 } |
1790 } | 1809 } |
1791 | 1810 |
1792 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1811 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1793 const base::Callback<base::Time()>& get_timestamp_callback) { | 1812 const base::Callback<base::Time()>& get_timestamp_callback) { |
1794 get_timestamp_callback_ = get_timestamp_callback; | 1813 get_timestamp_callback_ = get_timestamp_callback; |
1795 } | 1814 } |
1796 | 1815 |
1797 } // namespace content | 1816 } // namespace content |
OLD | NEW |