Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: chrome/browser/ui/panels/panel.cc

Issue 11886029: Use ImageLoader instead of ImageLoadingTracker (Part 9) (Closed) Base URL: https://git.chromium.org/chromium/src.git@Issue_163929
Patch Set: Rebasing Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/views/panels/panel_stack_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel.cc
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 6fe4d651f25cfa775f7ad96b0adf16cfdc56bd55..a785179789f47f19777bfe7e9115161783f585cd 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/browser/extensions/image_loader.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
#include "chrome/browser/lifetime/application_lifetime.h"
@@ -149,7 +150,8 @@ Panel::Panel(const std::string& app_name,
native_panel_(NULL),
attention_mode_(USE_PANEL_ATTENTION),
expansion_state_(EXPANDED),
- command_updater_(this) {
+ command_updater_(this),
+ ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_ptr_factory_(this)) {
}
Panel::~Panel() {
@@ -224,7 +226,8 @@ void Panel::InitCommandState() {
}
void Panel::OnNativePanelClosed() {
- app_icon_loader_.reset();
+ // Ensure previously enqueued OnImageLoaded callbacks are ignored.
+ image_loader_ptr_factory_.InvalidateWeakPtrs();
registrar_.RemoveAll();
manager()->OnPanelClosed(this);
DCHECK(!collection_);
@@ -829,24 +832,22 @@ void Panel::UpdateAppIcon() {
if (!extension)
return;
- app_icon_loader_.reset(new ImageLoadingTracker(this));
- app_icon_loader_->LoadImage(
+ extensions::ImageLoader* loader = extensions::ImageLoader::Get(profile());
+ loader->LoadImageAsync(
extension,
extension->GetIconResource(extension_misc::EXTENSION_ICON_SMALL,
ExtensionIconSet::MATCH_BIGGER),
gfx::Size(extension_misc::EXTENSION_ICON_SMALL,
extension_misc::EXTENSION_ICON_SMALL),
- ImageLoadingTracker::CACHE);
+ base::Bind(&Panel::OnImageLoaded,
+ image_loader_ptr_factory_.GetWeakPtr()));
}
-void Panel::OnImageLoaded(const gfx::Image& image,
- const std::string& extension_id,
- int index) {
+void Panel::OnImageLoaded(const gfx::Image& image) {
if (!image.IsEmpty()) {
app_icon_ = image;
native_panel_->UpdatePanelTitleBar();
}
- app_icon_loader_.reset();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PANEL_APP_ICON_LOADED,
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/views/panels/panel_stack_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698