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

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: License year update 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/ash/launcher/launcher_app_icon_loader.h" 5 #include "chrome/browser/ui/ash/launcher/launcher_app_icon_loader.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/extensions/api/icons/icons_handler.h"
10 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_constants.h" 12 #include "chrome/common/extensions/extension_constants.h"
12 13
13 namespace { 14 namespace {
14 15
15 const extensions::Extension* GetExtensionByID(Profile* profile, 16 const extensions::Extension* GetExtensionByID(Profile* profile,
16 const std::string& id) { 17 const std::string& id) {
17 ExtensionService* service = profile->GetExtensionService(); 18 ExtensionService* service = profile->GetExtensionService();
18 if (!service) 19 if (!service)
19 return NULL; 20 return NULL;
(...skipping 20 matching lines...) Expand all
40 if (i->second == id) 41 if (i->second == id)
41 return; // Already loading the image. 42 return; // Already loading the image.
42 } 43 }
43 44
44 const extensions::Extension* extension = GetExtensionByID(profile_, id); 45 const extensions::Extension* extension = GetExtensionByID(profile_, id);
45 if (!extension) 46 if (!extension)
46 return; 47 return;
47 48
48 extensions::IconImage* image = new extensions::IconImage( 49 extensions::IconImage* image = new extensions::IconImage(
49 extension, 50 extension,
50 extension->icons(), 51 IconsInfo::GetIcons(extension),
51 extension_misc::EXTENSION_ICON_SMALL, 52 extension_misc::EXTENSION_ICON_SMALL,
52 extensions::Extension::GetDefaultIcon(true), 53 extensions::IconsInfo::GetDefaultIcon(true), // is app
53 this); 54 this);
54 // |map_| takes ownership of |image|. 55 // |map_| takes ownership of |image|.
55 map_[image] = id; 56 map_[image] = id;
56 57
57 // Triggers image loading now instead of depending on paint message. This 58 // Triggers image loading now instead of depending on paint message. This
58 // makes the temp blank image be shown for shorter time and improves user 59 // makes the temp blank image be shown for shorter time and improves user
59 // experience. See http://crbug.com/146114. 60 // experience. See http://crbug.com/146114.
60 image->image_skia().EnsureRepsForSupportedScaleFactors(); 61 image->image_skia().EnsureRepsForSupportedScaleFactors();
61 } 62 }
62 63
63 void LauncherAppIconLoader::ClearImage(const std::string& id) { 64 void LauncherAppIconLoader::ClearImage(const std::string& id) {
64 for (ImageToExtensionIDMap::iterator i = map_.begin(); 65 for (ImageToExtensionIDMap::iterator i = map_.begin();
65 i != map_.end(); ++i) { 66 i != map_.end(); ++i) {
66 if (i->second == id) { 67 if (i->second == id) {
67 delete i->first; 68 delete i->first;
68 map_.erase(i); 69 map_.erase(i);
69 break; 70 break;
70 } 71 }
71 } 72 }
72 } 73 }
73 74
74 void LauncherAppIconLoader::OnExtensionIconImageChanged( 75 void LauncherAppIconLoader::OnExtensionIconImageChanged(
75 extensions::IconImage* image) { 76 extensions::IconImage* image) {
76 ImageToExtensionIDMap::iterator i = map_.find(image); 77 ImageToExtensionIDMap::iterator i = map_.find(image);
77 if (i == map_.end()) 78 if (i == map_.end())
78 return; // The image has been removed, do nothing. 79 return; // The image has been removed, do nothing.
79 80
80 host_->SetAppImage(i->second, image->image_skia()); 81 host_->SetAppImage(i->second, image->image_skia());
81 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698