Index: chrome/browser/download/download_status_updater_mac.mm |
diff --git a/chrome/browser/download/download_status_updater_mac.mm b/chrome/browser/download/download_status_updater_mac.mm |
index 240f7ebe6cb649979696709e0b9a2ff3e13eeea3..7f32e6a97367e9bd9b0c7e9603d1ec0b2239a526 100644 |
--- a/chrome/browser/download/download_status_updater_mac.mm |
+++ b/chrome/browser/download/download_status_updater_mac.mm |
@@ -75,6 +75,14 @@ NSString* ProgressString(NSString* string) { |
} |
} |
+ if (!result) { |
+ // Huh. At least return a local copy of the expected string. |
+ result = string; |
+ NSString* const kKeySuffix = @"Key"; |
+ if ([result hasSuffix:kKeySuffix]) |
+ result = [result substringToIndex:[result length] - [kKeySuffix length]]; |
+ } |
+ |
return result; |
} |
@@ -175,7 +183,7 @@ void UpdateAppIcon(int download_count, |
void CreateNSProgress(content::DownloadItem* download) { |
NSURL* source_url = [NSURL URLWithString: |
- base::SysUTF8ToNSString(download->GetURL().spec())]; |
+ base::SysUTF8ToNSString(download->GetURL().possibly_invalid_spec())]; |
FilePath destination_path = download->GetFullPath(); |
NSURL* destination_url = [NSURL fileURLWithPath: |
base::mac::FilePathToNSString(destination_path)]; |
@@ -186,12 +194,12 @@ void CreateNSProgress(content::DownloadItem* download) { |
// - kNSProgressFileIconOriginalRectKey : NSValue of NSRect in global coords |
NSDictionary* user_info = @{ |
- ProgressString(kNSProgressFileDownloadingSourceURLKey) : source_url, |
ProgressString(kNSProgressFileLocationCanChangeKey) : @true, |
ProgressString(kNSProgressFileOperationKindKey) : |
- ProgressString(kNSProgressFileOperationKindDownloading), |
+ ProgressString(kNSProgressFileOperationKindDownloading), |
ProgressString(kNSProgressFileURLKey) : destination_url |
}; |
+ |
Class progress_class = NSClassFromString(@"NSProgress"); |
NSProgress* progress = [progress_class performSelector:@selector(alloc)]; |
progress = [progress performSelector:@selector(initWithParent:userInfo:) |
@@ -199,6 +207,11 @@ void CreateNSProgress(content::DownloadItem* download) { |
withObject:user_info]; |
progress.kind = ProgressString(kNSProgressKindFile); |
+ if (source_url) { |
benjhayden
2012/08/16 15:52:03
Could you do this right after making |user_info| b
Avi (use Gerrit)
2012/08/16 17:05:30
Unfortunately, NSDictionaries are not mutable so I
|
+ [progress setUserInfoObject:source_url forKey: |
+ ProgressString(kNSProgressFileDownloadingSourceURLKey)]; |
+ } |
+ |
progress.pausable = NO; |
progress.cancellable = YES; |
[progress setCancellationHandler:^{ |