OLD | NEW |
1 // Copyright (c) 2011 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" |
11 #include "chrome/browser/ui/cocoa/download/download_util_mac.h" | 11 #include "chrome/browser/ui/cocoa/download/download_util_mac.h" |
(...skipping 11 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 DownloadItemMac::~DownloadItemMac() { | 25 DownloadItemMac::~DownloadItemMac() { |
26 download_model_->download()->RemoveObserver(this); | 26 download_model_->download()->RemoveObserver(this); |
27 icon_consumer_.CancelAllRequests(); | 27 icon_consumer_.CancelAllRequests(); |
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 ([item_controller_ isDangerousMode] && | 33 if ([item_controller_ isDangerousMode] && !download_model_->IsDangerous()) { |
34 download->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED) { | |
35 // We have been approved. | 34 // We have been approved. |
36 [item_controller_ clearDangerousMode]; | 35 [item_controller_ clearDangerousMode]; |
37 } | 36 } |
38 | 37 |
39 if (download->GetUserVerifiedFilePath() != lastFilePath_) { | 38 if (download->GetUserVerifiedFilePath() != lastFilePath_) { |
40 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | 39 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous |
41 // downloads. When the download is confirmed, the file is renamed on | 40 // downloads. When the download is confirmed, the file is renamed on |
42 // another thread, so reload the icon if the download filename changes. | 41 // another thread, so reload the icon if the download filename changes. |
43 LoadIcon(); | 42 LoadIcon(); |
44 lastFilePath_ = download->GetUserVerifiedFilePath(); | 43 lastFilePath_ = download->GetUserVerifiedFilePath(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 91 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
93 base::Unretained(this))); | 92 base::Unretained(this))); |
94 } | 93 } |
95 | 94 |
96 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, | 95 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, |
97 gfx::Image* icon) { | 96 gfx::Image* icon) { |
98 if (!icon) | 97 if (!icon) |
99 return; | 98 return; |
100 [item_controller_ setIcon:*icon]; | 99 [item_controller_ setIcon:*icon]; |
101 } | 100 } |
OLD | NEW |