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; |
49 case DownloadItem::COMPLETE: | 52 case DownloadItem::COMPLETE: |
50 if (download->GetAutoOpened()) { | 53 if (download->GetAutoOpened()) { |
51 [item_controller_ remove]; // We're deleted now! | 54 [item_controller_ remove]; // We're deleted now! |
52 return; | 55 return; |
53 } | 56 } |
54 download_util::NotifySystemOfDownloadComplete(download->GetFullPath()); | 57 download_util::NotifySystemOfDownloadComplete(download->GetFullPath()); |
55 // fall through | 58 // fall through |
56 case DownloadItem::IN_PROGRESS: | 59 case DownloadItem::IN_PROGRESS: |
57 case DownloadItem::CANCELLED: | 60 case DownloadItem::CANCELLED: |
58 [item_controller_ setStateFromDownload:download_model_.get()]; | 61 [item_controller_ setStateFromDownload:download_model_.get()]; |
59 break; | 62 break; |
60 case DownloadItem::INTERRUPTED: | 63 case DownloadItem::INTERRUPTED: |
61 [item_controller_ updateToolTip]; | 64 [item_controller_ updateToolTip]; |
62 [item_controller_ setStateFromDownload:download_model_.get()]; | 65 [item_controller_ setStateFromDownload:download_model_.get()]; |
63 break; | 66 break; |
64 default: | 67 default: |
65 NOTREACHED(); | 68 NOTREACHED(); |
66 } | 69 } |
67 } | 70 } |
68 | 71 |
69 void DownloadItemMac::OnDownloadDestroyed(content::DownloadItem* download) { | |
70 [item_controller_ remove]; // We're deleted now! | |
71 } | |
72 | |
73 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { | 72 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { |
74 DCHECK_EQ(download, download_model_->download()); | 73 DCHECK_EQ(download, download_model_->download()); |
75 [item_controller_ downloadWasOpened]; | 74 [item_controller_ downloadWasOpened]; |
76 } | 75 } |
77 | 76 |
78 void DownloadItemMac::LoadIcon() { | 77 void DownloadItemMac::LoadIcon() { |
79 IconManager* icon_manager = g_browser_process->icon_manager(); | 78 IconManager* icon_manager = g_browser_process->icon_manager(); |
80 if (!icon_manager) { | 79 if (!icon_manager) { |
81 NOTREACHED(); | 80 NOTREACHED(); |
82 return; | 81 return; |
(...skipping 12 matching lines...) Expand all Loading... |
95 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 94 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
96 base::Unretained(this))); | 95 base::Unretained(this))); |
97 } | 96 } |
98 | 97 |
99 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, | 98 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, |
100 gfx::Image* icon) { | 99 gfx::Image* icon) { |
101 if (!icon) | 100 if (!icon) |
102 return; | 101 return; |
103 [item_controller_ setIcon:*icon]; | 102 [item_controller_ setIcon:*icon]; |
104 } | 103 } |
OLD | NEW |