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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 int render_view_id, 122 int render_view_id,
123 const content::URLDataSource::GotDataCallback& callback) { 123 const content::URLDataSource::GotDataCallback& callback) {
124 // This is where everything gets started. First, parse the request and make 124 // This is where everything gets started. First, parse the request and make
125 // the request data available for later. 125 // the request data available for later.
126 static int next_id = 0; 126 static int next_id = 0;
127 if (!ParseData(path, ++next_id, callback)) { 127 if (!ParseData(path, ++next_id, callback)) {
128 // If the request data cannot be parsed, request parameters will not be 128 // If the request data cannot be parsed, request parameters will not be
129 // added to |request_map_|. 129 // added to |request_map_|.
130 // Send back the default application icon (not resized or desaturated) as 130 // Send back the default application icon (not resized or desaturated) as
131 // the default response. 131 // the default response.
132 callback.Run(BitmapToMemory(GetDefaultAppImage())); 132 callback.Run(BitmapToMemory(GetDefaultAppImage()).get());
133 return; 133 return;
134 } 134 }
135 135
136 ExtensionIconRequest* request = GetData(next_id); 136 ExtensionIconRequest* request = GetData(next_id);
137 extensions::ExtensionResource icon = extensions::IconsInfo::GetIconResource( 137 extensions::ExtensionResource icon = extensions::IconsInfo::GetIconResource(
138 request->extension, request->size, request->match); 138 request->extension, request->size, request->match);
139 139
140 if (icon.relative_path().empty()) { 140 if (icon.relative_path().empty()) {
141 LoadIconFailed(next_id); 141 LoadIconFailed(next_id);
142 } else { 142 } else {
(...skipping 24 matching lines...) Expand all
167 167
168 void ExtensionIconSource::FinalizeImage(const SkBitmap* image, 168 void ExtensionIconSource::FinalizeImage(const SkBitmap* image,
169 int request_id) { 169 int request_id) {
170 SkBitmap bitmap; 170 SkBitmap bitmap;
171 ExtensionIconRequest* request = GetData(request_id); 171 ExtensionIconRequest* request = GetData(request_id);
172 if (request->grayscale) 172 if (request->grayscale)
173 bitmap = DesaturateImage(image); 173 bitmap = DesaturateImage(image);
174 else 174 else
175 bitmap = *image; 175 bitmap = *image;
176 176
177 request->callback.Run(BitmapToMemory(&bitmap)); 177 request->callback.Run(BitmapToMemory(&bitmap).get());
178 ClearData(request_id); 178 ClearData(request_id);
179 } 179 }
180 180
181 void ExtensionIconSource::LoadDefaultImage(int request_id) { 181 void ExtensionIconSource::LoadDefaultImage(int request_id) {
182 ExtensionIconRequest* request = GetData(request_id); 182 ExtensionIconRequest* request = GetData(request_id);
183 const SkBitmap* default_image = NULL; 183 const SkBitmap* default_image = NULL;
184 184
185 if (request->extension->is_app()) 185 if (request->extension->is_app())
186 default_image = GetDefaultAppImage(); 186 default_image = GetDefaultAppImage();
187 else 187 else
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 void ExtensionIconSource::ClearData(int request_id) { 341 void ExtensionIconSource::ClearData(int request_id) {
342 std::map<int, ExtensionIconRequest*>::iterator i = 342 std::map<int, ExtensionIconRequest*>::iterator i =
343 request_map_.find(request_id); 343 request_map_.find(request_id);
344 if (i == request_map_.end()) 344 if (i == request_map_.end())
345 return; 345 return;
346 346
347 delete i->second; 347 delete i->second;
348 request_map_.erase(i); 348 request_map_.erase(i);
349 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698