| 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/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/task/cancelable_task_tracker.h" |
| 12 #include "chrome/browser/favicon/favicon_service.h" | 13 #include "chrome/browser/favicon/favicon_service.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" | 14 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search_engines/template_url.h" | 16 #include "chrome/browser/search_engines/template_url.h" |
| 16 #include "chrome/browser/search_engines/template_url_service.h" | 17 #include "chrome/browser/search_engines/template_url_service.h" |
| 17 #include "chrome/common/cancelable_task_tracker.h" | |
| 18 #include "chrome/common/favicon/favicon_types.h" | 18 #include "chrome/common/favicon/favicon_types.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 #include "grit/ui_resources.h" | 20 #include "grit/ui_resources.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/models/table_model_observer.h" | 23 #include "ui/base/models/table_model_observer.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/favicon_size.h" | 25 #include "ui/gfx/favicon_size.h" |
| 26 #include "ui/gfx/image/image_skia.h" | 26 #include "ui/gfx/image/image_skia.h" |
| 27 | 27 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (!image_result.image.IsEmpty()) { | 107 if (!image_result.image.IsEmpty()) { |
| 108 favicon_ = image_result.image.AsImageSkia(); | 108 favicon_ = image_result.image.AsImageSkia(); |
| 109 model_->FaviconAvailable(this); | 109 model_->FaviconAvailable(this); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 TemplateURL* template_url_; | 113 TemplateURL* template_url_; |
| 114 gfx::ImageSkia favicon_; | 114 gfx::ImageSkia favicon_; |
| 115 LoadState load_state_; | 115 LoadState load_state_; |
| 116 TemplateURLTableModel* model_; | 116 TemplateURLTableModel* model_; |
| 117 CancelableTaskTracker tracker_; | 117 base::CancelableTaskTracker tracker_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(ModelEntry); | 119 DISALLOW_COPY_AND_ASSIGN(ModelEntry); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 // TemplateURLTableModel ----------------------------------------- | 122 // TemplateURLTableModel ----------------------------------------- |
| 123 | 123 |
| 124 TemplateURLTableModel::TemplateURLTableModel( | 124 TemplateURLTableModel::TemplateURLTableModel( |
| 125 TemplateURLService* template_url_service) | 125 TemplateURLService* template_url_service) |
| 126 : observer_(NULL), | 126 : observer_(NULL), |
| 127 template_url_service_(template_url_service) { | 127 template_url_service_(template_url_service) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 return entry.Pass(); | 389 return entry.Pass(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) { | 392 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) { |
| 393 entries_.insert(entries_.begin() + index, entry.release()); | 393 entries_.insert(entries_.begin() + index, entry.release()); |
| 394 if (index <= last_other_engine_index_) | 394 if (index <= last_other_engine_index_) |
| 395 ++last_other_engine_index_; | 395 ++last_other_engine_index_; |
| 396 if (observer_) | 396 if (observer_) |
| 397 observer_->OnItemsAdded(index, 1); | 397 observer_->OnItemsAdded(index, 1); |
| 398 } | 398 } |
| OLD | NEW |