Chromium Code Reviews| 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_service.h" | 5 #include "chrome/browser/favicon/favicon_service.h" |
| 6 | 6 |
| 7 #include "base/hash.h" | |
| 7 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 8 #include "chrome/browser/favicon/favicon_util.h" | 9 #include "chrome/browser/favicon/favicon_util.h" |
| 9 #include "chrome/browser/history/history_backend.h" | 10 #include "chrome/browser/history/history_backend.h" |
| 10 #include "chrome/browser/history/history_service.h" | 11 #include "chrome/browser/history/history_service.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 12 #include "chrome/browser/history/select_favicon_frames.h" | 13 #include "chrome/browser/history/select_favicon_frames.h" |
| 13 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 15 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 bitmap_data_element.pixel_size = pixel_size; | 253 bitmap_data_element.pixel_size = pixel_size; |
| 253 bitmap_data_element.icon_url = icon_url; | 254 bitmap_data_element.icon_url = icon_url; |
| 254 | 255 |
| 255 favicon_bitmap_data.push_back(bitmap_data_element); | 256 favicon_bitmap_data.push_back(bitmap_data_element); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 history_service_->SetFavicons(page_url, icon_type, favicon_bitmap_data); | 260 history_service_->SetFavicons(page_url, icon_type, favicon_bitmap_data); |
| 260 } | 261 } |
| 261 | 262 |
| 263 void FaviconService::UnableToDownloadFavicon(const GURL& icon_url) { | |
| 264 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | |
|
palmer
2013/05/13 17:22:47
I don't think it matters a whole lot, but my insti
mef
2013/05/14 18:47:08
I thought about it, but hash_set seemed more natur
| |
| 265 missing_favicon_urls_.insert(url_hash); | |
| 266 } | |
| 267 | |
| 268 bool FaviconService::WasUnableToDownloadFavicon(const GURL& icon_url) const { | |
| 269 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | |
| 270 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); | |
| 271 } | |
| 272 | |
| 273 void FaviconService::ClearUnableToDownloadFavicons() { | |
| 274 missing_favicon_urls_.clear(); | |
| 275 } | |
| 276 | |
| 262 FaviconService::~FaviconService() {} | 277 FaviconService::~FaviconService() {} |
| 263 | 278 |
| 264 CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( | 279 CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( |
| 265 const FaviconForURLParams& params, | 280 const FaviconForURLParams& params, |
| 266 const std::vector<ui::ScaleFactor>& desired_scale_factors, | 281 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
| 267 const FaviconResultsCallback& callback, | 282 const FaviconResultsCallback& callback, |
| 268 CancelableTaskTracker* tracker) { | 283 CancelableTaskTracker* tracker) { |
| 269 if (params.page_url.SchemeIs(chrome::kChromeUIScheme) || | 284 if (params.page_url.SchemeIs(chrome::kChromeUIScheme) || |
| 270 params.page_url.SchemeIs(extensions::kExtensionScheme)) { | 285 params.page_url.SchemeIs(extensions::kExtensionScheme)) { |
| 271 CancelableTaskTracker::IsCanceledCallback is_canceled_cb; | 286 CancelableTaskTracker::IsCanceledCallback is_canceled_cb; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 361 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
| 347 &resized_bitmap_data)) { | 362 &resized_bitmap_data)) { |
| 348 callback.Run(history::FaviconBitmapResult()); | 363 callback.Run(history::FaviconBitmapResult()); |
| 349 return; | 364 return; |
| 350 } | 365 } |
| 351 | 366 |
| 352 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 367 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
| 353 &resized_bitmap_data); | 368 &resized_bitmap_data); |
| 354 callback.Run(bitmap_result); | 369 callback.Run(bitmap_result); |
| 355 } | 370 } |
| 371 | |
| OLD | NEW |