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

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

Issue 352393002: Be explicit about target type in platform_util::OpenItem() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 enum PlatformDownloadPathType { 94 enum PlatformDownloadPathType {
95 // Return the platform specific target path. 95 // Return the platform specific target path.
96 PLATFORM_TARGET_PATH, 96 PLATFORM_TARGET_PATH,
97 97
98 // Return the platform specific current path. If the download is in-progress 98 // Return the platform specific current path. If the download is in-progress
99 // and the download location is a local filesystem path, then 99 // and the download location is a local filesystem path, then
100 // GetPlatformDownloadPath will return the path to the intermediate file. 100 // GetPlatformDownloadPath will return the path to the intermediate file.
101 PLATFORM_CURRENT_PATH 101 PLATFORM_CURRENT_PATH
102 }; 102 };
103 103
104 // Returns a path in the form that that is expected by platform_util::OpenItem / 104 // Returns a path in the form that that is expected by platform_util::OpenFile /
105 // platform_util::ShowItemInFolder / DownloadTargetDeterminer. 105 // platform_util::OpenFolder / platform_util::ShowItemInFolder /
106 // DownloadTargetDeterminer.
106 // 107 //
107 // DownloadItems corresponding to Drive downloads use a temporary file as the 108 // DownloadItems corresponding to Drive downloads use a temporary file as the
108 // target path. The paths returned by DownloadItem::GetFullPath() / 109 // target path. The paths returned by DownloadItem::GetFullPath() /
109 // GetTargetFilePath() refer to this temporary file. This function looks up the 110 // GetTargetFilePath() refer to this temporary file. This function looks up the
110 // corresponding path in Drive for these downloads. 111 // corresponding path in Drive for these downloads.
111 // 112 //
112 // How the platform path is determined is based on PlatformDownloadPathType. 113 // How the platform path is determined is based on PlatformDownloadPathType.
113 base::FilePath GetPlatformDownloadPath(Profile* profile, 114 base::FilePath GetPlatformDownloadPath(Profile* profile,
114 const DownloadItem* download, 115 const DownloadItem* download,
115 PlatformDownloadPathType path_type) { 116 PlatformDownloadPathType path_type) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 can_save_as_complete, 414 can_save_as_complete,
414 download_prefs_.get(), 415 download_prefs_.get(),
415 callback); 416 callback);
416 } 417 }
417 418
418 void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler( 419 void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler(
419 DownloadItem* download) { 420 DownloadItem* download) {
420 base::FilePath platform_path( 421 base::FilePath platform_path(
421 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH)); 422 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH));
422 DCHECK(!platform_path.empty()); 423 DCHECK(!platform_path.empty());
423 platform_util::OpenItem(profile_, platform_path); 424 platform_util::OpenFile(profile_, platform_path);
424 } 425 }
425 426
426 void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) { 427 void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
427 DCHECK_EQ(DownloadItem::COMPLETE, download->GetState()); 428 DCHECK_EQ(DownloadItem::COMPLETE, download->GetState());
428 DCHECK(!download->GetTargetFilePath().empty()); 429 DCHECK(!download->GetTargetFilePath().empty());
429 if (!download->CanOpenDownload()) 430 if (!download->CanOpenDownload())
430 return; 431 return;
431 432
432 if (!DownloadItemModel(download).ShouldPreferOpeningInBrowser()) { 433 if (!DownloadItemModel(download).ShouldPreferOpeningInBrowser()) {
433 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_PLATFORM); 434 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_PLATFORM);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || 734 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) ||
734 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || 735 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) ||
735 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || 736 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) ||
736 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || 737 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) ||
737 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { 738 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) {
738 return true; 739 return true;
739 } 740 }
740 #endif 741 #endif
741 return false; 742 return false;
742 } 743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698