| 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" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/favicon/favicon_service.h" | 12 #include "chrome/browser/favicon/favicon_service.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
| 15 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
| 16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 17 #include "grit/ui_resources.h" | 18 #include "grit/ui_resources.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/models/table_model_observer.h" | 21 #include "ui/base/models/table_model_observer.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 23 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 private: | 69 private: |
| 69 // State of the favicon. | 70 // State of the favicon. |
| 70 enum LoadState { | 71 enum LoadState { |
| 71 NOT_LOADED, | 72 NOT_LOADED, |
| 72 LOADING, | 73 LOADING, |
| 73 LOADED | 74 LOADED |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 void LoadFavicon() { | 77 void LoadFavicon() { |
| 77 load_state_ = LOADED; | 78 load_state_ = LOADED; |
| 78 FaviconService* favicon_service = | 79 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
| 79 model_->template_url_service()->profile()->GetFaviconService( | 80 model_->template_url_service()->profile(), Profile::EXPLICIT_ACCESS); |
| 80 Profile::EXPLICIT_ACCESS); | |
| 81 if (!favicon_service) | 81 if (!favicon_service) |
| 82 return; | 82 return; |
| 83 GURL favicon_url = template_url()->favicon_url(); | 83 GURL favicon_url = template_url()->favicon_url(); |
| 84 if (!favicon_url.is_valid()) { | 84 if (!favicon_url.is_valid()) { |
| 85 // The favicon url isn't always set. Guess at one here. | 85 // The favicon url isn't always set. Guess at one here. |
| 86 if (template_url_->url_ref().IsValid()) { | 86 if (template_url_->url_ref().IsValid()) { |
| 87 GURL url(template_url_->url()); | 87 GURL url(template_url_->url()); |
| 88 if (url.is_valid()) | 88 if (url.is_valid()) |
| 89 favicon_url = TemplateURL::GenerateFaviconURL(url); | 89 favicon_url = TemplateURL::GenerateFaviconURL(url); |
| 90 } | 90 } |
| (...skipping 275 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 |