diff options
author | rpaquay@chromium.org <rpaquay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 05:27:13 +0000 |
---|---|---|
committer | rpaquay@chromium.org <rpaquay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 05:27:13 +0000 |
commit | 780f68bde6e9713b2465358a0479c340d30a1924 (patch) | |
tree | b266e0dcc3425932f052d0fcc73510d0205f5495 | |
parent | b9cdb3c4f674f49a8601aa7f60cd7b75dc719bd2 (diff) | |
download | chromium_src-780f68bde6e9713b2465358a0479c340d30a1924.zip chromium_src-780f68bde6e9713b2465358a0479c340d30a1924.tar.gz chromium_src-780f68bde6e9713b2465358a0479c340d30a1924.tar.bz2 |
Use ImageLoader instead of ImageLoadingTracker (Part 6)
BUG=163929
Review URL: https://chromiumcodereview.appspot.com/11889012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179802 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/image_loading_tracker.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/infobars/extension_infobar.cc | 55 | ||||
-rw-r--r-- | chrome/browser/ui/views/infobars/extension_infobar.h | 12 |
3 files changed, 33 insertions, 35 deletions
diff --git a/chrome/browser/extensions/image_loading_tracker.h b/chrome/browser/extensions/image_loading_tracker.h index 7541f44..6ac2077 100644 --- a/chrome/browser/extensions/image_loading_tracker.h +++ b/chrome/browser/extensions/image_loading_tracker.h @@ -130,7 +130,6 @@ class ImageLoadingTracker : public content::NotificationObserver { // This class is deprecated. This just lists all currently remaining // usage of this class, so once this list is empty this class can and // should be removed. - friend class ExtensionInfoBar; friend class extensions::IconImage; FRIEND_TEST_ALL_PREFIXES(ImageLoadingTrackerTest, Cache); FRIEND_TEST_ALL_PREFIXES(ImageLoadingTrackerTest, diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 552d794..36dd69e 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -7,6 +7,7 @@ #include "chrome/browser/extensions/extension_context_menu_model.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" +#include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/extensions/extension.h" @@ -80,7 +81,7 @@ ExtensionInfoBar::ExtensionInfoBar(Browser* browser, delegate_(delegate), browser_(browser), menu_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { delegate->set_observer(this); int height = delegate->height(); @@ -134,17 +135,40 @@ void ExtensionInfoBar::ViewHierarchyChanged(bool is_add, extension_misc::EXTENSION_ICON_BITTY; ExtensionResource icon_resource = extension->GetIconResource( image_size, ExtensionIconSet::MATCH_EXACTLY); - tracker_.LoadImage(extension, icon_resource, - gfx::Size(image_size, image_size), ImageLoadingTracker::DONT_CACHE); + extensions::ImageLoader* loader = + extensions::ImageLoader::Get(extension_host->profile()); + loader->LoadImageAsync( + extension, + icon_resource, + gfx::Size(image_size, image_size), + base::Bind(&ExtensionInfoBar::OnImageLoaded, + weak_ptr_factory_.GetWeakPtr())); } int ExtensionInfoBar::ContentMinimumWidth() const { return menu_->GetPreferredSize().width() + kMenuHorizontalMargin; } -void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image, - const std::string& extension_id, - int index) { +void ExtensionInfoBar::OnDelegateDeleted() { + delegate_ = NULL; +} + +void ExtensionInfoBar::OnMenuButtonClicked(views::View* source, + const gfx::Point& point) { + if (!owned()) + return; // We're closing; don't call anything, it might access the owner. + const extensions::Extension* extension = GetDelegate()->extension_host()-> + extension(); + if (!extension->ShowConfigureContextMenus()) + return; + + scoped_refptr<ExtensionContextMenuModel> options_menu_contents = + new ExtensionContextMenuModel(extension, browser_); + DCHECK_EQ(menu_, source); + RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); +} + +void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image) { if (!GetDelegate()) return; // The delegate can go away while we asynchronously load images. @@ -167,25 +191,6 @@ void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image, Layout(); } -void ExtensionInfoBar::OnDelegateDeleted() { - delegate_ = NULL; -} - -void ExtensionInfoBar::OnMenuButtonClicked(views::View* source, - const gfx::Point& point) { - if (!owned()) - return; // We're closing; don't call anything, it might access the owner. - const extensions::Extension* extension = GetDelegate()->extension_host()-> - extension(); - if (!extension->ShowConfigureContextMenus()) - return; - - scoped_refptr<ExtensionContextMenuModel> options_menu_contents = - new ExtensionContextMenuModel(extension, browser_); - DCHECK_EQ(menu_, source); - RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); -} - ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; } diff --git a/chrome/browser/ui/views/infobars/extension_infobar.h b/chrome/browser/ui/views/infobars/extension_infobar.h index 302afea..2ed7e57 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.h +++ b/chrome/browser/ui/views/infobars/extension_infobar.h @@ -7,7 +7,6 @@ #include "base/compiler_specific.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" -#include "chrome/browser/extensions/image_loading_tracker.h" #include "chrome/browser/ui/views/infobars/infobar_view.h" #include "ui/views/controls/button/menu_button_listener.h" @@ -17,7 +16,6 @@ class MenuButton; } class ExtensionInfoBar : public InfoBarView, - public ImageLoadingTracker::Observer, public ExtensionInfoBarDelegate::DelegateObserver, public views::MenuButtonListener { public: @@ -35,11 +33,6 @@ class ExtensionInfoBar : public InfoBarView, views::View* child) OVERRIDE; virtual int ContentMinimumWidth() const OVERRIDE; - // ImageLoadingTracker::Observer: - virtual void OnImageLoaded(const gfx::Image& image, - const std::string& extension_id, - int index) OVERRIDE; - // ExtensionInfoBarDelegate::DelegateObserver: virtual void OnDelegateDeleted() OVERRIDE; @@ -47,6 +40,8 @@ class ExtensionInfoBar : public InfoBarView, virtual void OnMenuButtonClicked(views::View* source, const gfx::Point& point) OVERRIDE; + void OnImageLoaded(const gfx::Image& image); + ExtensionInfoBarDelegate* GetDelegate(); // TODO(pkasting): This shadows InfoBarView::delegate_. Get rid of this once @@ -59,8 +54,7 @@ class ExtensionInfoBar : public InfoBarView, // The dropdown menu for accessing the contextual extension actions. views::MenuButton* menu_; - // Keeps track of images being loaded on the File thread. - ImageLoadingTracker tracker_; + base::WeakPtrFactory<ExtensionInfoBar> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar); }; |