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

Side by Side Diff: chrome/browser/possible_url_model.cc

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: sync Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/possible_url_model.h" 5 #include "chrome/browser/possible_url_model.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (i != favicon_map_.end()) { 156 if (i != favicon_map_.end()) {
157 // We already requested the favicon, return it. 157 // We already requested the favicon, return it.
158 if (!i->second.isNull()) 158 if (!i->second.isNull())
159 return i->second; 159 return i->second;
160 } else if (profile_) { 160 } else if (profile_) {
161 FaviconService* favicon_service = 161 FaviconService* favicon_service =
162 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 162 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
163 if (favicon_service) { 163 if (favicon_service) {
164 CancelableRequestProvider::Handle h = 164 CancelableRequestProvider::Handle h =
165 favicon_service->GetFaviconForURL( 165 favicon_service->GetFaviconForURL(
166 result.url, &consumer_, 166 result.url, history::FAVICON, &consumer_,
167 NewCallback(this, &PossibleURLModel::OnFaviconAvailable)); 167 NewCallback(this, &PossibleURLModel::OnFaviconAvailable));
168 consumer_.SetClientData(favicon_service, h, result.index); 168 consumer_.SetClientData(favicon_service, h, result.index);
169 // Add an entry to the map so that we don't attempt to request the 169 // Add an entry to the map so that we don't attempt to request the
170 // favicon again. 170 // favicon again.
171 favicon_map_[result.index] = SkBitmap(); 171 favicon_map_[result.index] = SkBitmap();
172 } 172 }
173 } 173 }
174 return *default_favicon; 174 return *default_favicon;
175 } 175 }
176 176
177 int PossibleURLModel::CompareValues(int row1, int row2, int column_id) { 177 int PossibleURLModel::CompareValues(int row1, int row2, int column_id) {
178 if (column_id == IDS_ASI_URL_COLUMN) { 178 if (column_id == IDS_ASI_URL_COLUMN) {
179 return results_[row1].display_url.Compare( 179 return results_[row1].display_url.Compare(
180 results_[row2].display_url, GetCollator()); 180 results_[row2].display_url, GetCollator());
181 } 181 }
182 return ui::TableModel::CompareValues(row1, row2, column_id); 182 return ui::TableModel::CompareValues(row1, row2, column_id);
183 } 183 }
184 184
185 void PossibleURLModel::OnFaviconAvailable( 185 void PossibleURLModel::OnFaviconAvailable(
186 FaviconService::Handle h, 186 FaviconService::Handle h,
187 bool favicon_available, 187 history::FaviconData favicon) {
188 scoped_refptr<RefCountedMemory> data,
189 bool expired,
190 GURL icon_url) {
191 if (profile_) { 188 if (profile_) {
192 FaviconService* favicon_service = 189 FaviconService* favicon_service =
193 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 190 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
194 size_t index = consumer_.GetClientData(favicon_service, h); 191 size_t index = consumer_.GetClientData(favicon_service, h);
195 if (favicon_available) { 192 if (favicon.is_valid()) {
196 // The decoder will leave our bitmap empty on error. 193 // The decoder will leave our bitmap empty on error.
197 gfx::PNGCodec::Decode(data->front(), data->size(), 194 gfx::PNGCodec::Decode(favicon.image_data->front(),
195 favicon.image_data->size(),
198 &(favicon_map_[index])); 196 &(favicon_map_[index]));
199 197
200 // Notify the observer. 198 // Notify the observer.
201 if (!favicon_map_[index].isNull() && observer_) 199 if (!favicon_map_[index].isNull() && observer_)
202 observer_->OnItemsChanged(static_cast<int>(index), 1); 200 observer_->OnItemsChanged(static_cast<int>(index), 1);
203 } 201 }
204 } 202 }
205 } 203 }
206 204
207 void PossibleURLModel::SetObserver(ui::TableModelObserver* observer) { 205 void PossibleURLModel::SetObserver(ui::TableModelObserver* observer) {
208 observer_ = observer; 206 observer_ = observer;
209 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698