| 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/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 28 matching lines...) Expand all Loading... |
| 39 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | 39 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous |
| 40 // downloads. When the download is confirmed, the file is renamed on | 40 // downloads. When the download is confirmed, the file is renamed on |
| 41 // another thread, so reload the icon if the download filename changes. | 41 // another thread, so reload the icon if the download filename changes. |
| 42 LoadIcon(); | 42 LoadIcon(); |
| 43 lastFilePath_ = download->GetUserVerifiedFilePath(); | 43 lastFilePath_ = download->GetUserVerifiedFilePath(); |
| 44 | 44 |
| 45 [item_controller_ updateToolTip]; | 45 [item_controller_ updateToolTip]; |
| 46 } | 46 } |
| 47 | 47 |
| 48 switch (download->GetState()) { | 48 switch (download->GetState()) { |
| 49 case DownloadItem::REMOVING: | |
| 50 [item_controller_ remove]; // We're deleted now! | |
| 51 break; | |
| 52 case DownloadItem::COMPLETE: | 49 case DownloadItem::COMPLETE: |
| 53 if (download->GetAutoOpened()) { | 50 if (download->GetAutoOpened()) { |
| 54 [item_controller_ remove]; // We're deleted now! | 51 [item_controller_ remove]; // We're deleted now! |
| 55 return; | 52 return; |
| 56 } | 53 } |
| 57 download_util::NotifySystemOfDownloadComplete(download->GetFullPath()); | 54 download_util::NotifySystemOfDownloadComplete(download->GetFullPath()); |
| 58 // fall through | 55 // fall through |
| 59 case DownloadItem::IN_PROGRESS: | 56 case DownloadItem::IN_PROGRESS: |
| 60 case DownloadItem::CANCELLED: | 57 case DownloadItem::CANCELLED: |
| 61 [item_controller_ setStateFromDownload:download_model_.get()]; | 58 [item_controller_ setStateFromDownload:download_model_.get()]; |
| 62 break; | 59 break; |
| 63 case DownloadItem::INTERRUPTED: | 60 case DownloadItem::INTERRUPTED: |
| 64 [item_controller_ updateToolTip]; | 61 [item_controller_ updateToolTip]; |
| 65 [item_controller_ setStateFromDownload:download_model_.get()]; | 62 [item_controller_ setStateFromDownload:download_model_.get()]; |
| 66 break; | 63 break; |
| 67 default: | 64 default: |
| 68 NOTREACHED(); | 65 NOTREACHED(); |
| 69 } | 66 } |
| 70 } | 67 } |
| 71 | 68 |
| 69 void DownloadItemMac::OnDownloadDestructed(content::DownloadItem* download) { |
| 70 [item_controller_ remove]; // We're deleted now! |
| 71 } |
| 72 |
| 72 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { | 73 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { |
| 73 DCHECK_EQ(download, download_model_->download()); | 74 DCHECK_EQ(download, download_model_->download()); |
| 74 [item_controller_ downloadWasOpened]; | 75 [item_controller_ downloadWasOpened]; |
| 75 } | 76 } |
| 76 | 77 |
| 77 void DownloadItemMac::LoadIcon() { | 78 void DownloadItemMac::LoadIcon() { |
| 78 IconManager* icon_manager = g_browser_process->icon_manager(); | 79 IconManager* icon_manager = g_browser_process->icon_manager(); |
| 79 if (!icon_manager) { | 80 if (!icon_manager) { |
| 80 NOTREACHED(); | 81 NOTREACHED(); |
| 81 return; | 82 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 94 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 95 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
| 95 base::Unretained(this))); | 96 base::Unretained(this))); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, | 99 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, |
| 99 gfx::Image* icon) { | 100 gfx::Image* icon) { |
| 100 if (!icon) | 101 if (!icon) |
| 101 return; | 102 return; |
| 102 [item_controller_ setIcon:*icon]; | 103 [item_controller_ setIcon:*icon]; |
| 103 } | 104 } |
| OLD | NEW |