OLD | NEW |
---|---|
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 Loading... | |
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 bool know_favicon, |
102 scoped_refptr<RefCountedMemory> data, | 104 scoped_refptr<RefCountedMemory> data, |
103 bool expired, | 105 bool expired, |
104 GURL icon_url) { | 106 GURL icon_url, |
107 history::IconType) { | |
sky
2011/03/09 21:41:08
name
michaelbai
2011/03/09 23:11:45
Done.
| |
105 load_state_ = LOADED; | 108 load_state_ = LOADED; |
106 if (know_favicon && data.get() && | 109 if (know_favicon && data.get() && |
107 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon_)) { | 110 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon_)) { |
108 model_->FavIconAvailable(this); | 111 model_->FavIconAvailable(this); |
109 } | 112 } |
110 } | 113 } |
111 | 114 |
112 const TemplateURL& template_url_; | 115 const TemplateURL& template_url_; |
113 SkBitmap fav_icon_; | 116 SkBitmap fav_icon_; |
114 LoadState load_state_; | 117 LoadState load_state_; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { | 375 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { |
373 std::vector<ModelEntry*>::iterator i = | 376 std::vector<ModelEntry*>::iterator i = |
374 find(entries_.begin(), entries_.end(), entry); | 377 find(entries_.begin(), entries_.end(), entry); |
375 DCHECK(i != entries_.end()); | 378 DCHECK(i != entries_.end()); |
376 NotifyChanged(static_cast<int>(i - entries_.begin())); | 379 NotifyChanged(static_cast<int>(i - entries_.begin())); |
377 } | 380 } |
378 | 381 |
379 void TemplateURLTableModel::OnTemplateURLModelChanged() { | 382 void TemplateURLTableModel::OnTemplateURLModelChanged() { |
380 Reload(); | 383 Reload(); |
381 } | 384 } |
OLD | NEW |