| OLD | NEW |
| 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 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" | 5 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/download/download_item_model.h" | 9 #include "chrome/browser/download/download_item_model.h" |
| 10 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" | 10 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 DownloadItemMac::~DownloadItemMac() { | 23 DownloadItemMac::~DownloadItemMac() { |
| 24 download_model_->download()->RemoveObserver(this); | 24 download_model_->download()->RemoveObserver(this); |
| 25 icon_consumer_.CancelAllRequests(); | 25 icon_consumer_.CancelAllRequests(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void DownloadItemMac::OnDownloadUpdated(DownloadItem* download) { | 28 void DownloadItemMac::OnDownloadUpdated(DownloadItem* download) { |
| 29 DCHECK_EQ(download, download_model_->download()); | 29 DCHECK_EQ(download, download_model_->download()); |
| 30 | 30 |
| 31 if ([item_controller_ isDangerousMode] && | 31 if ([item_controller_ isDangerousMode] && |
| 32 download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) { | 32 download->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED) { |
| 33 // We have been approved. | 33 // We have been approved. |
| 34 [item_controller_ clearDangerousMode]; | 34 [item_controller_ clearDangerousMode]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 if (download->GetUserVerifiedFilePath() != lastFilePath_) { | 37 if (download->GetUserVerifiedFilePath() != lastFilePath_) { |
| 38 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | 38 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous |
| 39 // downloads. When the download is confirmed, the file is renamed on | 39 // downloads. When the download is confirmed, the file is renamed on |
| 40 // another thread, so reload the icon if the download filename changes. | 40 // another thread, so reload the icon if the download filename changes. |
| 41 LoadIcon(); | 41 LoadIcon(); |
| 42 lastFilePath_ = download->GetUserVerifiedFilePath(); | 42 lastFilePath_ = download->GetUserVerifiedFilePath(); |
| 43 | 43 |
| 44 [item_controller_ updateToolTip]; | 44 [item_controller_ updateToolTip]; |
| 45 } | 45 } |
| 46 | 46 |
| 47 switch (download->state()) { | 47 switch (download->GetState()) { |
| 48 case DownloadItem::REMOVING: | 48 case DownloadItem::REMOVING: |
| 49 [item_controller_ remove]; // We're deleted now! | 49 [item_controller_ remove]; // We're deleted now! |
| 50 break; | 50 break; |
| 51 case DownloadItem::COMPLETE: | 51 case DownloadItem::COMPLETE: |
| 52 if (download->auto_opened()) { | 52 if (download->GetAutoOpened()) { |
| 53 [item_controller_ remove]; // We're deleted now! | 53 [item_controller_ remove]; // We're deleted now! |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 download_util::NotifySystemOfDownloadComplete(download->full_path()); | 56 download_util::NotifySystemOfDownloadComplete(download->GetFullPath()); |
| 57 // fall through | 57 // fall through |
| 58 case DownloadItem::IN_PROGRESS: | 58 case DownloadItem::IN_PROGRESS: |
| 59 case DownloadItem::INTERRUPTED: | 59 case DownloadItem::INTERRUPTED: |
| 60 case DownloadItem::CANCELLED: | 60 case DownloadItem::CANCELLED: |
| 61 [item_controller_ setStateFromDownload:download_model_.get()]; | 61 [item_controller_ setStateFromDownload:download_model_.get()]; |
| 62 break; | 62 break; |
| 63 default: | 63 default: |
| 64 NOTREACHED(); | 64 NOTREACHED(); |
| 65 } | 65 } |
| 66 } | 66 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 90 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 90 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
| 91 base::Unretained(this))); | 91 base::Unretained(this))); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, | 94 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, |
| 95 gfx::Image* icon) { | 95 gfx::Image* icon) { |
| 96 if (!icon) | 96 if (!icon) |
| 97 return; | 97 return; |
| 98 [item_controller_ setIcon:*icon]; | 98 [item_controller_ setIcon:*icon]; |
| 99 } | 99 } |
| OLD | NEW |