| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // We don't want to add any metadata, because that will cause the file to | 125 // We don't want to add any metadata, because that will cause the file to |
| 126 // be quarantined against the user's wishes. | 126 // be quarantined against the user's wishes. |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // kLSQuarantineAgentNameKey, kLSQuarantineAgentBundleIdentifierKey, and | 130 // kLSQuarantineAgentNameKey, kLSQuarantineAgentBundleIdentifierKey, and |
| 131 // kLSQuarantineTimeStampKey are set for us (see LSQuarantine.h), so we only | 131 // kLSQuarantineTimeStampKey are set for us (see LSQuarantine.h), so we only |
| 132 // need to set the values that the OS can't infer. | 132 // need to set the values that the OS can't infer. |
| 133 | 133 |
| 134 if (![quarantine_properties valueForKey:(NSString*)kLSQuarantineTypeKey]) { | 134 if (![quarantine_properties valueForKey:(NSString*)kLSQuarantineTypeKey]) { |
| 135 CFStringRef type = (source.SchemeIs("http") || source.SchemeIs("https")) | 135 CFStringRef type = source.SchemeIsHttp() |
| 136 ? kLSQuarantineTypeWebDownload | 136 ? kLSQuarantineTypeWebDownload |
| 137 : kLSQuarantineTypeOtherDownload; | 137 : kLSQuarantineTypeOtherDownload; |
| 138 [quarantine_properties setValue:(NSString*)type | 138 [quarantine_properties setValue:(NSString*)type |
| 139 forKey:(NSString*)kLSQuarantineTypeKey]; | 139 forKey:(NSString*)kLSQuarantineTypeKey]; |
| 140 } | 140 } |
| 141 | 141 |
| 142 if (![quarantine_properties | 142 if (![quarantine_properties |
| 143 valueForKey:(NSString*)kLSQuarantineOriginURLKey] && | 143 valueForKey:(NSString*)kLSQuarantineOriginURLKey] && |
| 144 referrer.is_valid()) { | 144 referrer.is_valid()) { |
| 145 NSString* referrer_url = | 145 NSString* referrer_url = |
| (...skipping 13 matching lines...) Expand all 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 |