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 load_state_ = LOADED; | 104 load_state_ = LOADED; |
105 if (favicon.is_valid() && gfx::PNGCodec::Decode(favicon.image_data->front(), | 105 if (favicon_data.is_valid()) { |
106 favicon.image_data->size(), | 106 const history::FaviconDataElement& element = |
107 &favicon_)) { | 107 favicon_data.elements[0]; |
108 model_->FaviconAvailable(this); | 108 if (gfx::PNGCodec::Decode(element.bitmap_data->front(), |
| 109 element.bitmap_data->size(), |
| 110 &favicon_)) { |
| 111 model_->FaviconAvailable(this); |
| 112 } |
109 } | 113 } |
110 } | 114 } |
111 | 115 |
112 TemplateURL* template_url_; | 116 TemplateURL* template_url_; |
113 SkBitmap favicon_; | 117 SkBitmap favicon_; |
114 LoadState load_state_; | 118 LoadState load_state_; |
115 TemplateURLTableModel* model_; | 119 TemplateURLTableModel* model_; |
116 CancelableRequestConsumer request_consumer_; | 120 CancelableRequestConsumer request_consumer_; |
117 | 121 |
118 DISALLOW_COPY_AND_ASSIGN(ModelEntry); | 122 DISALLOW_COPY_AND_ASSIGN(ModelEntry); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { | 370 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { |
367 std::vector<ModelEntry*>::iterator i = | 371 std::vector<ModelEntry*>::iterator i = |
368 std::find(entries_.begin(), entries_.end(), entry); | 372 std::find(entries_.begin(), entries_.end(), entry); |
369 DCHECK(i != entries_.end()); | 373 DCHECK(i != entries_.end()); |
370 NotifyChanged(static_cast<int>(i - entries_.begin())); | 374 NotifyChanged(static_cast<int>(i - entries_.begin())); |
371 } | 375 } |
372 | 376 |
373 void TemplateURLTableModel::OnTemplateURLServiceChanged() { | 377 void TemplateURLTableModel::OnTemplateURLServiceChanged() { |
374 Reload(); | 378 Reload(); |
375 } | 379 } |
OLD | NEW |