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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_icon_source.cc

Issue 505913002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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) 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/webui/extensions/extension_icon_source.h" 5 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // If the request data cannot be parsed, request parameters will not be 127 // If the request data cannot be parsed, request parameters will not be
128 // added to |request_map_|. 128 // added to |request_map_|.
129 // Send back the default application icon (not resized or desaturated) as 129 // Send back the default application icon (not resized or desaturated) as
130 // the default response. 130 // the default response.
131 callback.Run(BitmapToMemory(GetDefaultAppImage()).get()); 131 callback.Run(BitmapToMemory(GetDefaultAppImage()).get());
132 return; 132 return;
133 } 133 }
134 134
135 ExtensionIconRequest* request = GetData(next_id); 135 ExtensionIconRequest* request = GetData(next_id);
136 ExtensionResource icon = IconsInfo::GetIconResource( 136 ExtensionResource icon = IconsInfo::GetIconResource(
137 request->extension, request->size, request->match); 137 request->extension.get(), request->size, request->match);
138 138
139 if (icon.relative_path().empty()) { 139 if (icon.relative_path().empty()) {
140 LoadIconFailed(next_id); 140 LoadIconFailed(next_id);
141 } else { 141 } else {
142 LoadExtensionImage(icon, next_id); 142 LoadExtensionImage(icon, next_id);
143 } 143 }
144 } 144 }
145 145
146 ExtensionIconSource::~ExtensionIconSource() { 146 ExtensionIconSource::~ExtensionIconSource() {
147 // Clean up all the temporary data we're holding for requests. 147 // Clean up all the temporary data we're holding for requests.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (resized_image.empty()) 196 if (resized_image.empty())
197 resized_image = *default_image; 197 resized_image = *default_image;
198 198
199 FinalizeImage(&resized_image, request_id); 199 FinalizeImage(&resized_image, request_id);
200 } 200 }
201 201
202 void ExtensionIconSource::LoadExtensionImage(const ExtensionResource& icon, 202 void ExtensionIconSource::LoadExtensionImage(const ExtensionResource& icon,
203 int request_id) { 203 int request_id) {
204 ExtensionIconRequest* request = GetData(request_id); 204 ExtensionIconRequest* request = GetData(request_id);
205 ImageLoader::Get(profile_)->LoadImageAsync( 205 ImageLoader::Get(profile_)->LoadImageAsync(
206 request->extension, icon, 206 request->extension.get(),
207 icon,
207 gfx::Size(request->size, request->size), 208 gfx::Size(request->size, request->size),
208 base::Bind(&ExtensionIconSource::OnImageLoaded, AsWeakPtr(), request_id)); 209 base::Bind(&ExtensionIconSource::OnImageLoaded, AsWeakPtr(), request_id));
209 } 210 }
210 211
211 void ExtensionIconSource::LoadFaviconImage(int request_id) { 212 void ExtensionIconSource::LoadFaviconImage(int request_id) {
212 FaviconService* favicon_service = 213 FaviconService* favicon_service =
213 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 214 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
214 // Fall back to the default icons if the service isn't available. 215 // Fall back to the default icons if the service isn't available.
215 if (favicon_service == NULL) { 216 if (favicon_service == NULL) {
216 LoadDefaultImage(request_id); 217 LoadDefaultImage(request_id);
217 return; 218 return;
218 } 219 }
219 220
220 GURL favicon_url = 221 GURL favicon_url =
221 AppLaunchInfo::GetFullLaunchURL(GetData(request_id)->extension); 222 AppLaunchInfo::GetFullLaunchURL(GetData(request_id)->extension.get());
222 favicon_service->GetRawFaviconForPageURL( 223 favicon_service->GetRawFaviconForPageURL(
223 favicon_url, 224 favicon_url,
224 favicon_base::FAVICON, 225 favicon_base::FAVICON,
225 gfx::kFaviconSize, 226 gfx::kFaviconSize,
226 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, 227 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable,
227 base::Unretained(this), 228 base::Unretained(this),
228 request_id), 229 request_id),
229 &cancelable_task_tracker_); 230 &cancelable_task_tracker_);
230 } 231 }
231 232
(...skipping 23 matching lines...) Expand all
255 const gfx::Image& image) { 256 const gfx::Image& image) {
256 if (image.IsEmpty()) 257 if (image.IsEmpty())
257 LoadIconFailed(request_id); 258 LoadIconFailed(request_id);
258 else 259 else
259 FinalizeImage(image.ToSkBitmap(), request_id); 260 FinalizeImage(image.ToSkBitmap(), request_id);
260 } 261 }
261 262
262 void ExtensionIconSource::LoadIconFailed(int request_id) { 263 void ExtensionIconSource::LoadIconFailed(int request_id) {
263 ExtensionIconRequest* request = GetData(request_id); 264 ExtensionIconRequest* request = GetData(request_id);
264 ExtensionResource icon = IconsInfo::GetIconResource( 265 ExtensionResource icon = IconsInfo::GetIconResource(
265 request->extension, request->size, request->match); 266 request->extension.get(), request->size, request->match);
266 267
267 if (request->size == extension_misc::EXTENSION_ICON_BITTY) 268 if (request->size == extension_misc::EXTENSION_ICON_BITTY)
268 LoadFaviconImage(request_id); 269 LoadFaviconImage(request_id);
269 else 270 else
270 LoadDefaultImage(request_id); 271 LoadDefaultImage(request_id);
271 } 272 }
272 273
273 bool ExtensionIconSource::ParseData( 274 bool ExtensionIconSource::ParseData(
274 const std::string& path, 275 const std::string& path,
275 int request_id, 276 int request_id,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 std::map<int, ExtensionIconRequest*>::iterator i = 341 std::map<int, ExtensionIconRequest*>::iterator i =
341 request_map_.find(request_id); 342 request_map_.find(request_id);
342 if (i == request_map_.end()) 343 if (i == request_map_.end())
343 return; 344 return;
344 345
345 delete i->second; 346 delete i->second;
346 request_map_.erase(i); 347 request_map_.erase(i);
347 } 348 }
348 349
349 } // namespace extensions 350 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698