| 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 "content/browser/download/file_metadata_mac.h" | 5 #include "content/browser/download/file_metadata_mac.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #include <Foundation/Foundation.h> | 8 #include <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 [list addObject:referrer_url]; | 89 [list addObject:referrer_url]; |
| 90 | 90 |
| 91 md_item_set_attribute_func(md_item, kMDItemWhereFroms, | 91 md_item_set_attribute_func(md_item, kMDItemWhereFroms, |
| 92 base::mac::NSToCFCast(list)); | 92 base::mac::NSToCFCast(list)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // The OS will automatically quarantine files due to the | 95 // The OS will automatically quarantine files due to the |
| 96 // LSFileQuarantineEnabled entry in our Info.plist, but it knows relatively | 96 // LSFileQuarantineEnabled entry in our Info.plist, but it knows relatively |
| 97 // little about the files. We add more information about the download to | 97 // little about the files. We add more information about the download to |
| 98 // improve the UI shown by the OS when the users tries to open the file. | 98 // improve the UI shown by the OS when the users tries to open the file. |
| 99 void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source, | 99 void AddQuarantineMetadataToFile(const base::FilePath& file, const GURL& source, |
| 100 const GURL& referrer) { | 100 const GURL& referrer) { |
| 101 FSRef file_ref; | 101 FSRef file_ref; |
| 102 if (!base::mac::FSRefFromPath(file.value(), &file_ref)) | 102 if (!base::mac::FSRefFromPath(file.value(), &file_ref)) |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 NSMutableDictionary* quarantine_properties = nil; | 105 NSMutableDictionary* quarantine_properties = nil; |
| 106 CFTypeRef quarantine_properties_base = NULL; | 106 CFTypeRef quarantine_properties_base = NULL; |
| 107 if (LSCopyItemAttribute(&file_ref, kLSRolesAll, kLSItemQuarantineProperties, | 107 if (LSCopyItemAttribute(&file_ref, kLSRolesAll, kLSItemQuarantineProperties, |
| 108 &quarantine_properties_base) == noErr) { | 108 &quarantine_properties_base) == noErr) { |
| 109 if (CFGetTypeID(quarantine_properties_base) == | 109 if (CFGetTypeID(quarantine_properties_base) == |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 OSStatus os_error = LSSetItemAttribute(&file_ref, kLSRolesAll, | 159 OSStatus os_error = LSSetItemAttribute(&file_ref, kLSRolesAll, |
| 160 kLSItemQuarantineProperties, | 160 kLSItemQuarantineProperties, |
| 161 quarantine_properties); | 161 quarantine_properties); |
| 162 if (os_error != noErr) { | 162 if (os_error != noErr) { |
| 163 OSSTATUS_LOG(WARNING, os_error) | 163 OSSTATUS_LOG(WARNING, os_error) |
| 164 << "Unable to set quarantine attributes on file " << file.value(); | 164 << "Unable to set quarantine attributes on file " << file.value(); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace content | 168 } // namespace content |
| OLD | NEW |