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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 download_model_.download()->AddObserver(this); | 23 download_model_.download()->AddObserver(this); |
24 } | 24 } |
25 | 25 |
26 DownloadItemMac::~DownloadItemMac() { | 26 DownloadItemMac::~DownloadItemMac() { |
27 download_model_.download()->RemoveObserver(this); | 27 download_model_.download()->RemoveObserver(this); |
28 } | 28 } |
29 | 29 |
30 void DownloadItemMac::OnDownloadUpdated(content::DownloadItem* download) { | 30 void DownloadItemMac::OnDownloadUpdated(content::DownloadItem* download) { |
31 DCHECK_EQ(download, download_model_.download()); | 31 DCHECK_EQ(download, download_model_.download()); |
32 | 32 |
| 33 if (!download_model_.ShouldShowInShelf()) { |
| 34 [item_controller_ remove]; // We're deleted now! |
| 35 return; |
| 36 } |
| 37 |
33 if ([item_controller_ isDangerousMode] && !download_model_.IsDangerous()) { | 38 if ([item_controller_ isDangerousMode] && !download_model_.IsDangerous()) { |
34 // We have been approved. | 39 // We have been approved. |
35 [item_controller_ clearDangerousMode]; | 40 [item_controller_ clearDangerousMode]; |
36 } | 41 } |
37 | 42 |
38 if (download->GetTargetFilePath() != lastFilePath_) { | 43 if (download->GetTargetFilePath() != lastFilePath_) { |
39 LoadIcon(); | 44 LoadIcon(); |
40 lastFilePath_ = download->GetTargetFilePath(); | 45 lastFilePath_ = download->GetTargetFilePath(); |
41 | 46 |
42 [item_controller_ updateToolTip]; | 47 [item_controller_ updateToolTip]; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 96 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
92 base::Unretained(this)), | 97 base::Unretained(this)), |
93 &cancelable_task_tracker_); | 98 &cancelable_task_tracker_); |
94 } | 99 } |
95 | 100 |
96 void DownloadItemMac::OnExtractIconComplete(gfx::Image* icon) { | 101 void DownloadItemMac::OnExtractIconComplete(gfx::Image* icon) { |
97 if (!icon) | 102 if (!icon) |
98 return; | 103 return; |
99 [item_controller_ setIcon:icon->ToNSImage()]; | 104 [item_controller_ setIcon:icon->ToNSImage()]; |
100 } | 105 } |
OLD | NEW |