OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/download/download_request_limiter.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "content/browser/child_process_security_policy.h" | 18 #include "content/browser/child_process_security_policy.h" |
18 #include "content/browser/content_browser_client.h" | 19 #include "content/browser/content_browser_client.h" |
19 #include "content/browser/debugger/devtools_manager.h" | 20 #include "content/browser/debugger/devtools_manager.h" |
20 #include "content/browser/host_zoom_map.h" | 21 #include "content/browser/host_zoom_map.h" |
21 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 22 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
22 #include "content/browser/load_from_memory_cache_details.h" | 23 #include "content/browser/load_from_memory_cache_details.h" |
23 #include "content/browser/load_notification_details.h" | 24 #include "content/browser/load_notification_details.h" |
24 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_process_host.h" |
25 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
26 #include "content/browser/renderer_host/render_widget_host_view.h" | 27 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
27 #include "content/browser/renderer_host/resource_request_details.h" | 29 #include "content/browser/renderer_host/resource_request_details.h" |
28 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
29 #include "content/browser/tab_contents/interstitial_page.h" | 31 #include "content/browser/tab_contents/interstitial_page.h" |
30 #include "content/browser/tab_contents/navigation_details.h" | 32 #include "content/browser/tab_contents/navigation_details.h" |
31 #include "content/browser/tab_contents/navigation_entry.h" | 33 #include "content/browser/tab_contents/navigation_entry.h" |
32 #include "content/browser/tab_contents/provisional_load_details.h" | 34 #include "content/browser/tab_contents/provisional_load_details.h" |
33 #include "content/browser/tab_contents/tab_contents_delegate.h" | 35 #include "content/browser/tab_contents/tab_contents_delegate.h" |
34 #include "content/browser/tab_contents/tab_contents_observer.h" | 36 #include "content/browser/tab_contents/tab_contents_observer.h" |
35 #include "content/browser/tab_contents/tab_contents_view.h" | 37 #include "content/browser/tab_contents/tab_contents_view.h" |
36 #include "content/browser/tab_contents/title_updated_details.h" | 38 #include "content/browser/tab_contents/title_updated_details.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 if (entry && entry->url() == GURL(chrome::kAboutBlankURL)) | 674 if (entry && entry->url() == GURL(chrome::kAboutBlankURL)) |
673 return true; | 675 return true; |
674 return false; | 676 return false; |
675 } | 677 } |
676 | 678 |
677 void TabContents::SetFocusToLocationBar(bool select_all) { | 679 void TabContents::SetFocusToLocationBar(bool select_all) { |
678 if (delegate()) | 680 if (delegate()) |
679 delegate()->SetFocusToLocationBar(select_all); | 681 delegate()->SetFocusToLocationBar(select_all); |
680 } | 682 } |
681 | 683 |
| 684 bool TabContents::CanDownload(int request_id) { |
| 685 TabContentsDelegate* d = delegate(); |
| 686 if (d) |
| 687 return d->CanDownload(this, request_id); |
| 688 return true; |
| 689 } |
| 690 |
| 691 void TabContents::OnStartDownload(DownloadItem* download) { |
| 692 TabContentsDelegate* d = delegate(); |
| 693 if (d) |
| 694 d->OnStartDownload(this, download); |
| 695 } |
| 696 |
682 void TabContents::WillClose(ConstrainedWindow* window) { | 697 void TabContents::WillClose(ConstrainedWindow* window) { |
683 ConstrainedWindowList::iterator i( | 698 ConstrainedWindowList::iterator i( |
684 std::find(child_windows_.begin(), child_windows_.end(), window)); | 699 std::find(child_windows_.begin(), child_windows_.end(), window)); |
685 bool removed_topmost_window = i == child_windows_.begin(); | 700 bool removed_topmost_window = i == child_windows_.begin(); |
686 if (i != child_windows_.end()) | 701 if (i != child_windows_.end()) |
687 child_windows_.erase(i); | 702 child_windows_.erase(i); |
688 if (child_windows_.empty()) { | 703 if (child_windows_.empty()) { |
689 BlockTabContent(false); | 704 BlockTabContent(false); |
690 } else { | 705 } else { |
691 if (removed_topmost_window) | 706 if (removed_topmost_window) |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 if (!IOSurfaceSupport::Initialize()) | 1651 if (!IOSurfaceSupport::Initialize()) |
1637 web_prefs.accelerated_compositing_enabled = false; | 1652 web_prefs.accelerated_compositing_enabled = false; |
1638 #endif | 1653 #endif |
1639 | 1654 |
1640 return web_prefs; | 1655 return web_prefs; |
1641 } | 1656 } |
1642 | 1657 |
1643 void TabContents::OnUserGesture() { | 1658 void TabContents::OnUserGesture() { |
1644 // Notify observers. | 1659 // Notify observers. |
1645 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); | 1660 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); |
| 1661 |
| 1662 ResourceDispatcherHost* rdh = |
| 1663 content::GetContentClient()->browser()->GetResourceDispatcherHost(); |
| 1664 if (rdh) // NULL in unittests. |
| 1665 rdh->download_request_limiter()->OnUserGesture(this); |
1646 } | 1666 } |
1647 | 1667 |
1648 void TabContents::OnIgnoredUIEvent() { | 1668 void TabContents::OnIgnoredUIEvent() { |
1649 if (constrained_window_count()) { | 1669 if (constrained_window_count()) { |
1650 ConstrainedWindow* window = *constrained_window_begin(); | 1670 ConstrainedWindow* window = *constrained_window_begin(); |
1651 window->FocusConstrainedWindow(); | 1671 window->FocusConstrainedWindow(); |
1652 } | 1672 } |
1653 } | 1673 } |
1654 | 1674 |
1655 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, | 1675 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 } | 1833 } |
1814 | 1834 |
1815 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 1835 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
1816 render_manager_.SwapInRenderViewHost(rvh); | 1836 render_manager_.SwapInRenderViewHost(rvh); |
1817 } | 1837 } |
1818 | 1838 |
1819 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 1839 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
1820 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 1840 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
1821 rwh_view->SetSize(view()->GetContainerSize()); | 1841 rwh_view->SetSize(view()->GetContainerSize()); |
1822 } | 1842 } |
OLD | NEW |