Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: chrome/browser/ui/cocoa/download/download_util_mac.mm

Issue 10827207: Mountain Lion: use the system download progress. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Download utility implementation for Mac OS X. 5 // Download utility implementation for Mac OS X.
6 6
7 #include "chrome/browser/ui/cocoa/download/download_util_mac.h" 7 #include "chrome/browser/ui/cocoa/download/download_util_mac.h"
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #import "chrome/browser/ui/cocoa/dock_icon.h" 10 #import "chrome/browser/ui/cocoa/dock_icon.h"
11 #include "content/public/browser/download_item.h" 11 #include "content/public/browser/download_item.h"
12 #include "content/public/browser/download_manager.h" 12 #include "content/public/browser/download_manager.h"
13 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
14 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
15 15
16 using content::DownloadItem; 16 using content::DownloadItem;
17 17
18 namespace download_util { 18 namespace download_util {
19 19
20 void AddFileToPasteboard(NSPasteboard* pasteboard, const FilePath& path) { 20 void AddFileToPasteboard(NSPasteboard* pasteboard, const FilePath& path) {
21 // Write information about the file being dragged to the pasteboard. 21 // Write information about the file being dragged to the pasteboard.
22 NSString* file = base::SysUTF8ToNSString(path.value()); 22 NSString* file = base::SysUTF8ToNSString(path.value());
23 NSArray* fileList = [NSArray arrayWithObject:file]; 23 NSArray* fileList = [NSArray arrayWithObject:file];
24 [pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] 24 [pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType]
25 owner:nil]; 25 owner:nil];
26 [pasteboard setPropertyList:fileList forType:NSFilenamesPboardType]; 26 [pasteboard setPropertyList:fileList forType:NSFilenamesPboardType];
27 } 27 }
28 28
29 void NotifySystemOfDownloadComplete(const FilePath& path) {
30 NSString* filePath = base::SysUTF8ToNSString(path.value());
31 [[NSDistributedNotificationCenter defaultCenter]
32 postNotificationName:@"com.apple.DownloadFileFinished"
33 object:filePath];
34
35 NSString* parentPath = [filePath stringByDeletingLastPathComponent];
36 FNNotifyByPath(
37 reinterpret_cast<const UInt8*>([parentPath fileSystemRepresentation]),
38 kFNDirectoryModifiedMessage,
39 kNilOptions);
40 }
41
42 void DragDownload(const DownloadItem* download, 29 void DragDownload(const DownloadItem* download,
43 gfx::Image* icon, 30 gfx::Image* icon,
44 gfx::NativeView view) { 31 gfx::NativeView view) {
45 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; 32 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
46 AddFileToPasteboard(pasteboard, download->GetFullPath()); 33 AddFileToPasteboard(pasteboard, download->GetFullPath());
47 34
48 // Synthesize a drag event, since we don't have access to the actual event 35 // Synthesize a drag event, since we don't have access to the actual event
49 // that initiated a drag (possibly consumed by the Web UI, for example). 36 // that initiated a drag (possibly consumed by the Web UI, for example).
50 NSPoint position = [[view window] mouseLocationOutsideOfEventStream]; 37 NSPoint position = [[view window] mouseLocationOutsideOfEventStream];
51 NSTimeInterval eventTime = [[NSApp currentEvent] timestamp]; 38 NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
(...skipping 21 matching lines...) Expand all
73 bool progress_known, 60 bool progress_known,
74 float progress) { 61 float progress) {
75 DockIcon* dock_icon = [DockIcon sharedDockIcon]; 62 DockIcon* dock_icon = [DockIcon sharedDockIcon];
76 [dock_icon setDownloads:download_count]; 63 [dock_icon setDownloads:download_count];
77 [dock_icon setIndeterminate:!progress_known]; 64 [dock_icon setIndeterminate:!progress_known];
78 [dock_icon setProgress:progress]; 65 [dock_icon setProgress:progress];
79 [dock_icon updateIcon]; 66 [dock_icon updateIcon];
80 } 67 }
81 68
82 } // namespace download_util 69 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698