OLD | NEW |
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/download_file_picker_chromeos.h" | 5 #include "chrome/browser/download/download_file_picker_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/file_util_icu.h" | 8 #include "base/i18n/file_util_icu.h" |
9 #include "chrome/browser/chromeos/drive/drive_download_handler.h" | 9 #include "chrome/browser/chromeos/drive/drive_download_handler.h" |
10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | |
11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
12 #include "content/public/browser/download_item.h" | 11 #include "content/public/browser/download_item.h" |
13 #include "content/public/browser/download_manager.h" | 12 #include "content/public/browser/download_manager.h" |
14 #include "ui/shell_dialogs/selected_file_info.h" | 13 #include "ui/shell_dialogs/selected_file_info.h" |
15 | 14 |
16 using content::DownloadItem; | 15 using content::DownloadItem; |
17 using content::DownloadManager; | 16 using content::DownloadManager; |
18 | 17 |
19 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() { | 18 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() { |
20 } | 19 } |
21 | 20 |
22 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { | 21 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { |
23 } | 22 } |
24 | 23 |
25 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item, | 24 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item, |
26 const FilePath& path) { | 25 const FilePath& path) { |
27 // For Drive downloads, |path| is the virtual gdata path instead of the | 26 // For Drive downloads, we should pass the drive path instead of the temporary |
28 // temporary local one. | 27 // file path. |
29 Profile* profile = | 28 Profile* profile = |
30 Profile::FromBrowserContext(download_manager_->GetBrowserContext()); | 29 Profile::FromBrowserContext(download_manager_->GetBrowserContext()); |
31 drive::DriveDownloadHandler* drive_download_handler = | 30 drive::DriveDownloadHandler* drive_download_handler = |
32 drive::DriveDownloadHandler::GetForProfile(profile); | 31 drive::DriveDownloadHandler::GetForProfile(profile); |
33 if (drive_download_handler && drive_download_handler->IsDriveDownload(item)) { | 32 FilePath suggested_path = path; |
34 set_suggested_path(drive::util::GetSpecialRemoteRootPath().Append( | 33 if (drive_download_handler && drive_download_handler->IsDriveDownload(item)) |
35 drive_download_handler->GetDrivePath(item))); | 34 suggested_path = drive_download_handler->GetTargetPath(item); |
36 } else { | 35 |
37 DownloadFilePicker::InitSuggestedPath(item, path); | 36 DownloadFilePicker::InitSuggestedPath(item, suggested_path); |
38 } | |
39 } | 37 } |
40 | 38 |
41 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path, | 39 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path, |
42 int index, | 40 int index, |
43 void* params) { | 41 void* params) { |
44 FileSelectedWithExtraInfo( | 42 FileSelectedWithExtraInfo( |
45 ui::SelectedFileInfo(selected_path, selected_path), | 43 ui::SelectedFileInfo(selected_path, selected_path), |
46 index, | 44 index, |
47 params); | 45 params); |
48 } | 46 } |
(...skipping 21 matching lines...) Expand all Loading... |
70 base::Bind(&DownloadFilePickerChromeOS::OnFileSelected, | 68 base::Bind(&DownloadFilePickerChromeOS::OnFileSelected, |
71 base::Unretained(this))); | 69 base::Unretained(this))); |
72 } else { | 70 } else { |
73 OnFileSelected(path); | 71 OnFileSelected(path); |
74 } | 72 } |
75 } else { | 73 } else { |
76 OnFileSelected(FilePath()); | 74 OnFileSelected(FilePath()); |
77 } | 75 } |
78 // The OnFileSelected() call deletes |this| | 76 // The OnFileSelected() call deletes |this| |
79 } | 77 } |
OLD | NEW |