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

Side by Side Diff: components/favicon/core/browser/favicon_handler.cc

Issue 983043003: Componentize FaviconService and FaviconHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@favicon_service
Patch Set: Fix android_aosp (reverted the change by mistake by switching computer) Created 5 years, 9 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
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/favicon/favicon_handler.h" 5 #include "components/favicon/core/browser/favicon_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/favicon/favicon_service.h"
16 #include "components/favicon/core/browser/favicon_client.h" 15 #include "components/favicon/core/browser/favicon_client.h"
16 #include "components/favicon/core/browser/favicon_service.h"
17 #include "components/favicon/core/favicon_driver.h" 17 #include "components/favicon/core/favicon_driver.h"
18 #include "components/favicon_base/favicon_util.h" 18 #include "components/favicon_base/favicon_util.h"
19 #include "components/favicon_base/select_favicon_frames.h" 19 #include "components/favicon_base/select_favicon_frames.h"
20 #include "skia/ext/image_operations.h" 20 #include "skia/ext/image_operations.h"
21 #include "ui/gfx/codec/png_codec.h" 21 #include "ui/gfx/codec/png_codec.h"
22 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
23 #include "ui/gfx/image/image_util.h" 23 #include "ui/gfx/image/image_util.h"
24 24
25 using favicon::FaviconURL; 25 using favicon::FaviconURL;
26 26
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Returns true if at least one of |bitmap_results| is valid. 117 // Returns true if at least one of |bitmap_results| is valid.
118 bool HasValidResult( 118 bool HasValidResult(
119 const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) { 119 const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) {
120 return std::find_if(bitmap_results.begin(), bitmap_results.end(), IsValid) != 120 return std::find_if(bitmap_results.begin(), bitmap_results.end(), IsValid) !=
121 bitmap_results.end(); 121 bitmap_results.end();
122 } 122 }
123 123
124 // Returns the index of the entry with the largest area. 124 // Returns the index of the entry with the largest area.
125 int GetLargestSizeIndex(const std::vector<gfx::Size>& sizes) { 125 int GetLargestSizeIndex(const std::vector<gfx::Size>& sizes) {
126 DCHECK(!sizes.empty()); 126 DCHECK(!sizes.empty());
127 int ret = 0; 127 size_t ret = 0;
128 for (size_t i = 1; i < sizes.size(); ++i) { 128 for (size_t i = 1; i < sizes.size(); ++i) {
129 if (sizes[ret].GetArea() < sizes[i].GetArea()) 129 if (sizes[ret].GetArea() < sizes[i].GetArea())
130 ret = i; 130 ret = i;
131 } 131 }
132 return ret; 132 return static_cast<int>(ret);
133 } 133 }
134 134
135 // Return the index of a size which is same as the given |size|, -1 returned if 135 // Return the index of a size which is same as the given |size|, -1 returned if
136 // there is no such bitmap. 136 // there is no such bitmap.
137 int GetIndexBySize(const std::vector<gfx::Size>& sizes, 137 int GetIndexBySize(const std::vector<gfx::Size>& sizes,
138 const gfx::Size& size) { 138 const gfx::Size& size) {
139 DCHECK(!sizes.empty()); 139 DCHECK(!sizes.empty());
140 std::vector<gfx::Size>::const_iterator i = 140 std::vector<gfx::Size>::const_iterator i =
141 std::find(sizes.begin(), sizes.end(), size); 141 std::find(sizes.begin(), sizes.end(), size);
142 if (i == sizes.end()) 142 if (i == sizes.end())
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 continue; 684 continue;
685 685
686 gfx::Size largest = 686 gfx::Size largest =
687 image_url.icon_sizes[GetLargestSizeIndex(image_url.icon_sizes)]; 687 image_url.icon_sizes[GetLargestSizeIndex(image_url.icon_sizes)];
688 image_url.icon_sizes.clear(); 688 image_url.icon_sizes.clear();
689 image_url.icon_sizes.push_back(largest); 689 image_url.icon_sizes.push_back(largest);
690 } 690 }
691 std::stable_sort(image_urls_.begin(), image_urls_.end(), 691 std::stable_sort(image_urls_.begin(), image_urls_.end(),
692 CompareIconSize); 692 CompareIconSize);
693 } 693 }
OLDNEW
« no previous file with comments | « components/favicon/core/browser/favicon_handler.h ('k') | components/favicon/core/browser/favicon_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698