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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CFSTR("MDItemSetAttribute")); | 63 CFSTR("MDItemSetAttribute")); |
64 } | 64 } |
65 if (!md_item_set_attribute_func) | 65 if (!md_item_set_attribute_func) |
66 return; | 66 return; |
67 | 67 |
68 NSString* file_path = | 68 NSString* file_path = |
69 [NSString stringWithUTF8String:file.value().c_str()]; | 69 [NSString stringWithUTF8String:file.value().c_str()]; |
70 if (!file_path) | 70 if (!file_path) |
71 return; | 71 return; |
72 | 72 |
73 base::mac::ScopedCFTypeRef<MDItemRef> md_item( | 73 base::ScopedCFTypeRef<MDItemRef> md_item( |
74 MDItemCreate(NULL, base::mac::NSToCFCast(file_path))); | 74 MDItemCreate(NULL, base::mac::NSToCFCast(file_path))); |
75 if (!md_item) | 75 if (!md_item) |
76 return; | 76 return; |
77 | 77 |
78 // We won't put any more than 2 items into the attribute. | 78 // We won't put any more than 2 items into the attribute. |
79 NSMutableArray* list = [NSMutableArray arrayWithCapacity:2]; | 79 NSMutableArray* list = [NSMutableArray arrayWithCapacity:2]; |
80 | 80 |
81 // Follow Safari's lead: the first item in the list is the source URL of | 81 // Follow Safari's lead: the first item in the list is the source URL of |
82 // the downloaded file. If the referrer is known, store that, too. | 82 // the downloaded file. If the referrer is known, store that, too. |
83 NSString* origin_url = [NSString stringWithUTF8String:source.spec().c_str()]; | 83 NSString* origin_url = [NSString stringWithUTF8String:source.spec().c_str()]; |
(...skipping 75 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 |