OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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.h" | 5 #include "chrome/browser/download/download_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/platform_util.h" | 21 #include "chrome/common/platform_util.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
25 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
26 | 26 |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 #include "app/win_util.h" | 28 #include "app/win_util.h" |
29 #include "chrome/common/win_safe_util.h" | 29 #include "chrome/common/win_safe_util.h" |
30 #elif defined(OS_MACOSX) | 30 #elif defined(OS_MACOSX) |
31 #include "chrome/common/quarantine_mac.h" | 31 #include "chrome/browser/cocoa/file_metadata.h" |
32 #endif | 32 #endif |
33 | 33 |
34 // Throttle updates to the UI thread so that a fast moving download doesn't | 34 // Throttle updates to the UI thread so that a fast moving download doesn't |
35 // cause it to become unresponsive (in milliseconds). | 35 // cause it to become unresponsive (in milliseconds). |
36 static const int kUpdatePeriodMs = 500; | 36 static const int kUpdatePeriodMs = 500; |
37 | 37 |
38 // Timer task for posting UI updates. This task is created and maintained by | 38 // Timer task for posting UI updates. This task is created and maintained by |
39 // the DownloadFileManager long as there is an in progress download. The task | 39 // the DownloadFileManager long as there is an in progress download. The task |
40 // is cancelled when all active downloads have completed, or in the destructor | 40 // is cancelled when all active downloads have completed, or in the destructor |
41 // of the DownloadFileManager. | 41 // of the DownloadFileManager. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 #endif | 141 #endif |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 void DownloadFile::AnnotateWithSourceInformation() { | 145 void DownloadFile::AnnotateWithSourceInformation() { |
146 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
147 // Sets the Zone to tell Windows that this file comes from the internet. | 147 // Sets the Zone to tell Windows that this file comes from the internet. |
148 // We ignore the return value because a failure is not fatal. | 148 // We ignore the return value because a failure is not fatal. |
149 win_util::SetInternetZoneIdentifier(full_path_); | 149 win_util::SetInternetZoneIdentifier(full_path_); |
150 #elif defined(OS_MACOSX) | 150 #elif defined(OS_MACOSX) |
151 quarantine_mac::AddQuarantineMetadataToFile(full_path_, source_url_, | 151 file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_, |
152 referrer_url_); | 152 referrer_url_); |
| 153 file_metadata::AddOriginMetadataToFile(full_path_, source_url_, |
| 154 referrer_url_); |
153 #endif | 155 #endif |
154 } | 156 } |
155 | 157 |
156 // DownloadFileManager implementation ------------------------------------------ | 158 // DownloadFileManager implementation ------------------------------------------ |
157 | 159 |
158 DownloadFileManager::DownloadFileManager(MessageLoop* ui_loop, | 160 DownloadFileManager::DownloadFileManager(MessageLoop* ui_loop, |
159 ResourceDispatcherHost* rdh) | 161 ResourceDispatcherHost* rdh) |
160 : next_id_(0), | 162 : next_id_(0), |
161 ui_loop_(ui_loop), | 163 ui_loop_(ui_loop), |
162 resource_dispatcher_host_(rdh) { | 164 resource_dispatcher_host_(rdh) { |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 612 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
611 this, &DownloadFileManager::StopUpdateTimer)); | 613 this, &DownloadFileManager::StopUpdateTimer)); |
612 } | 614 } |
613 | 615 |
614 // static | 616 // static |
615 void DownloadFileManager::DeleteFile(const FilePath& path) { | 617 void DownloadFileManager::DeleteFile(const FilePath& path) { |
616 // Make sure we only delete files. | 618 // Make sure we only delete files. |
617 if (!file_util::DirectoryExists(path)) | 619 if (!file_util::DirectoryExists(path)) |
618 file_util::Delete(path, false); | 620 file_util::Delete(path, false); |
619 } | 621 } |
OLD | NEW |