| 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 17 matching lines...) Expand all Loading... |
| 28 // Safari on 10.4 and later populates this attribute. | 28 // Safari on 10.4 and later populates this attribute. |
| 29 // | 29 // |
| 30 // With this metadata set, you can locate downloads by performing a Spotlight | 30 // With this metadata set, you can locate downloads by performing a Spotlight |
| 31 // search for their source or referrer URLs, either from within the Spotlight | 31 // search for their source or referrer URLs, either from within the Spotlight |
| 32 // UI or from the command line: | 32 // UI or from the command line: |
| 33 // mdfind 'kMDItemWhereFroms == "http://releases.mozilla.org/*"' | 33 // mdfind 'kMDItemWhereFroms == "http://releases.mozilla.org/*"' |
| 34 // | 34 // |
| 35 // There is no documented API to set metadata on a file directly as of the | 35 // There is no documented API to set metadata on a file directly as of the |
| 36 // 10.5 SDK. The MDSetItemAttribute function does exist to perform this task, | 36 // 10.5 SDK. The MDSetItemAttribute function does exist to perform this task, |
| 37 // but it's undocumented. | 37 // but it's undocumented. |
| 38 void AddOriginMetadataToFile(const FilePath& file, const GURL& source, | 38 void AddOriginMetadataToFile(const base::FilePath& file, const GURL& source, |
| 39 const GURL& referrer) { | 39 const GURL& referrer) { |
| 40 // There's no declaration for MDItemSetAttribute in any known public SDK. | 40 // There's no declaration for MDItemSetAttribute in any known public SDK. |
| 41 // It exists in the 10.4 and 10.5 runtimes. To play it safe, do the lookup | 41 // It exists in the 10.4 and 10.5 runtimes. To play it safe, do the lookup |
| 42 // at runtime instead of declaring it ourselves and linking against what's | 42 // at runtime instead of declaring it ourselves and linking against what's |
| 43 // provided. This has two benefits: | 43 // provided. This has two benefits: |
| 44 // - If Apple relents and declares the function in a future SDK (it's | 44 // - If Apple relents and declares the function in a future SDK (it's |
| 45 // happened before), our build won't break. | 45 // happened before), our build won't break. |
| 46 // - If Apple removes or renames the function in a future runtime, the | 46 // - If Apple removes or renames the function in a future runtime, the |
| 47 // loader won't refuse to let the application launch. Instead, we'll | 47 // loader won't refuse to let the application launch. Instead, we'll |
| 48 // silently fail to set any metadata. | 48 // silently fail to set any metadata. |
| (...skipping 110 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 |