| 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 #import "chrome/browser/ui/cocoa/infobars/extension_infobar_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/extension_infobar_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "chrome/browser/api/infobars/infobar_service.h" | 9 #include "chrome/browser/api/infobars/infobar_service.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ExtensionIconSet::MATCH_EXACTLY); | 76 ExtensionIconSet::MATCH_EXACTLY); |
| 77 extensions::ImageLoader* loader = | 77 extensions::ImageLoader* loader = |
| 78 extensions::ImageLoader::Get(delegate_->extension_host()->profile()); | 78 extensions::ImageLoader::Get(delegate_->extension_host()->profile()); |
| 79 loader->LoadImageAsync(extension, icon_resource, | 79 loader->LoadImageAsync(extension, icon_resource, |
| 80 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, | 80 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, |
| 81 extension_misc::EXTENSION_ICON_BITTY), | 81 extension_misc::EXTENSION_ICON_BITTY), |
| 82 base::Bind(&InfobarBridge::OnImageLoaded, | 82 base::Bind(&InfobarBridge::OnImageLoaded, |
| 83 weak_ptr_factory_.GetWeakPtr())); | 83 weak_ptr_factory_.GetWeakPtr())); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // ImageLoadingTracker::Observer implementation. | 86 // ImageLoader callback. |
| 87 // TODO(andybons): The infobar view implementations share a lot of the same | 87 // TODO(andybons): The infobar view implementations share a lot of the same |
| 88 // code. Come up with a strategy to share amongst them. | 88 // code. Come up with a strategy to share amongst them. |
| 89 void OnImageLoaded(const gfx::Image& image) { | 89 void OnImageLoaded(const gfx::Image& image) { |
| 90 if (!delegate_) | 90 if (!delegate_) |
| 91 return; // The delegate can go away while the image asynchronously loads. | 91 return; // The delegate can go away while the image asynchronously loads. |
| 92 | 92 |
| 93 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 93 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 94 | 94 |
| 95 // Fall back on the default extension icon on failure. | 95 // Fall back on the default extension icon on failure. |
| 96 const gfx::ImageSkia* icon; | 96 const gfx::ImageSkia* icon; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { | 273 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { |
| 274 NSWindow* window = | 274 NSWindow* window = |
| 275 [(NSView*)owner->GetWebContents()->GetContentNativeView() window]; | 275 [(NSView*)owner->GetWebContents()->GetContentNativeView() window]; |
| 276 ExtensionInfoBarController* controller = | 276 ExtensionInfoBarController* controller = |
| 277 [[ExtensionInfoBarController alloc] initWithDelegate:this | 277 [[ExtensionInfoBarController alloc] initWithDelegate:this |
| 278 owner:owner | 278 owner:owner |
| 279 window:window]; | 279 window:window]; |
| 280 return new InfoBar(controller, this); | 280 return new InfoBar(controller, this); |
| 281 } | 281 } |
| OLD | NEW |