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

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 6973035: Move download stuff to download tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, forgot to add tab watcher as delegate with CF. Created 9 years, 7 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) 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/debugger/devtools_manager.h" 17 #include "chrome/browser/debugger/devtools_manager.h"
19 #include "chrome/browser/defaults.h" 18 #include "chrome/browser/defaults.h"
20 #include "chrome/browser/download/download_request_limiter.h"
21 #include "chrome/browser/external_protocol_handler.h" 19 #include "chrome/browser/external_protocol_handler.h"
22 #include "chrome/browser/history/history.h" 20 #include "chrome/browser/history/history.h"
23 #include "chrome/browser/load_from_memory_cache_details.h" 21 #include "chrome/browser/load_from_memory_cache_details.h"
24 #include "chrome/browser/load_notification_details.h" 22 #include "chrome/browser/load_notification_details.h"
25 #include "chrome/browser/notifications/desktop_notification_service.h" 23 #include "chrome/browser/notifications/desktop_notification_service.h"
26 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 24 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
27 #include "chrome/browser/platform_util.h" 25 #include "chrome/browser/platform_util.h"
28 #include "chrome/browser/plugin_observer.h" 26 #include "chrome/browser/plugin_observer.h"
29 #include "chrome/browser/prefs/pref_service.h" 27 #include "chrome/browser/prefs/pref_service.h"
30 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 847
850 // When it's the first load, we know either the pending one or the committed 848 // When it's the first load, we know either the pending one or the committed
851 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one 849 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one
852 // of them will be valid, so we can just check both. 850 // of them will be valid, so we can just check both.
853 if (render_manager_.pending_web_ui()) 851 if (render_manager_.pending_web_ui())
854 return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); 852 return render_manager_.pending_web_ui()->force_bookmark_bar_visible();
855 return (render_manager_.web_ui() == NULL) ? 853 return (render_manager_.web_ui() == NULL) ?
856 false : render_manager_.web_ui()->force_bookmark_bar_visible(); 854 false : render_manager_.web_ui()->force_bookmark_bar_visible();
857 } 855 }
858 856
859 bool TabContents::CanDownload(int request_id) {
860 TabContentsDelegate* d = delegate();
861 if (d)
862 return d->CanDownload(request_id);
863 return true;
864 }
865
866 void TabContents::OnStartDownload(DownloadItem* download) {
867 DCHECK(download);
868
869 if (!delegate())
870 return;
871
872 // Download in a constrained popup is shown in the tab that opened it.
873 TabContents* tab_contents = delegate()->GetConstrainingContents(this);
874
875 if (tab_contents && tab_contents->delegate())
876 tab_contents->delegate()->OnStartDownload(download, this);
877 }
878
879 void TabContents::WillClose(ConstrainedWindow* window) { 857 void TabContents::WillClose(ConstrainedWindow* window) {
880 ConstrainedWindowList::iterator i( 858 ConstrainedWindowList::iterator i(
881 std::find(child_windows_.begin(), child_windows_.end(), window)); 859 std::find(child_windows_.begin(), child_windows_.end(), window));
882 bool removed_topmost_window = i == child_windows_.begin(); 860 bool removed_topmost_window = i == child_windows_.begin();
883 if (i != child_windows_.end()) 861 if (i != child_windows_.end())
884 child_windows_.erase(i); 862 child_windows_.erase(i);
885 if (child_windows_.empty()) { 863 if (child_windows_.empty()) {
886 BlockTabContent(false); 864 BlockTabContent(false);
887 } else { 865 } else {
888 if (removed_topmost_window) 866 if (removed_topmost_window)
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 // Disable accelerated compositing if IOSurface's are not supported, 1925 // Disable accelerated compositing if IOSurface's are not supported,
1948 // as is the case in 10.5. 1926 // as is the case in 10.5.
1949 if (!IOSurfaceSupport::Initialize()) 1927 if (!IOSurfaceSupport::Initialize())
1950 web_prefs.accelerated_compositing_enabled = false; 1928 web_prefs.accelerated_compositing_enabled = false;
1951 #endif 1929 #endif
1952 1930
1953 return web_prefs; 1931 return web_prefs;
1954 } 1932 }
1955 1933
1956 void TabContents::OnUserGesture() { 1934 void TabContents::OnUserGesture() {
1957 // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this. 1935 // Notify observers.
1958 DownloadRequestLimiter* limiter = 1936 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture());
1959 g_browser_process->download_request_limiter();
1960 if (limiter)
1961 limiter->OnUserGesture(this);
1962 ExternalProtocolHandler::PermitLaunchUrl(); 1937 ExternalProtocolHandler::PermitLaunchUrl();
1963 } 1938 }
1964 1939
1965 void TabContents::OnIgnoredUIEvent() { 1940 void TabContents::OnIgnoredUIEvent() {
1966 if (constrained_window_count()) { 1941 if (constrained_window_count()) {
1967 ConstrainedWindow* window = *constrained_window_begin(); 1942 ConstrainedWindow* window = *constrained_window_begin();
1968 window->FocusConstrainedWindow(); 1943 window->FocusConstrainedWindow();
1969 } 1944 }
1970 } 1945 }
1971 1946
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2201
2227 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2202 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2228 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2203 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2229 rwh_view->SetSize(view()->GetContainerSize()); 2204 rwh_view->SetSize(view()->GetContainerSize());
2230 } 2205 }
2231 2206
2232 void TabContents::OnOnlineStateChanged(bool online) { 2207 void TabContents::OnOnlineStateChanged(bool online) {
2233 render_view_host()->Send(new ViewMsg_NetworkStateChanged( 2208 render_view_host()->Send(new ViewMsg_NetworkStateChanged(
2234 render_view_host()->routing_id(), online)); 2209 render_view_host()->routing_id(), online));
2235 } 2210 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/browser/tab_contents/tab_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698