Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: chrome/browser/ui/search_engines/template_url_table_model.cc

Issue 331163003: [Refactor] Change FaviconService API to take in a desired pixel size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/task/cancelable_task_tracker.h"
13 #include "chrome/browser/favicon/favicon_service.h" 13 #include "chrome/browser/favicon/favicon_service.h"
14 #include "chrome/browser/favicon/favicon_service_factory.h" 14 #include "chrome/browser/favicon/favicon_service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 16 #include "chrome/browser/search_engines/template_url_service.h"
17 #include "components/favicon_base/favicon_types.h" 17 #include "components/favicon_base/favicon_types.h"
18 #include "components/search_engines/template_url.h" 18 #include "components/search_engines/template_url.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"
26 #include "ui/gfx/image/image_skia.h" 25 #include "ui/gfx/image/image_skia.h"
27 26
28 // Group IDs used by TemplateURLTableModel. 27 // Group IDs used by TemplateURLTableModel.
29 static const int kMainGroupID = 0; 28 static const int kMainGroupID = 0;
30 static const int kOtherGroupID = 1; 29 static const int kOtherGroupID = 1;
31 static const int kExtensionGroupID = 2; 30 static const int kExtensionGroupID = 2;
32 31
33 // ModelEntry ---------------------------------------------------- 32 // ModelEntry ----------------------------------------------------
34 33
35 // ModelEntry wraps a TemplateURL as returned from the TemplateURL. 34 // ModelEntry wraps a TemplateURL as returned from the TemplateURL.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GURL url(template_url_->url()); 90 GURL url(template_url_->url());
92 if (url.is_valid()) 91 if (url.is_valid())
93 favicon_url = TemplateURL::GenerateFaviconURL(url); 92 favicon_url = TemplateURL::GenerateFaviconURL(url);
94 } 93 }
95 if (!favicon_url.is_valid()) 94 if (!favicon_url.is_valid())
96 return; 95 return;
97 } 96 }
98 load_state_ = LOADING; 97 load_state_ = LOADING;
99 favicon_service->GetFaviconImage( 98 favicon_service->GetFaviconImage(
100 favicon_url, 99 favicon_url,
101 favicon_base::FAVICON,
102 gfx::kFaviconSize,
103 base::Bind(&ModelEntry::OnFaviconDataAvailable, base::Unretained(this)), 100 base::Bind(&ModelEntry::OnFaviconDataAvailable, base::Unretained(this)),
104 &tracker_); 101 &tracker_);
105 } 102 }
106 103
107 void OnFaviconDataAvailable( 104 void OnFaviconDataAvailable(
108 const favicon_base::FaviconImageResult& image_result) { 105 const favicon_base::FaviconImageResult& image_result) {
109 load_state_ = LOADED; 106 load_state_ = LOADED;
110 if (!image_result.image.IsEmpty()) { 107 if (!image_result.image.IsEmpty()) {
111 favicon_ = image_result.image.AsImageSkia(); 108 favicon_ = image_result.image.AsImageSkia();
112 model_->FaviconAvailable(this); 109 model_->FaviconAvailable(this);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 return entry.Pass(); 390 return entry.Pass();
394 } 391 }
395 392
396 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) { 393 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) {
397 entries_.insert(entries_.begin() + index, entry.release()); 394 entries_.insert(entries_.begin() + index, entry.release());
398 if (index <= last_other_engine_index_) 395 if (index <= last_other_engine_index_)
399 ++last_other_engine_index_; 396 ++last_other_engine_index_;
400 if (observer_) 397 if (observer_)
401 observer_->OnItemsAdded(index, 1); 398 observer_->OnItemsAdded(index, 1);
402 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698