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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void LoadFavicon() { | 75 void LoadFavicon() { |
76 load_state_ = LOADED; | 76 load_state_ = LOADED; |
77 FaviconService* favicon_service = | 77 FaviconService* favicon_service = |
78 model_->template_url_service()->profile()->GetFaviconService( | 78 model_->template_url_service()->profile()->GetFaviconService( |
79 Profile::EXPLICIT_ACCESS); | 79 Profile::EXPLICIT_ACCESS); |
80 if (!favicon_service) | 80 if (!favicon_service) |
81 return; | 81 return; |
82 GURL favicon_url = template_url()->favicon_url(); | 82 GURL favicon_url = template_url()->favicon_url(); |
83 if (!favicon_url.is_valid()) { | 83 if (!favicon_url.is_valid()) { |
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_ref().IsValid()) { | 85 if (template_url_->url() && template_url_->url()->IsValid()) { |
86 GURL url(template_url_->url()); | 86 GURL url(template_url_->url()->url()); |
87 if (url.is_valid()) | 87 if (url.is_valid()) |
88 favicon_url = TemplateURL::GenerateFaviconURL(url); | 88 favicon_url = TemplateURL::GenerateFaviconURL(url); |
89 } | 89 } |
90 if (!favicon_url.is_valid()) | 90 if (!favicon_url.is_valid()) |
91 return; | 91 return; |
92 } | 92 } |
93 load_state_ = LOADING; | 93 load_state_ = LOADING; |
94 favicon_service->GetFavicon(favicon_url, history::FAVICON, | 94 favicon_service->GetFavicon(favicon_url, history::FAVICON, |
95 &request_consumer_, | 95 &request_consumer_, |
96 base::Bind(&ModelEntry::OnFaviconDataAvailable, | 96 base::Bind(&ModelEntry::OnFaviconDataAvailable, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { | 366 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { |
367 std::vector<ModelEntry*>::iterator i = | 367 std::vector<ModelEntry*>::iterator i = |
368 std::find(entries_.begin(), entries_.end(), entry); | 368 std::find(entries_.begin(), entries_.end(), entry); |
369 DCHECK(i != entries_.end()); | 369 DCHECK(i != entries_.end()); |
370 NotifyChanged(static_cast<int>(i - entries_.begin())); | 370 NotifyChanged(static_cast<int>(i - entries_.begin())); |
371 } | 371 } |
372 | 372 |
373 void TemplateURLTableModel::OnTemplateURLServiceChanged() { | 373 void TemplateURLTableModel::OnTemplateURLServiceChanged() { |
374 Reload(); | 374 Reload(); |
375 } | 375 } |
OLD | NEW |