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

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

Issue 330603004: Rename FaviconBitmapXxx to FaviconRawBitmapXxx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 6 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/favicon_source.h" 5 #include "chrome/browser/ui/webui/favicon_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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/favicon/favicon_service_factory.h" 10 #include "chrome/browser/favicon/favicon_service_factory.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (url.spec() == 100 if (url.spec() ==
101 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { 101 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) {
102 callback.Run( 102 callback.Run(
103 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 103 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
104 history::kPrepopulatedPages[i].favicon_id, 104 history::kPrepopulatedPages[i].favicon_id,
105 scale_factor)); 105 scale_factor));
106 return; 106 return;
107 } 107 }
108 } 108 }
109 109
110 favicon_service->GetRawFaviconForURL( 110 favicon_service->GetRawFaviconForPageURL(
111 FaviconService::FaviconForURLParams(url, icon_types_, 111 FaviconService::FaviconForPageURLParams(
112 parsed.size_in_dip), 112 url, icon_types_, parsed.size_in_dip),
113 scale_factor, 113 scale_factor,
114 base::Bind(&FaviconSource::OnFaviconDataAvailable, 114 base::Bind(
115 base::Unretained(this), 115 &FaviconSource::OnFaviconDataAvailable,
116 IconRequest(callback, 116 base::Unretained(this),
117 url, 117 IconRequest(callback, url, parsed.size_in_dip, scale_factor)),
118 parsed.size_in_dip,
119 scale_factor)),
120 &cancelable_task_tracker_); 118 &cancelable_task_tracker_);
121 } 119 }
122 } 120 }
123 121
124 std::string FaviconSource::GetMimeType(const std::string&) const { 122 std::string FaviconSource::GetMimeType(const std::string&) const {
125 // We need to explicitly return a mime type, otherwise if the user tries to 123 // We need to explicitly return a mime type, otherwise if the user tries to
126 // drag the image they get no extension. 124 // drag the image they get no extension.
127 return "image/png"; 125 return "image/png";
128 } 126 }
129 127
(...skipping 21 matching lines...) Expand all
151 open_tabs->GetSyncedFaviconForPageURL(request.request_path.spec(), 149 open_tabs->GetSyncedFaviconForPageURL(request.request_path.spec(),
152 &response)) { 150 &response)) {
153 request.callback.Run(response.get()); 151 request.callback.Run(response.get());
154 return true; 152 return true;
155 } 153 }
156 return false; 154 return false;
157 } 155 }
158 156
159 void FaviconSource::OnFaviconDataAvailable( 157 void FaviconSource::OnFaviconDataAvailable(
160 const IconRequest& request, 158 const IconRequest& request,
161 const favicon_base::FaviconBitmapResult& bitmap_result) { 159 const favicon_base::FaviconRawBitmapResult& bitmap_result) {
162 if (bitmap_result.is_valid()) { 160 if (bitmap_result.is_valid()) {
163 // Forward the data along to the networking system. 161 // Forward the data along to the networking system.
164 request.callback.Run(bitmap_result.bitmap_data.get()); 162 request.callback.Run(bitmap_result.bitmap_data.get());
165 } else if (!HandleMissingResource(request)) { 163 } else if (!HandleMissingResource(request)) {
166 SendDefaultResponse(request); 164 SendDefaultResponse(request);
167 } 165 }
168 } 166 }
169 167
170 void FaviconSource::SendDefaultResponse( 168 void FaviconSource::SendDefaultResponse(
171 const content::URLDataSource::GotDataCallback& callback) { 169 const content::URLDataSource::GotDataCallback& callback) {
(...skipping 23 matching lines...) Expand all
195 193
196 if (!default_favicon) { 194 if (!default_favicon) {
197 default_favicon = ResourceBundle::GetSharedInstance() 195 default_favicon = ResourceBundle::GetSharedInstance()
198 .LoadDataResourceBytesForScale(resource_id, 196 .LoadDataResourceBytesForScale(resource_id,
199 icon_request.scale_factor); 197 icon_request.scale_factor);
200 default_favicons_[favicon_index] = default_favicon; 198 default_favicons_[favicon_index] = default_favicon;
201 } 199 }
202 200
203 icon_request.callback.Run(default_favicon); 201 icon_request.callback.Run(default_favicon);
204 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/favicon_source.h ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698