OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/download/download_status_updater.h" | 5 #include "chrome/browser/download/download_status_updater.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/mac/sdk_forward_declarations.h" |
9 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
10 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
11 #import "chrome/browser/ui/cocoa/dock_icon.h" | 12 #import "chrome/browser/ui/cocoa/dock_icon.h" |
12 #include "content/public/browser/download_item.h" | 13 #include "content/public/browser/download_item.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
15 // NSProgress is public API in 10.9, but a version of it exists and is usable | |
16 // in 10.8. | |
17 | |
18 #if !defined(MAC_OS_X_VERSION_10_9) || \ | |
19 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 | |
20 | |
21 @interface NSProgress : NSObject | |
22 | |
23 - (instancetype)initWithParent:(NSProgress*)parentProgressOrNil | |
24 userInfo:(NSDictionary*)userInfoOrNil; | |
25 @property (copy) NSString* kind; | |
26 | |
27 @property int64_t totalUnitCount; | |
28 @property int64_t completedUnitCount; | |
29 | |
30 @property (getter=isCancellable) BOOL cancellable; | |
31 @property (getter=isPausable) BOOL pausable; | |
32 @property (readonly, getter=isCancelled) BOOL cancelled; | |
33 @property (readonly, getter=isPaused) BOOL paused; | |
34 @property (copy) void (^cancellationHandler)(void); | |
35 @property (copy) void (^pausingHandler)(void); | |
36 - (void)cancel; | |
37 - (void)pause; | |
38 | |
39 - (void)setUserInfoObject:(id)objectOrNil forKey:(NSString*)key; | |
40 - (NSDictionary*)userInfo; | |
41 | |
42 @property (readonly, getter=isIndeterminate) BOOL indeterminate; | |
43 @property (readonly) double fractionCompleted; | |
44 | |
45 - (void)publish; | |
46 - (void)unpublish; | |
47 | |
48 @end | |
49 | |
50 #endif // MAC_OS_X_VERSION_10_9 | |
51 | |
52 namespace { | 16 namespace { |
53 | 17 |
54 // These are not the keys themselves; they are the names for dynamic lookup via | 18 // These are not the keys themselves; they are the names for dynamic lookup via |
55 // the ProgressString() function. | 19 // the ProgressString() function. |
56 | 20 |
57 // Public keys, SPI in 10.8, API in 10.9: | 21 // Public keys, SPI in 10.8, API in 10.9: |
58 NSString* const kNSProgressEstimatedTimeRemainingKeyName = | 22 NSString* const kNSProgressEstimatedTimeRemainingKeyName = |
59 @"NSProgressEstimatedTimeRemainingKey"; | 23 @"NSProgressEstimatedTimeRemainingKey"; |
60 NSString* const kNSProgressFileOperationKindDownloadingName = | 24 NSString* const kNSProgressFileOperationKindDownloadingName = |
61 @"NSProgressFileOperationKindDownloading"; | 25 @"NSProgressFileOperationKindDownloading"; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 244 } |
281 | 245 |
282 // Notify the Finder. | 246 // Notify the Finder. |
283 NSString* parent_path = [download_path stringByDeletingLastPathComponent]; | 247 NSString* parent_path = [download_path stringByDeletingLastPathComponent]; |
284 FNNotifyByPath( | 248 FNNotifyByPath( |
285 reinterpret_cast<const UInt8*>([parent_path fileSystemRepresentation]), | 249 reinterpret_cast<const UInt8*>([parent_path fileSystemRepresentation]), |
286 kFNDirectoryModifiedMessage, | 250 kFNDirectoryModifiedMessage, |
287 kNilOptions); | 251 kNilOptions); |
288 } | 252 } |
289 } | 253 } |
OLD | NEW |