| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 #include "content/public/browser/download_item.h" | |
| 13 #include "content/public/browser/download_manager.h" | |
| 14 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 11 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 15 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 12 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 16 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 13 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 17 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 15 #include "chrome/browser/download/download_util.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/download_item.h" |
| 19 #include "content/public/browser/download_manager.h" |
| 19 | 20 |
| 20 using content::BrowserThread; | 21 using content::BrowserThread; |
| 21 using content::DownloadManager; | 22 using content::DownloadManager; |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Callbacks for PostTaskAndReply. | 26 // Callbacks for PostTaskAndReply. |
| 26 | 27 |
| 27 // |temp_path| is set to a temporary local download path in | 28 // |temp_path| is set to a temporary local download path in |
| 28 // ~/GCache/v1/tmp/downloads/ | 29 // ~/GCache/v1/tmp/downloads/ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 56 int32 download_id) | 57 int32 download_id) |
| 57 : DownloadFilePicker(download_manager, | 58 : DownloadFilePicker(download_manager, |
| 58 web_contents, | 59 web_contents, |
| 59 suggested_path, | 60 suggested_path, |
| 60 download_id) { | 61 download_id) { |
| 61 } | 62 } |
| 62 | 63 |
| 63 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { | 64 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { |
| 64 } | 65 } |
| 65 | 66 |
| 66 void DownloadFilePickerChromeOS::FileSelected(const FilePath& path, | 67 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path, |
| 67 int index, | 68 int index, |
| 68 void* params) { | 69 void* params) { |
| 70 FilePath normalized_file_name = selected_path.BaseName(); |
| 71 download_util::NormalizeFileNameOnChromeOS(&normalized_file_name); |
| 72 FilePath path = selected_path.DirName().Append(normalized_file_name); |
| 73 |
| 69 RecordFileSelected(path); | 74 RecordFileSelected(path); |
| 70 | 75 |
| 71 if (download_manager_) { | 76 if (download_manager_) { |
| 72 gdata::GDataSystemService* system_service = | 77 gdata::GDataSystemService* system_service = |
| 73 gdata::GDataSystemServiceFactory::GetForProfile( | 78 gdata::GDataSystemServiceFactory::GetForProfile( |
| 74 ProfileManager::GetDefaultProfile()); | 79 ProfileManager::GetDefaultProfile()); |
| 75 if (system_service && gdata::util::IsUnderGDataMountPoint(path)) { | 80 if (system_service && gdata::util::IsUnderGDataMountPoint(path)) { |
| 76 // If we're trying to download a file into gdata, save path in external | 81 // If we're trying to download a file into gdata, save path in external |
| 77 // data. | 82 // data. |
| 78 content::DownloadItem* download = | 83 content::DownloadItem* download = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 96 download_manager_, | 101 download_manager_, |
| 97 base::Owned(download_path), | 102 base::Owned(download_path), |
| 98 download_id_)); | 103 download_id_)); |
| 99 } | 104 } |
| 100 } else { | 105 } else { |
| 101 download_manager_->FileSelected(path, download_id_); | 106 download_manager_->FileSelected(path, download_id_); |
| 102 } | 107 } |
| 103 } | 108 } |
| 104 delete this; | 109 delete this; |
| 105 } | 110 } |
| OLD | NEW |