OLD | NEW |
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/search_engines/template_url_table_model.h" | 5 #include "chrome/browser/ui/search_engines/template_url_table_model.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/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 load_state_ = LOADING; | 94 load_state_ = LOADING; |
95 favicon_service->GetFavicon(favicon_url, history::FAVICON, | 95 favicon_service->GetFavicon(favicon_url, history::FAVICON, |
96 &request_consumer_, | 96 &request_consumer_, |
97 base::Bind(&ModelEntry::OnFaviconDataAvailable, | 97 base::Bind(&ModelEntry::OnFaviconDataAvailable, |
98 base::Unretained(this))); | 98 base::Unretained(this))); |
99 } | 99 } |
100 | 100 |
101 void OnFaviconDataAvailable( | 101 void OnFaviconDataAvailable( |
102 FaviconService::Handle handle, | 102 FaviconService::Handle handle, |
103 history::FaviconData favicon) { | 103 history::FaviconData favicon_data, |
| 104 std::vector<GURL> icon_urls_in_db) { |
104 load_state_ = LOADED; | 105 load_state_ = LOADED; |
105 if (favicon.is_valid() && gfx::PNGCodec::Decode(favicon.image_data->front(), | 106 if (favicon_data.has_valid_bitmaps()) { |
106 favicon.image_data->size(), | 107 scoped_refptr<base::RefCountedMemory> bitmap_data( |
107 &favicon_)) { | 108 favicon_data.first_bitmap()); |
108 model_->FaviconAvailable(this); | 109 if (gfx::PNGCodec::Decode(bitmap_data->front(), |
| 110 bitmap_data->size(), |
| 111 &favicon_)) { |
| 112 model_->FaviconAvailable(this); |
| 113 } |
109 } | 114 } |
110 } | 115 } |
111 | 116 |
112 TemplateURL* template_url_; | 117 TemplateURL* template_url_; |
113 SkBitmap favicon_; | 118 SkBitmap favicon_; |
114 LoadState load_state_; | 119 LoadState load_state_; |
115 TemplateURLTableModel* model_; | 120 TemplateURLTableModel* model_; |
116 CancelableRequestConsumer request_consumer_; | 121 CancelableRequestConsumer request_consumer_; |
117 | 122 |
118 DISALLOW_COPY_AND_ASSIGN(ModelEntry); | 123 DISALLOW_COPY_AND_ASSIGN(ModelEntry); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { | 371 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { |
367 std::vector<ModelEntry*>::iterator i = | 372 std::vector<ModelEntry*>::iterator i = |
368 std::find(entries_.begin(), entries_.end(), entry); | 373 std::find(entries_.begin(), entries_.end(), entry); |
369 DCHECK(i != entries_.end()); | 374 DCHECK(i != entries_.end()); |
370 NotifyChanged(static_cast<int>(i - entries_.begin())); | 375 NotifyChanged(static_cast<int>(i - entries_.begin())); |
371 } | 376 } |
372 | 377 |
373 void TemplateURLTableModel::OnTemplateURLServiceChanged() { | 378 void TemplateURLTableModel::OnTemplateURLServiceChanged() { |
374 Reload(); | 379 Reload(); |
375 } | 380 } |
OLD | NEW |