| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/time_format.h" | 33 #include "chrome/common/time_format.h" |
| 34 #include "content/browser/download/download_create_info.h" | 34 #include "content/browser/download/download_create_info.h" |
| 35 #include "content/browser/download/download_state_info.h" | 35 #include "content/browser/download/download_state_info.h" |
| 36 #include "content/browser/download/download_types.h" | 36 #include "content/browser/download/download_types.h" |
| 37 #include "content/browser/renderer_host/render_view_host.h" | 37 #include "content/browser/renderer_host/render_view_host.h" |
| 38 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 38 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 39 #include "content/browser/tab_contents/tab_contents.h" | |
| 40 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/download_file.h" | 40 #include "content/public/browser/download_file.h" |
| 42 #include "content/public/browser/download_item.h" | 41 #include "content/public/browser/download_item.h" |
| 43 #include "content/public/browser/download_manager.h" | 42 #include "content/public/browser/download_manager.h" |
| 44 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 45 #include "grit/locale_settings.h" | 44 #include "grit/locale_settings.h" |
| 46 #include "grit/theme_resources.h" | 45 #include "grit/theme_resources.h" |
| 47 #include "net/base/mime_util.h" | 46 #include "net/base/mime_util.h" |
| 48 #include "net/base/net_util.h" | 47 #include "net/base/net_util.h" |
| 49 #include "skia/ext/image_operations.h" | 48 #include "skia/ext/image_operations.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 download->GetFileNameToReportUser(), *icon, &data); | 380 download->GetFileNameToReportUser(), *icon, &data); |
| 382 } | 381 } |
| 383 | 382 |
| 384 const FilePath full_path = download->GetFullPath(); | 383 const FilePath full_path = download->GetFullPath(); |
| 385 data.SetFilename(full_path); | 384 data.SetFilename(full_path); |
| 386 | 385 |
| 387 std::string mime_type = download->GetMimeType(); | 386 std::string mime_type = download->GetMimeType(); |
| 388 if (mime_type.empty()) | 387 if (mime_type.empty()) |
| 389 net::GetMimeTypeFromFile(full_path, &mime_type); | 388 net::GetMimeTypeFromFile(full_path, &mime_type); |
| 390 | 389 |
| 391 // Add URL so that we can load supported files when dragged to TabContents. | 390 // Add URL so that we can load supported files when dragged to WebContents. |
| 392 if (net::IsSupportedMimeType(mime_type)) { | 391 if (net::IsSupportedMimeType(mime_type)) { |
| 393 data.SetURL(net::FilePathToFileURL(full_path), | 392 data.SetURL(net::FilePathToFileURL(full_path), |
| 394 download->GetFileNameToReportUser().LossyDisplayName()); | 393 download->GetFileNameToReportUser().LossyDisplayName()); |
| 395 } | 394 } |
| 396 | 395 |
| 397 #if defined(USE_AURA) | 396 #if defined(USE_AURA) |
| 398 // TODO(beng): | 397 // TODO(beng): |
| 399 NOTIMPLEMENTED(); | 398 NOTIMPLEMENTED(); |
| 400 #elif defined(OS_WIN) | 399 #elif defined(OS_WIN) |
| 401 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); | 400 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 return DownloadFile::GetUniquePathNumberWithSuffix( | 593 return DownloadFile::GetUniquePathNumberWithSuffix( |
| 595 path, FILE_PATH_LITERAL(".crdownload")); | 594 path, FILE_PATH_LITERAL(".crdownload")); |
| 596 } | 595 } |
| 597 | 596 |
| 598 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 597 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
| 599 return DownloadFile::AppendSuffixToPath( | 598 return DownloadFile::AppendSuffixToPath( |
| 600 suggested_path, FILE_PATH_LITERAL(".crdownload")); | 599 suggested_path, FILE_PATH_LITERAL(".crdownload")); |
| 601 } | 600 } |
| 602 | 601 |
| 603 } // namespace download_util | 602 } // namespace download_util |
| OLD | NEW |