| 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 14 matching lines...) Expand all Loading... |
| 25 // Group IDs used by TemplateURLTableModel. | 25 // Group IDs used by TemplateURLTableModel. |
| 26 static const int kMainGroupID = 0; | 26 static const int kMainGroupID = 0; |
| 27 static const int kOtherGroupID = 1; | 27 static const int kOtherGroupID = 1; |
| 28 | 28 |
| 29 // ModelEntry ---------------------------------------------------- | 29 // ModelEntry ---------------------------------------------------- |
| 30 | 30 |
| 31 // ModelEntry wraps a TemplateURL as returned from the TemplateURL. | 31 // ModelEntry wraps a TemplateURL as returned from the TemplateURL. |
| 32 // ModelEntry also tracks state information about the URL. | 32 // ModelEntry also tracks state information about the URL. |
| 33 | 33 |
| 34 // Icon used while loading, or if a specific favicon can't be found. | 34 // Icon used while loading, or if a specific favicon can't be found. |
| 35 static SkBitmap* default_icon = NULL; | 35 static gfx::ImageSkia* default_icon = NULL; |
| 36 | 36 |
| 37 class ModelEntry { | 37 class ModelEntry { |
| 38 public: | 38 public: |
| 39 ModelEntry(TemplateURLTableModel* model, TemplateURL* template_url) | 39 ModelEntry(TemplateURLTableModel* model, TemplateURL* template_url) |
| 40 : template_url_(template_url), | 40 : template_url_(template_url), |
| 41 load_state_(NOT_LOADED), | 41 load_state_(NOT_LOADED), |
| 42 model_(model) { | 42 model_(model) { |
| 43 if (!default_icon) { | 43 if (!default_icon) { |
| 44 default_icon = ResourceBundle::GetSharedInstance(). | 44 default_icon = ResourceBundle::GetSharedInstance(). |
| 45 GetBitmapNamed(IDR_DEFAULT_FAVICON); | 45 GetImageSkiaNamed(IDR_DEFAULT_FAVICON); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 TemplateURL* template_url() { | 49 TemplateURL* template_url() { |
| 50 return template_url_; | 50 return template_url_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::ImageSkia GetIcon() { | 53 gfx::ImageSkia GetIcon() { |
| 54 if (load_state_ == NOT_LOADED) | 54 if (load_state_ == NOT_LOADED) |
| 55 LoadFavicon(); | 55 LoadFavicon(); |
| (...skipping 310 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 |