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

Unified Diff: chrome/browser/download/download_status_updater_mac.mm

Issue 10831340: Bulletproof download status update code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixin' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:^{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698