OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
11 #endif | 11 #endif |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
15 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
18 #include "base/i18n/time_formatting.h" | 18 #include "base/i18n/time_formatting.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/singleton.h" | 20 #include "base/singleton.h" |
21 #include "base/string16.h" | 21 #include "base/string16.h" |
22 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
23 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
24 #include "base/sys_string_conversions.h" | 24 #include "base/sys_string_conversions.h" |
25 #include "base/thread_restrictions.h" | 25 #include "base/thread_restrictions.h" |
26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
27 #include "base/values.h" | 27 #include "base/values.h" |
28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
29 #include "chrome/browser/browser_list.h" | |
30 #include "chrome/browser/browser_process.h" | |
31 #include "chrome/browser/browser_thread.h" | 29 #include "chrome/browser/browser_thread.h" |
32 #include "chrome/browser/download/download_item.h" | 30 #include "chrome/browser/download/download_item.h" |
33 #include "chrome/browser/download/download_item_model.h" | 31 #include "chrome/browser/download/download_item_model.h" |
34 #include "chrome/browser/download/download_manager.h" | 32 #include "chrome/browser/download/download_manager.h" |
35 #include "chrome/browser/extensions/crx_installer.h" | 33 #include "chrome/browser/extensions/crx_installer.h" |
36 #include "chrome/browser/extensions/extension_install_ui.h" | 34 #include "chrome/browser/extensions/extension_install_ui.h" |
37 #include "chrome/browser/extensions/extensions_service.h" | 35 #include "chrome/browser/extensions/extensions_service.h" |
38 #include "chrome/browser/history/download_create_info.h" | 36 #include "chrome/browser/history/download_create_info.h" |
39 #include "chrome/browser/net/chrome_url_request_context.h" | 37 #include "chrome/browser/net/chrome_url_request_context.h" |
40 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 namespace { | 690 namespace { |
693 | 691 |
694 // NOTE: If index is 0, deletes files that do not have the " (nnn)" appended. | 692 // NOTE: If index is 0, deletes files that do not have the " (nnn)" appended. |
695 void DeleteUniqueDownloadFile(const FilePath& path, int index) { | 693 void DeleteUniqueDownloadFile(const FilePath& path, int index) { |
696 FilePath new_path(path); | 694 FilePath new_path(path); |
697 if (index > 0) | 695 if (index > 0) |
698 AppendNumberToPath(&new_path, index); | 696 AppendNumberToPath(&new_path, index); |
699 file_util::Delete(new_path, false); | 697 file_util::Delete(new_path, false); |
700 } | 698 } |
701 | 699 |
702 } | 700 } // namespace |
703 | 701 |
704 void EraseUniqueDownloadFiles(const FilePath& path) { | 702 void EraseUniqueDownloadFiles(const FilePath& path) { |
705 FilePath cr_path = GetCrDownloadPath(path); | 703 FilePath cr_path = GetCrDownloadPath(path); |
706 | 704 |
707 for (int index = 0; index <= kMaxUniqueFiles; ++index) { | 705 for (int index = 0; index <= kMaxUniqueFiles; ++index) { |
708 DeleteUniqueDownloadFile(path, index); | 706 DeleteUniqueDownloadFile(path, index); |
709 DeleteUniqueDownloadFile(cr_path, index); | 707 DeleteUniqueDownloadFile(cr_path, index); |
710 } | 708 } |
711 } | 709 } |
712 | 710 |
(...skipping 17 matching lines...) Expand all Loading... |
730 ExtensionsService* service = profile->GetExtensionsService(); | 728 ExtensionsService* service = profile->GetExtensionsService(); |
731 if (!service || | 729 if (!service || |
732 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 730 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
733 return true; | 731 return true; |
734 } | 732 } |
735 } | 733 } |
736 return false; | 734 return false; |
737 } | 735 } |
738 | 736 |
739 } // namespace download_util | 737 } // namespace download_util |
OLD | NEW |