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

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 6973035: Move download stuff to download tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment tweak 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 "chrome/browser/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/download/download_safe_browsing_client.h" 26 #include "chrome/browser/download/download_safe_browsing_client.h"
27 #include "chrome/browser/download/download_status_updater.h" 27 #include "chrome/browser/download/download_status_updater.h"
28 #include "chrome/browser/download/download_util.h" 28 #include "chrome/browser/download/download_util.h"
29 #include "chrome/browser/extensions/extension_service.h" 29 #include "chrome/browser/extensions/extension_service.h"
30 #include "chrome/browser/history/download_create_info.h" 30 #include "chrome/browser/history/download_create_info.h"
31 #include "chrome/browser/platform_util.h" 31 #include "chrome/browser/platform_util.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/tab_contents/tab_util.h" 33 #include "chrome/browser/tab_contents/tab_util.h"
34 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
35 #include "chrome/browser/ui/browser_list.h" 35 #include "chrome/browser/ui/browser_list.h"
36 #include "chrome/browser/ui/download/download_tab_helper.h"
37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
36 #include "chrome/common/chrome_paths.h" 38 #include "chrome/common/chrome_paths.h"
37 #include "content/browser/browser_thread.h" 39 #include "content/browser/browser_thread.h"
38 #include "content/browser/renderer_host/render_process_host.h" 40 #include "content/browser/renderer_host/render_process_host.h"
39 #include "content/browser/renderer_host/render_view_host.h" 41 #include "content/browser/renderer_host/render_view_host.h"
40 #include "content/browser/renderer_host/resource_dispatcher_host.h" 42 #include "content/browser/renderer_host/resource_dispatcher_host.h"
41 #include "content/browser/tab_contents/tab_contents.h" 43 #include "content/browser/tab_contents/tab_contents.h"
42 #include "content/common/notification_type.h" 44 #include "content/common/notification_type.h"
43 #include "googleurl/src/gurl.h" 45 #include "googleurl/src/gurl.h"
44 #include "grit/generated_resources.h" 46 #include "grit/generated_resources.h"
45 #include "grit/theme_resources.h" 47 #include "grit/theme_resources.h"
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } 1063 }
1062 1064
1063 void DownloadManager::ShowDownloadInBrowser( 1065 void DownloadManager::ShowDownloadInBrowser(
1064 DownloadProcessHandle* process_handle, DownloadItem* download) { 1066 DownloadProcessHandle* process_handle, DownloadItem* download) {
1065 if (!process_handle) 1067 if (!process_handle)
1066 return; 1068 return;
1067 1069
1068 // The 'contents' may no longer exist if the user closed the tab before we 1070 // The 'contents' may no longer exist if the user closed the tab before we
1069 // get this start completion event. If it does, tell the origin TabContents 1071 // get this start completion event. If it does, tell the origin TabContents
1070 // to display its download shelf. 1072 // to display its download shelf.
1071 TabContents* contents = process_handle->GetTabContents(); 1073 TabContentsWrapper* contents = process_handle->GetTabContentsWrapper();
1072 1074
1073 // If the contents no longer exists, we start the download in the last active 1075 // If the contents no longer exists, we start the download in the last active
1074 // browser. This is not ideal but better than fully hiding the download from 1076 // browser. This is not ideal but better than fully hiding the download from
1075 // the user. 1077 // the user.
1076 if (!contents) { 1078 if (!contents) {
1077 Browser* last_active = BrowserList::GetLastActive(); 1079 Browser* last_active = BrowserList::GetLastActive();
1078 if (last_active) 1080 if (last_active)
1079 contents = last_active->GetSelectedTabContents(); 1081 contents = last_active->GetSelectedTabContentsWrapper();
1080 } 1082 }
1081 1083
1082 if (!contents) 1084 if (!contents)
1083 return; 1085 return;
1084 1086
1085 contents->OnStartDownload(download); 1087 contents->download_tab_helper()->OnStartDownload(download);
1086 } 1088 }
1087 1089
1088 // Clears the last download path, used to initialize "save as" dialogs. 1090 // Clears the last download path, used to initialize "save as" dialogs.
1089 void DownloadManager::ClearLastDownloadPath() { 1091 void DownloadManager::ClearLastDownloadPath() {
1090 last_download_path_ = FilePath(); 1092 last_download_path_ = FilePath();
1091 } 1093 }
1092 1094
1093 void DownloadManager::NotifyModelChanged() { 1095 void DownloadManager::NotifyModelChanged() {
1094 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged()); 1096 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged());
1095 } 1097 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 observed_download_manager_->RemoveObserver(this); 1172 observed_download_manager_->RemoveObserver(this);
1171 } 1173 }
1172 1174
1173 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { 1175 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() {
1174 observing_download_manager_->NotifyModelChanged(); 1176 observing_download_manager_->NotifyModelChanged();
1175 } 1177 }
1176 1178
1177 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1179 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1178 observed_download_manager_ = NULL; 1180 observed_download_manager_ = NULL;
1179 } 1181 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_process_handle.h » ('j') | chrome/browser/tab_contents/tab_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698