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/views/ash/launcher/launcher_favicon_loader.h" | 5 #include "chrome/browser/ui/views/ash/launcher/launcher_favicon_loader.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/favicon/favicon_util.h" | 8 #include "chrome/browser/favicon/favicon_util.h" |
9 #include "chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.
h" | 9 #include "chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.
h" |
10 #include "chrome/common/favicon_url.h" | 10 #include "chrome/common/favicon_url.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 void FaviconBitmapHandler::DownloadFavicon(const GURL& image_url) { | 108 void FaviconBitmapHandler::DownloadFavicon(const GURL& image_url) { |
109 int image_size = 0; // Request the full sized image. | 109 int image_size = 0; // Request the full sized image. |
110 pending_requests_.insert(image_url); | 110 pending_requests_.insert(image_url); |
111 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); | 111 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); |
112 FaviconUtil::DownloadFavicon(host, image_url, image_size); | 112 FaviconUtil::DownloadFavicon(host, image_url, image_size); |
113 } | 113 } |
114 | 114 |
115 void FaviconBitmapHandler::OnDidDownloadFavicon(int id, | 115 |
116 const GURL& image_url, | 116 void FaviconBitmapHandler::OnDidDownloadFavicon( |
117 bool errored, | 117 int id, |
118 const SkBitmap& bitmap) { | 118 const GURL& image_url, |
| 119 bool errored, |
| 120 int requested_size, |
| 121 const std::vector<SkBitmap>& bitmaps) { |
119 UrlSet::iterator iter = pending_requests_.find(image_url); | 122 UrlSet::iterator iter = pending_requests_.find(image_url); |
120 if (iter == pending_requests_.end()) { | 123 if (iter == pending_requests_.end()) { |
121 // Updates are received for all downloads; ignore unrequested urls. | 124 // Updates are received for all downloads; ignore unrequested urls. |
122 return; | 125 return; |
123 } | 126 } |
124 pending_requests_.erase(iter); | 127 pending_requests_.erase(iter); |
125 | 128 |
126 if (!errored) | 129 // Favicon bitmaps are ordered by decreasing width. |
127 AddFavicon(image_url, bitmap); | 130 if (!errored && !bitmaps.empty()) |
| 131 AddFavicon(image_url, bitmaps[0]); |
128 } | 132 } |
129 | 133 |
130 void FaviconBitmapHandler::AddFavicon(const GURL& image_url, | 134 void FaviconBitmapHandler::AddFavicon(const GURL& image_url, |
131 const SkBitmap& new_bitmap) { | 135 const SkBitmap& new_bitmap) { |
132 processed_requests_.insert(image_url); | 136 processed_requests_.insert(image_url); |
133 if (new_bitmap.height() > kMaxBitmapSize || | 137 if (new_bitmap.height() > kMaxBitmapSize || |
134 new_bitmap.width() > kMaxBitmapSize) | 138 new_bitmap.width() > kMaxBitmapSize) |
135 return; | 139 return; |
136 if (new_bitmap.height() < ash::kLauncherPreferredSize) | 140 if (new_bitmap.height() < ash::kLauncherPreferredSize) |
137 return; | 141 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const std::vector<FaviconURL>& candidates) { | 182 const std::vector<FaviconURL>& candidates) { |
179 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); | 183 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); |
180 } | 184 } |
181 | 185 |
182 void LauncherFaviconLoader::OnDidDownloadFavicon(int id, | 186 void LauncherFaviconLoader::OnDidDownloadFavicon(int id, |
183 const GURL& image_url, | 187 const GURL& image_url, |
184 bool errored, | 188 bool errored, |
185 const SkBitmap& bitmap) { | 189 const SkBitmap& bitmap) { |
186 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, bitmap); | 190 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, bitmap); |
187 } | 191 } |
OLD | NEW |