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/browser_process.h" | |
17 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
18 #include "chrome/browser/content_settings/content_settings_details.h" | 17 #include "chrome/browser/content_settings/content_settings_details.h" |
19 #include "chrome/browser/content_settings/host_content_settings_map.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map.h" |
20 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
21 #include "chrome/browser/debugger/devtools_manager.h" | 20 #include "chrome/browser/debugger/devtools_manager.h" |
22 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
23 #include "chrome/browser/download/download_request_limiter.h" | |
24 #include "chrome/browser/external_protocol_handler.h" | 22 #include "chrome/browser/external_protocol_handler.h" |
25 #include "chrome/browser/history/history.h" | 23 #include "chrome/browser/history/history.h" |
26 #include "chrome/browser/load_from_memory_cache_details.h" | 24 #include "chrome/browser/load_from_memory_cache_details.h" |
27 #include "chrome/browser/load_notification_details.h" | 25 #include "chrome/browser/load_notification_details.h" |
28 #include "chrome/browser/notifications/desktop_notification_service.h" | 26 #include "chrome/browser/notifications/desktop_notification_service.h" |
29 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 27 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
30 #include "chrome/browser/platform_util.h" | 28 #include "chrome/browser/platform_util.h" |
31 #include "chrome/browser/plugin_observer.h" | 29 #include "chrome/browser/plugin_observer.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 855 |
858 // When it's the first load, we know either the pending one or the committed | 856 // When it's the first load, we know either the pending one or the committed |
859 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one | 857 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one |
860 // of them will be valid, so we can just check both. | 858 // of them will be valid, so we can just check both. |
861 if (render_manager_.pending_web_ui()) | 859 if (render_manager_.pending_web_ui()) |
862 return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); | 860 return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); |
863 return (render_manager_.web_ui() == NULL) ? | 861 return (render_manager_.web_ui() == NULL) ? |
864 false : render_manager_.web_ui()->force_bookmark_bar_visible(); | 862 false : render_manager_.web_ui()->force_bookmark_bar_visible(); |
865 } | 863 } |
866 | 864 |
867 bool TabContents::CanDownload(int request_id) { | |
868 TabContentsDelegate* d = delegate(); | |
869 if (d) | |
870 return d->CanDownload(request_id); | |
871 return true; | |
872 } | |
873 | |
874 void TabContents::OnStartDownload(DownloadItem* download) { | |
875 DCHECK(download); | |
876 | |
877 if (!delegate()) | |
878 return; | |
879 | |
880 // Download in a constrained popup is shown in the tab that opened it. | |
881 TabContents* tab_contents = delegate()->GetConstrainingContents(this); | |
882 | |
883 if (tab_contents && tab_contents->delegate()) | |
884 tab_contents->delegate()->OnStartDownload(download, this); | |
885 } | |
886 | |
887 void TabContents::WillClose(ConstrainedWindow* window) { | 865 void TabContents::WillClose(ConstrainedWindow* window) { |
888 ConstrainedWindowList::iterator i( | 866 ConstrainedWindowList::iterator i( |
889 std::find(child_windows_.begin(), child_windows_.end(), window)); | 867 std::find(child_windows_.begin(), child_windows_.end(), window)); |
890 bool removed_topmost_window = i == child_windows_.begin(); | 868 bool removed_topmost_window = i == child_windows_.begin(); |
891 if (i != child_windows_.end()) | 869 if (i != child_windows_.end()) |
892 child_windows_.erase(i); | 870 child_windows_.erase(i); |
893 if (child_windows_.empty()) { | 871 if (child_windows_.empty()) { |
894 BlockTabContent(false); | 872 BlockTabContent(false); |
895 } else { | 873 } else { |
896 if (removed_topmost_window) | 874 if (removed_topmost_window) |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 // Disable accelerated compositing if IOSurface's are not supported, | 1939 // Disable accelerated compositing if IOSurface's are not supported, |
1962 // as is the case in 10.5. | 1940 // as is the case in 10.5. |
1963 if (!IOSurfaceSupport::Initialize()) | 1941 if (!IOSurfaceSupport::Initialize()) |
1964 web_prefs.accelerated_compositing_enabled = false; | 1942 web_prefs.accelerated_compositing_enabled = false; |
1965 #endif | 1943 #endif |
1966 | 1944 |
1967 return web_prefs; | 1945 return web_prefs; |
1968 } | 1946 } |
1969 | 1947 |
1970 void TabContents::OnUserGesture() { | 1948 void TabContents::OnUserGesture() { |
1971 // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this. | 1949 // Notify observers. |
1972 DownloadRequestLimiter* limiter = | 1950 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); |
1973 g_browser_process->download_request_limiter(); | |
1974 if (limiter) | |
1975 limiter->OnUserGesture(this); | |
1976 ExternalProtocolHandler::PermitLaunchUrl(); | 1951 ExternalProtocolHandler::PermitLaunchUrl(); |
1977 } | 1952 } |
1978 | 1953 |
1979 void TabContents::OnIgnoredUIEvent() { | 1954 void TabContents::OnIgnoredUIEvent() { |
1980 if (constrained_window_count()) { | 1955 if (constrained_window_count()) { |
1981 ConstrainedWindow* window = *constrained_window_begin(); | 1956 ConstrainedWindow* window = *constrained_window_begin(); |
1982 window->FocusConstrainedWindow(); | 1957 window->FocusConstrainedWindow(); |
1983 } | 1958 } |
1984 } | 1959 } |
1985 | 1960 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 | 2230 |
2256 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2231 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2257 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2232 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2258 rwh_view->SetSize(view()->GetContainerSize()); | 2233 rwh_view->SetSize(view()->GetContainerSize()); |
2259 } | 2234 } |
2260 | 2235 |
2261 void TabContents::OnOnlineStateChanged(bool online) { | 2236 void TabContents::OnOnlineStateChanged(bool online) { |
2262 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2237 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
2263 render_view_host()->routing_id(), online)); | 2238 render_view_host()->routing_id(), online)); |
2264 } | 2239 } |
OLD | NEW |