| 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 "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/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
| 9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void DownloadStatusUpdater::UpdateAppIconDownloadProgress( | 257 void DownloadStatusUpdater::UpdateAppIconDownloadProgress( |
| 258 content::DownloadItem* download) { | 258 content::DownloadItem* download) { |
| 259 | 259 |
| 260 // Always update overall progress. | 260 // Always update overall progress. |
| 261 | 261 |
| 262 float progress = 0; | 262 float progress = 0; |
| 263 int download_count = 0; | 263 int download_count = 0; |
| 264 bool progress_known = GetProgress(&progress, &download_count); | 264 bool progress_known = GetProgress(&progress, &download_count); |
| 265 UpdateAppIcon(download_count, progress_known, progress); | 265 UpdateAppIcon(download_count, progress_known, progress); |
| 266 | 266 |
| 267 if (download->GetFullPath().empty()) |
| 268 return; |
| 269 |
| 267 // Update NSProgress-based indicators. | 270 // Update NSProgress-based indicators. |
| 268 | 271 |
| 269 if (NSProgressSupported()) { | 272 if (NSProgressSupported()) { |
| 270 CrNSProgressUserData* progress_data = static_cast<CrNSProgressUserData*>( | 273 CrNSProgressUserData* progress_data = static_cast<CrNSProgressUserData*>( |
| 271 download->GetUserData(&kCrNSProgressUserDataKey)); | 274 download->GetUserData(&kCrNSProgressUserDataKey)); |
| 272 if (!progress_data) | 275 if (!progress_data) |
| 273 CreateNSProgress(download); | 276 CreateNSProgress(download); |
| 274 else if (download->GetState() != content::DownloadItem::IN_PROGRESS) | 277 else if (download->GetState() != content::DownloadItem::IN_PROGRESS) |
| 275 DestroyNSProgress(download, progress_data); | 278 DestroyNSProgress(download, progress_data); |
| 276 else | 279 else |
| (...skipping 12 matching lines...) Expand all Loading... |
| 289 } | 292 } |
| 290 | 293 |
| 291 // Notify the Finder. | 294 // Notify the Finder. |
| 292 NSString* parent_path = [download_path stringByDeletingLastPathComponent]; | 295 NSString* parent_path = [download_path stringByDeletingLastPathComponent]; |
| 293 FNNotifyByPath( | 296 FNNotifyByPath( |
| 294 reinterpret_cast<const UInt8*>([parent_path fileSystemRepresentation]), | 297 reinterpret_cast<const UInt8*>([parent_path fileSystemRepresentation]), |
| 295 kFNDirectoryModifiedMessage, | 298 kFNDirectoryModifiedMessage, |
| 296 kNilOptions); | 299 kNilOptions); |
| 297 } | 300 } |
| 298 } | 301 } |
| OLD | NEW |