| 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/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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); | 249 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); |
| 250 #endif | 250 #endif |
| 251 base::SStringPrintf( | 251 base::SStringPrintf( |
| 252 &file_name, | 252 &file_name, |
| 253 unconfirmed_prefix.append( | 253 unconfirmed_prefix.append( |
| 254 FILE_PATH_LITERAL(" %d.crdownload")).c_str(), | 254 FILE_PATH_LITERAL(" %d.crdownload")).c_str(), |
| 255 base::RandInt(0, 1000000)); | 255 base::RandInt(0, 1000000)); |
| 256 return dir.Append(file_name); | 256 return dir.Append(file_name); |
| 257 } | 257 } |
| 258 | 258 |
| 259 int64 ChromeDownloadManagerDelegate::GetIntermediateFileLength( |
| 260 const FilePath& path, bool temporary) { |
| 261 // Get the intermediate file name. |
| 262 FilePath crpath = path; |
| 263 |
| 264 if (!temporary) |
| 265 crpath = download_util::GetCrDownloadPath(path); |
| 266 |
| 267 // Validate the start offset. |
| 268 int64 end = 0; |
| 269 if (file_util::GetFileSize(crpath, &end)) |
| 270 return end; |
| 271 |
| 272 return 0; |
| 273 } |
| 274 |
| 259 WebContents* ChromeDownloadManagerDelegate:: | 275 WebContents* ChromeDownloadManagerDelegate:: |
| 260 GetAlternativeWebContentsToNotifyForDownload() { | 276 GetAlternativeWebContentsToNotifyForDownload() { |
| 261 #if defined(OS_ANDROID) | 277 #if defined(OS_ANDROID) |
| 262 // Android does not implement BrowserList or any other way to get an | 278 // Android does not implement BrowserList or any other way to get an |
| 263 // alternate web contents. | 279 // alternate web contents. |
| 264 return NULL; | 280 return NULL; |
| 265 #else | 281 #else |
| 266 // Start the download in the last active browser. This is not ideal but better | 282 // Start the download in the last active browser. This is not ideal but better |
| 267 // than fully hiding the download from the user. | 283 // than fully hiding the download from the user. |
| 268 Browser* last_active = chrome::FindLastActiveWithProfile(profile_); | 284 Browser* last_active = chrome::FindLastActiveWithProfile(profile_); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a | 874 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a |
| 859 // directory to persist. Or perhaps, if the Drive path | 875 // directory to persist. Or perhaps, if the Drive path |
| 860 // substitution logic is moved here, then we would have a | 876 // substitution logic is moved here, then we would have a |
| 861 // persistable path after the DownloadFilePicker is done. | 877 // persistable path after the DownloadFilePicker is done. |
| 862 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && | 878 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && |
| 863 !download->IsTemporary()) | 879 !download->IsTemporary()) |
| 864 last_download_path_ = target_path.DirName(); | 880 last_download_path_ = target_path.DirName(); |
| 865 } | 881 } |
| 866 callback.Run(target_path, disposition, danger_type, intermediate_path); | 882 callback.Run(target_path, disposition, danger_type, intermediate_path); |
| 867 } | 883 } |
| OLD | NEW |