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

Side by Side Diff: chrome/browser/ui/search_engines/template_url_table_model.cc

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: removed the callback6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/search_engines/template_url_table_model.h" 5 #include "chrome/browser/ui/search_engines/template_url_table_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/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // The favicon url isn't always set. Guess at one here. 84 // The favicon url isn't always set. Guess at one here.
85 if (template_url_.url() && template_url_.url()->IsValid()) { 85 if (template_url_.url() && template_url_.url()->IsValid()) {
86 GURL url = GURL(template_url_.url()->url()); 86 GURL url = GURL(template_url_.url()->url());
87 if (url.is_valid()) 87 if (url.is_valid())
88 fav_icon_url = TemplateURL::GenerateFaviconURL(url); 88 fav_icon_url = TemplateURL::GenerateFaviconURL(url);
89 } 89 }
90 if (!fav_icon_url.is_valid()) 90 if (!fav_icon_url.is_valid())
91 return; 91 return;
92 } 92 }
93 load_state_ = LOADING; 93 load_state_ = LOADING;
94 favicon_service->GetFavicon(fav_icon_url, 94 favicon_service->GetFavicon(
95 &request_consumer_, 95 fav_icon_url,
96 NewCallback(this, &ModelEntry::OnFavIconDataAvailable)); 96 history::FAV_ICON,
97 &request_consumer_,
98 NewCallback(this, &ModelEntry::OnFavIconDataAvailable));
97 } 99 }
98 100
99 void OnFavIconDataAvailable( 101 void OnFavIconDataAvailable(
100 FaviconService::Handle handle, 102 FaviconService::Handle handle,
101 bool know_favicon, 103 FaviconService::FaviconData favicon) {
102 scoped_refptr<RefCountedMemory> data,
103 bool expired,
104 GURL icon_url) {
105 load_state_ = LOADED; 104 load_state_ = LOADED;
106 if (know_favicon && data.get() && 105 if (favicon.known_icon && favicon.image_data.get() &&
107 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon_)) { 106 gfx::PNGCodec::Decode(favicon.image_data->front(),
107 favicon.image_data->size(), &fav_icon_)) {
108 model_->FavIconAvailable(this); 108 model_->FavIconAvailable(this);
109 } 109 }
110 } 110 }
111 111
112 const TemplateURL& template_url_; 112 const TemplateURL& template_url_;
113 SkBitmap fav_icon_; 113 SkBitmap fav_icon_;
114 LoadState load_state_; 114 LoadState load_state_;
115 TemplateURLTableModel* model_; 115 TemplateURLTableModel* model_;
116 CancelableRequestConsumer request_consumer_; 116 CancelableRequestConsumer request_consumer_;
117 117
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { 372 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) {
373 std::vector<ModelEntry*>::iterator i = 373 std::vector<ModelEntry*>::iterator i =
374 find(entries_.begin(), entries_.end(), entry); 374 find(entries_.begin(), entries_.end(), entry);
375 DCHECK(i != entries_.end()); 375 DCHECK(i != entries_.end());
376 NotifyChanged(static_cast<int>(i - entries_.begin())); 376 NotifyChanged(static_cast<int>(i - entries_.begin()));
377 } 377 }
378 378
379 void TemplateURLTableModel::OnTemplateURLModelChanged() { 379 void TemplateURLTableModel::OnTemplateURLModelChanged() {
380 Reload(); 380 Reload();
381 } 381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698