| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 IconManager* icon_manager = g_browser_process->icon_manager(); | 77 IconManager* icon_manager = g_browser_process->icon_manager(); |
| 78 if (!icon_manager) { | 78 if (!icon_manager) { |
| 79 NOTREACHED(); | 79 NOTREACHED(); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // We may already have this particular image cached. | 83 // We may already have this particular image cached. |
| 84 FilePath file = download_model_->download()->GetUserVerifiedFilePath(); | 84 FilePath file = download_model_->download()->GetUserVerifiedFilePath(); |
| 85 gfx::Image* icon = icon_manager->LookupIcon(file, IconLoader::ALL); | 85 gfx::Image* icon = icon_manager->LookupIcon(file, IconLoader::ALL); |
| 86 if (icon) { | 86 if (icon) { |
| 87 [item_controller_ setIcon:*icon]; | 87 [item_controller_ setIcon:icon->ToNSImage()]; |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // The icon isn't cached, load it asynchronously. | 91 // The icon isn't cached, load it asynchronously. |
| 92 icon_manager->LoadIcon(file, IconLoader::ALL, &icon_consumer_, | 92 icon_manager->LoadIcon(file, IconLoader::ALL, &icon_consumer_, |
| 93 base::Bind(&DownloadItemMac::OnExtractIconComplete, | 93 base::Bind(&DownloadItemMac::OnExtractIconComplete, |
| 94 base::Unretained(this))); | 94 base::Unretained(this))); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, | 97 void DownloadItemMac::OnExtractIconComplete(IconManager::Handle handle, |
| 98 gfx::Image* icon) { | 98 gfx::Image* icon) { |
| 99 if (!icon) | 99 if (!icon) |
| 100 return; | 100 return; |
| 101 [item_controller_ setIcon:*icon]; | 101 [item_controller_ setIcon:icon->ToNSImage()]; |
| 102 } | 102 } |
| OLD | NEW |