| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 NOTREACHED(); | 66 NOTREACHED(); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DownloadItemMac::OnDownloadDestroyed(content::DownloadItem* download) { | 70 void DownloadItemMac::OnDownloadDestroyed(content::DownloadItem* download) { |
| 71 [item_controller_ remove]; // We're deleted now! | 71 [item_controller_ remove]; // We're deleted now! |
| 72 } | 72 } |
| 73 | 73 |
| 74 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { | 74 void DownloadItemMac::OnDownloadOpened(content::DownloadItem* download) { |
| 75 DCHECK_EQ(download, download_model_.download()); | 75 DCHECK_EQ(download, download_model_.download()); |
| 76 [item_controller_ downloadWasOpened]; | 76 [item_controller_ downloadWasOpenedOrShown]; |
| 77 } |
| 78 |
| 79 void DownloadItemMac::OnDownloadShown(content::DownloadItem* download) { |
| 80 DCHECK_EQ(download, download_model_.download()); |
| 81 [item_controller_ downloadWasOpenedOrShown]; |
| 77 } | 82 } |
| 78 | 83 |
| 79 void DownloadItemMac::LoadIcon() { | 84 void DownloadItemMac::LoadIcon() { |
| 80 IconManager* icon_manager = g_browser_process->icon_manager(); | 85 IconManager* icon_manager = g_browser_process->icon_manager(); |
| 81 if (!icon_manager) | 86 if (!icon_manager) |
| 82 return; | 87 return; |
| 83 | 88 |
| 84 // We may already have this particular image cached. | 89 // We may already have this particular image cached. |
| 85 base::FilePath file = download_model_.download()->GetTargetFilePath(); | 90 base::FilePath file = download_model_.download()->GetTargetFilePath(); |
| 86 gfx::Image* icon = icon_manager->LookupIconFromFilepath( | 91 gfx::Image* icon = icon_manager->LookupIconFromFilepath( |
| 87 file, IconLoader::ALL); | 92 file, IconLoader::ALL); |
| 88 if (icon) { | 93 if (icon) { |
| 89 [item_controller_ setIcon:icon->ToNSImage()]; | 94 [item_controller_ setIcon:icon->ToNSImage()]; |
| 90 return; | 95 return; |
| 91 } | 96 } |
| 92 | 97 |
| 93 // The icon isn't cached, load it asynchronously. | 98 // The icon isn't cached, load it asynchronously. |
| 94 icon_manager->LoadIcon(file, | 99 icon_manager->LoadIcon(file, |
| 95 IconLoader::ALL, | 100 IconLoader::ALL, |
| 96 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 101 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
| 97 base::Unretained(this)), | 102 base::Unretained(this)), |
| 98 &cancelable_task_tracker_); | 103 &cancelable_task_tracker_); |
| 99 } | 104 } |
| 100 | 105 |
| 101 void DownloadItemMac::OnExtractIconComplete(gfx::Image* icon) { | 106 void DownloadItemMac::OnExtractIconComplete(gfx::Image* icon) { |
| 102 if (!icon) | 107 if (!icon) |
| 103 return; | 108 return; |
| 104 [item_controller_ setIcon:icon->ToNSImage()]; | 109 [item_controller_ setIcon:icon->ToNSImage()]; |
| 105 } | 110 } |
| OLD | NEW |