| 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/save_package_file_picker_chromeos.h" | 5 #include "chrome/browser/download/save_package_file_picker_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // If false, we don't prompt the user as to where to save the file. This | 23 // If false, we don't prompt the user as to where to save the file. This |
| 24 // exists only for testing. | 24 // exists only for testing. |
| 25 bool g_should_prompt_for_filename = true; | 25 bool g_should_prompt_for_filename = true; |
| 26 | 26 |
| 27 // Trampoline callback between GetDriveTempDownloadPath() and |callback|. | 27 // Trampoline callback between GetDriveTempDownloadPath() and |callback|. |
| 28 void ContinueSettingUpDriveDownload( | 28 void ContinueSettingUpDriveDownload( |
| 29 const content::SavePackagePathPickedCallback& callback, | 29 const content::SavePackagePathPickedCallback& callback, |
| 30 const FilePath& drive_path, | 30 const FilePath& drive_path, |
| 31 const FilePath& drive_tmp_download_path) { | 31 const FilePath& drive_tmp_download_path) { |
| 32 callback.Run(drive_tmp_download_path, content::SAVE_PAGE_TYPE_AS_MHTML, | 32 callback.Run(drive_tmp_download_path, content::SAVE_PAGE_TYPE_AS_MHTML, |
| 33 base::Bind(&gdata::DriveDownloadObserver::SetDownloadParams, | 33 base::Bind(&drive::DriveDownloadObserver::SetDownloadParams, |
| 34 drive_path)); | 34 drive_path)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // anonymous namespace | 37 } // anonymous namespace |
| 38 | 38 |
| 39 SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS( | 39 SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS( |
| 40 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
| 41 const FilePath& suggested_path, | 41 const FilePath& suggested_path, |
| 42 const content::SavePackagePathPickedCallback& callback) | 42 const content::SavePackagePathPickedCallback& callback) |
| 43 : content::WebContentsObserver(web_contents), | 43 : content::WebContentsObserver(web_contents), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (!web_contents()) { | 85 if (!web_contents()) { |
| 86 delete this; | 86 delete this; |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 FilePath selected_path = selected_file_info.file_path; | 89 FilePath selected_path = selected_file_info.file_path; |
| 90 file_util::NormalizeFileNameEncoding(&selected_path); | 90 file_util::NormalizeFileNameEncoding(&selected_path); |
| 91 Profile* profile = Profile::FromBrowserContext( | 91 Profile* profile = Profile::FromBrowserContext( |
| 92 web_contents()->GetBrowserContext()); | 92 web_contents()->GetBrowserContext()); |
| 93 DCHECK(profile); | 93 DCHECK(profile); |
| 94 | 94 |
| 95 if (gdata::util::IsUnderDriveMountPoint(selected_path)) { | 95 if (drive::util::IsUnderDriveMountPoint(selected_path)) { |
| 96 // Here's a map to the callback chain: | 96 // Here's a map to the callback chain: |
| 97 // GetDriveTempDownloadPath -> | 97 // GetDriveTempDownloadPath -> |
| 98 // ContinueSettingUpDriveDownload -> | 98 // ContinueSettingUpDriveDownload -> |
| 99 // callback_ = SavePackage::OnPathPicked -> | 99 // callback_ = SavePackage::OnPathPicked -> |
| 100 // download_created_callback = OnSavePackageDownloadCreated | 100 // download_created_callback = OnSavePackageDownloadCreated |
| 101 gdata::DriveDownloadObserver::SubstituteDriveDownloadPath( | 101 drive::DriveDownloadObserver::SubstituteDriveDownloadPath( |
| 102 profile, selected_path, NULL, | 102 profile, selected_path, NULL, |
| 103 base::Bind(&ContinueSettingUpDriveDownload, callback_, selected_path)); | 103 base::Bind(&ContinueSettingUpDriveDownload, callback_, selected_path)); |
| 104 } else { | 104 } else { |
| 105 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML, | 105 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML, |
| 106 content::SavePackageDownloadCreatedCallback()); | 106 content::SavePackageDownloadCreatedCallback()); |
| 107 } | 107 } |
| 108 delete this; | 108 delete this; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) { | 111 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) { |
| 112 delete this; | 112 delete this; |
| 113 } | 113 } |
| OLD | NEW |