| 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 14 matching lines...) Expand all Loading... |
| 25 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 26 #include "ui/gfx/image/image_util.h" | 26 #include "ui/gfx/image/image_util.h" |
| 27 | 27 |
| 28 using content::FaviconURL; | 28 using content::FaviconURL; |
| 29 using content::NavigationEntry; | 29 using content::NavigationEntry; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // Size (along each axis) of a touch icon. This currently corresponds to | 33 // Size (along each axis) of a touch icon. This currently corresponds to |
| 34 // the apple touch icon for iPad. | 34 // the apple touch icon for iPad. |
| 35 const int kTouchIconSize = 72; | 35 const int kTouchIconSize = 144; |
| 36 | 36 |
| 37 // Returns chrome::IconType the given icon_type corresponds to. | 37 // Returns chrome::IconType the given icon_type corresponds to. |
| 38 chrome::IconType ToHistoryIconType(FaviconURL::IconType icon_type) { | 38 chrome::IconType ToHistoryIconType(FaviconURL::IconType icon_type) { |
| 39 switch (icon_type) { | 39 switch (icon_type) { |
| 40 case FaviconURL::FAVICON: | 40 case FaviconURL::FAVICON: |
| 41 return chrome::FAVICON; | 41 return chrome::FAVICON; |
| 42 case FaviconURL::TOUCH_ICON: | 42 case FaviconURL::TOUCH_ICON: |
| 43 return chrome::TOUCH_ICON; | 43 return chrome::TOUCH_ICON; |
| 44 case FaviconURL::TOUCH_PRECOMPOSED_ICON: | 44 case FaviconURL::TOUCH_PRECOMPOSED_ICON: |
| 45 return chrome::TOUCH_PRECOMPOSED_ICON; | 45 return chrome::TOUCH_PRECOMPOSED_ICON; |
| 46 case FaviconURL::INVALID_ICON: | 46 case FaviconURL::INVALID_ICON: |
| 47 return chrome::INVALID_ICON; | 47 return chrome::INVALID_ICON; |
| 48 } | 48 } |
| 49 NOTREACHED(); | 49 NOTREACHED(); |
| 50 // Shouldn't reach here, just make compiler happy. | |
| 51 return chrome::INVALID_ICON; | 50 return chrome::INVALID_ICON; |
| 52 } | 51 } |
| 53 | 52 |
| 54 // Get the maximal icon size in pixels for a icon of type |icon_type| for the | 53 // Get the maximal icon size in pixels for a icon of type |icon_type| for the |
| 55 // current platform. | 54 // current platform. |
| 56 int GetMaximalIconSize(chrome::IconType icon_type) { | 55 int GetMaximalIconSize(chrome::IconType icon_type) { |
| 57 int base_size = 0; | |
| 58 switch (icon_type) { | 56 switch (icon_type) { |
| 59 case chrome::FAVICON: | 57 case chrome::FAVICON: |
| 60 base_size = gfx::kFaviconSize; | 58 #if defined(OS_ANDROID) |
| 61 break; | 59 return 192; |
| 60 #else |
| 61 return gfx::ImageSkia::GetMaxSupportedScale() * gfx::kFaviconSize; |
| 62 #endif |
| 62 case chrome::TOUCH_ICON: | 63 case chrome::TOUCH_ICON: |
| 63 case chrome::TOUCH_PRECOMPOSED_ICON: | 64 case chrome::TOUCH_PRECOMPOSED_ICON: |
| 64 base_size = kTouchIconSize; | 65 return kTouchIconSize; |
| 65 break; | |
| 66 case chrome::INVALID_ICON: | 66 case chrome::INVALID_ICON: |
| 67 base_size = 0; | 67 return 0; |
| 68 break; | |
| 69 } | 68 } |
| 70 return gfx::ImageSkia::GetMaxSupportedScale() * base_size; | 69 NOTREACHED(); |
| 70 return 0; |
| 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 546 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 |