| 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/favicon/favicon_handler.h" | 5 #include "chrome/browser/favicon/favicon_handler.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 base_size = gfx::kFaviconSize; | 60 base_size = gfx::kFaviconSize; |
| 61 break; | 61 break; |
| 62 case chrome::TOUCH_ICON: | 62 case chrome::TOUCH_ICON: |
| 63 case chrome::TOUCH_PRECOMPOSED_ICON: | 63 case chrome::TOUCH_PRECOMPOSED_ICON: |
| 64 base_size = kTouchIconSize; | 64 base_size = kTouchIconSize; |
| 65 break; | 65 break; |
| 66 case chrome::INVALID_ICON: | 66 case chrome::INVALID_ICON: |
| 67 base_size = 0; | 67 base_size = 0; |
| 68 break; | 68 break; |
| 69 } | 69 } |
| 70 return ui::GetScaleFactorScale(ui::GetMaxScaleFactor()) * base_size; | 70 return gfx::ImageSkia::GetMaxSupportedScale() * base_size; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool DoUrlAndIconMatch(const FaviconURL& favicon_url, | 73 bool DoUrlAndIconMatch(const FaviconURL& favicon_url, |
| 74 const GURL& url, | 74 const GURL& url, |
| 75 chrome::IconType icon_type) { | 75 chrome::IconType icon_type) { |
| 76 return favicon_url.icon_url == url && | 76 return favicon_url.icon_url == url && |
| 77 favicon_url.icon_type == static_cast<FaviconURL::IconType>(icon_type); | 77 favicon_url.icon_type == static_cast<FaviconURL::IconType>(icon_type); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Returns true if all of the icon URLs and icon types in |bitmap_results| are | 80 // Returns true if all of the icon URLs and icon types in |bitmap_results| are |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // - Favicons inserted into the history backend by sync. | 141 // - Favicons inserted into the history backend by sync. |
| 142 // - Favicons for imported bookmarks. | 142 // - Favicons for imported bookmarks. |
| 143 std::vector<gfx::Size> favicon_sizes; | 143 std::vector<gfx::Size> favicon_sizes; |
| 144 for (size_t i = 0; i < bitmap_results.size(); ++i) | 144 for (size_t i = 0; i < bitmap_results.size(); ++i) |
| 145 favicon_sizes.push_back(bitmap_results[i].pixel_size); | 145 favicon_sizes.push_back(bitmap_results[i].pixel_size); |
| 146 | 146 |
| 147 std::vector<ui::ScaleFactor> scale_factors = | 147 std::vector<ui::ScaleFactor> scale_factors = |
| 148 FaviconUtil::GetFaviconScaleFactors(); | 148 FaviconUtil::GetFaviconScaleFactors(); |
| 149 for (size_t i = 0; i < scale_factors.size(); ++i) { | 149 for (size_t i = 0; i < scale_factors.size(); ++i) { |
| 150 int edge_size_in_pixel = floor( | 150 int edge_size_in_pixel = floor( |
| 151 desired_size_in_dip * ui::GetScaleFactorScale(scale_factors[i])); | 151 desired_size_in_dip * ui::GetImageScale(scale_factors[i])); |
| 152 std::vector<gfx::Size>::iterator it = std::find(favicon_sizes.begin(), | 152 std::vector<gfx::Size>::iterator it = std::find(favicon_sizes.begin(), |
| 153 favicon_sizes.end(), gfx::Size(edge_size_in_pixel, edge_size_in_pixel)); | 153 favicon_sizes.end(), gfx::Size(edge_size_in_pixel, edge_size_in_pixel)); |
| 154 if (it == favicon_sizes.end()) | 154 if (it == favicon_sizes.end()) |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 return false; | 157 return false; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Returns true if at least one of |bitmap_results| is valid. | 160 // Returns true if at least one of |bitmap_results| is valid. |
| 161 bool HasValidResult( | 161 bool HasValidResult( |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 GetMaximalIconSize(icon_type)); | 627 GetMaximalIconSize(icon_type)); |
| 628 if (download_id) { | 628 if (download_id) { |
| 629 // Download ids should be unique. | 629 // Download ids should be unique. |
| 630 DCHECK(download_requests_.find(download_id) == download_requests_.end()); | 630 DCHECK(download_requests_.find(download_id) == download_requests_.end()); |
| 631 download_requests_[download_id] = | 631 download_requests_[download_id] = |
| 632 DownloadRequest(url, image_url, icon_type); | 632 DownloadRequest(url, image_url, icon_type); |
| 633 } | 633 } |
| 634 | 634 |
| 635 return download_id; | 635 return download_id; |
| 636 } | 636 } |
| OLD | NEW |