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

Side by Side Diff: chrome/browser/ui/webui/fileicon_source.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/webui/feedback_ui.cc ('k') | chrome/browser/ui/webui/inspect_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fileicon_source.h" 5 #include "chrome/browser/ui/webui/fileicon_source.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const content::URLDataSource::GotDataCallback& callback) { 107 const content::URLDataSource::GotDataCallback& callback) {
108 IconManager* im = g_browser_process->icon_manager(); 108 IconManager* im = g_browser_process->icon_manager();
109 gfx::Image* icon = im->LookupIconFromFilepath(path, icon_size); 109 gfx::Image* icon = im->LookupIconFromFilepath(path, icon_size);
110 110
111 if (icon) { 111 if (icon) {
112 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); 112 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes);
113 gfx::PNGCodec::EncodeBGRASkBitmap( 113 gfx::PNGCodec::EncodeBGRASkBitmap(
114 icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(), 114 icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(),
115 false, &icon_data->data()); 115 false, &icon_data->data());
116 116
117 callback.Run(icon_data); 117 callback.Run(icon_data.get());
118 } else { 118 } else {
119 // Attach the ChromeURLDataManager request ID to the history request. 119 // Attach the ChromeURLDataManager request ID to the history request.
120 IconRequestDetails details; 120 IconRequestDetails details;
121 details.callback = callback; 121 details.callback = callback;
122 details.scale_factor = scale_factor; 122 details.scale_factor = scale_factor;
123 123
124 // Icon was not in cache, go fetch it slowly. 124 // Icon was not in cache, go fetch it slowly.
125 im->LoadIcon(path, 125 im->LoadIcon(path,
126 icon_size, 126 icon_size,
127 base::Bind(&FileIconSource::OnFileIconDataAvailable, 127 base::Bind(&FileIconSource::OnFileIconDataAvailable,
(...skipping 28 matching lines...) Expand all
156 void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details, 156 void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details,
157 gfx::Image* icon) { 157 gfx::Image* icon) {
158 if (icon) { 158 if (icon) {
159 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); 159 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes);
160 gfx::PNGCodec::EncodeBGRASkBitmap( 160 gfx::PNGCodec::EncodeBGRASkBitmap(
161 icon->ToImageSkia()->GetRepresentation(details.scale_factor) 161 icon->ToImageSkia()->GetRepresentation(details.scale_factor)
162 .sk_bitmap(), 162 .sk_bitmap(),
163 false, 163 false,
164 &icon_data->data()); 164 &icon_data->data());
165 165
166 details.callback.Run(icon_data); 166 details.callback.Run(icon_data.get());
167 } else { 167 } else {
168 // TODO(glen): send a dummy icon. 168 // TODO(glen): send a dummy icon.
169 details.callback.Run(NULL); 169 details.callback.Run(NULL);
170 } 170 }
171 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/feedback_ui.cc ('k') | chrome/browser/ui/webui/inspect_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698