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

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

Issue 7640021: Move some Chrome-specific code paths out of DownloadManager and into the delegate. Getting rid of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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_item.h" 5 #include "chrome/browser/download/download_item.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/timer.h" 14 #include "base/timer.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
17 #include "chrome/browser/download/download_create_info.h" 17 #include "chrome/browser/download/download_create_info.h"
18 #include "chrome/browser/download/download_crx_util.h" 18 #include "chrome/browser/download/download_crx_util.h"
19 #include "chrome/browser/download/download_extensions.h" 19 #include "chrome/browser/download/download_extensions.h"
20 #include "chrome/browser/download/download_file_manager.h" 20 #include "chrome/browser/download/download_file_manager.h"
21 #include "chrome/browser/download/download_history.h" 21 #include "chrome/browser/download/download_history.h"
22 #include "chrome/browser/download/download_manager.h" 22 #include "chrome/browser/download/download_manager.h"
23 #include "chrome/browser/download/download_manager_delegate.h"
23 #include "chrome/browser/download/download_prefs.h" 24 #include "chrome/browser/download/download_prefs.h"
24 #include "chrome/browser/download/download_state_info.h" 25 #include "chrome/browser/download/download_state_info.h"
25 #include "chrome/browser/download/download_util.h" 26 #include "chrome/browser/download/download_util.h"
26 #include "chrome/browser/extensions/crx_installer.h" 27 #include "chrome/browser/extensions/crx_installer.h"
27 #include "chrome/browser/history/download_history_info.h" 28 #include "chrome/browser/history/download_history_info.h"
28 #include "chrome/browser/platform_util.h" 29 #include "chrome/browser/platform_util.h"
29 #include "chrome/browser/prefs/pref_service.h" 30 #include "chrome/browser/prefs/pref_service.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/extensions/extension.h" 33 #include "chrome/common/extensions/extension.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 bool DownloadItem::CanShowInFolder() { 251 bool DownloadItem::CanShowInFolder() {
251 return !IsCancelled() && !file_externally_removed_; 252 return !IsCancelled() && !file_externally_removed_;
252 } 253 }
253 254
254 bool DownloadItem::CanOpenDownload() { 255 bool DownloadItem::CanOpenDownload() {
255 return !Extension::IsExtension(state_info_.target_name) && 256 return !Extension::IsExtension(state_info_.target_name) &&
256 !file_externally_removed_; 257 !file_externally_removed_;
257 } 258 }
258 259
259 bool DownloadItem::ShouldOpenFileBasedOnExtension() { 260 bool DownloadItem::ShouldOpenFileBasedOnExtension() {
260 return download_manager_->ShouldOpenFileBasedOnExtension( 261 return download_manager_->delegate()->ShouldOpenFileBasedOnExtension(
261 GetUserVerifiedFilePath()); 262 GetUserVerifiedFilePath());
262 } 263 }
263 264
264 void DownloadItem::OpenFilesBasedOnExtension(bool open) { 265 void DownloadItem::OpenFilesBasedOnExtension(bool open) {
265 DownloadPrefs* prefs = download_manager_->download_prefs(); 266 DownloadPrefs* prefs = download_manager_->download_prefs();
266 if (open) 267 if (open)
267 prefs->EnableAutoOpenBasedOnExtension(GetUserVerifiedFilePath()); 268 prefs->EnableAutoOpenBasedOnExtension(GetUserVerifiedFilePath());
268 else 269 else
269 prefs->DisableAutoOpenBasedOnExtension(GetUserVerifiedFilePath()); 270 prefs->DisableAutoOpenBasedOnExtension(GetUserVerifiedFilePath());
270 } 271 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 428
428 DCHECK(all_data_saved_); 429 DCHECK(all_data_saved_);
429 TransitionTo(COMPLETE); 430 TransitionTo(COMPLETE);
430 download_manager_->DownloadCompleted(id()); 431 download_manager_->DownloadCompleted(id());
431 download_util::RecordDownloadCompleted(start_tick_); 432 download_util::RecordDownloadCompleted(start_tick_);
432 433
433 if (is_extension_install()) { 434 if (is_extension_install()) {
434 // Extensions should already have been unpacked and opened. 435 // Extensions should already have been unpacked and opened.
435 DCHECK(auto_opened_); 436 DCHECK(auto_opened_);
436 } else if (open_when_complete() || 437 } else if (open_when_complete() ||
437 download_manager_->ShouldOpenFileBasedOnExtension( 438 ShouldOpenFileBasedOnExtension() ||
438 GetUserVerifiedFilePath()) ||
439 is_temporary()) { 439 is_temporary()) {
440 // If the download is temporary, like in drag-and-drop, do not open it but 440 // If the download is temporary, like in drag-and-drop, do not open it but
441 // we still need to set it auto-opened so that it can be removed from the 441 // we still need to set it auto-opened so that it can be removed from the
442 // download shelf. 442 // download shelf.
443 if (!is_temporary()) 443 if (!is_temporary())
444 OpenDownload(); 444 OpenDownload();
445 445
446 auto_opened_ = true; 446 auto_opened_ = true;
447 UpdateObservers(); 447 UpdateObservers();
448 } 448 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 state_info_.target_name.value().c_str(), 858 state_info_.target_name.value().c_str(),
859 full_path().value().c_str()); 859 full_path().value().c_str());
860 } else { 860 } else {
861 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 861 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
862 } 862 }
863 863
864 description += " }"; 864 description += " }";
865 865
866 return description; 866 return description;
867 } 867 }
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698