| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 11 #include "chrome/browser/history/history_backend.h" | 11 #include "chrome/browser/history/history_backend.h" |
| 12 #include "chrome/browser/history/history_service.h" | 12 #include "chrome/browser/history/history_service.h" |
| 13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 15 #include "chrome/common/importer/imported_favicon_usage.h" | |
| 16 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 17 #include "components/favicon_base/favicon_types.h" | 16 #include "components/favicon_base/favicon_types.h" |
| 18 #include "components/favicon_base/favicon_util.h" | 17 #include "components/favicon_base/favicon_util.h" |
| 19 #include "components/favicon_base/select_favicon_frames.h" | 18 #include "components/favicon_base/select_favicon_frames.h" |
| 20 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 21 #include "ui/gfx/codec/png_codec.h" |
| 23 #include "ui/gfx/favicon_size.h" | 22 #include "ui/gfx/favicon_size.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| 25 | 24 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (history_service_) | 276 if (history_service_) |
| 278 history_service_->SetFaviconsOutOfDateForPage(page_url); | 277 history_service_->SetFaviconsOutOfDateForPage(page_url); |
| 279 } | 278 } |
| 280 | 279 |
| 281 void FaviconService::CloneFavicon(const GURL& old_page_url, | 280 void FaviconService::CloneFavicon(const GURL& old_page_url, |
| 282 const GURL& new_page_url) { | 281 const GURL& new_page_url) { |
| 283 if (history_service_) | 282 if (history_service_) |
| 284 history_service_->CloneFavicons(old_page_url, new_page_url); | 283 history_service_->CloneFavicons(old_page_url, new_page_url); |
| 285 } | 284 } |
| 286 | 285 |
| 287 void FaviconService::SetImportedFavicons( | |
| 288 const std::vector<ImportedFaviconUsage>& favicon_usage) { | |
| 289 if (history_service_) | |
| 290 history_service_->SetImportedFavicons(favicon_usage); | |
| 291 } | |
| 292 | |
| 293 void FaviconService::MergeFavicon( | 286 void FaviconService::MergeFavicon( |
| 294 const GURL& page_url, | 287 const GURL& page_url, |
| 295 const GURL& icon_url, | 288 const GURL& icon_url, |
| 296 favicon_base::IconType icon_type, | 289 favicon_base::IconType icon_type, |
| 297 scoped_refptr<base::RefCountedMemory> bitmap_data, | 290 scoped_refptr<base::RefCountedMemory> bitmap_data, |
| 298 const gfx::Size& pixel_size) { | 291 const gfx::Size& pixel_size) { |
| 299 if (history_service_) { | 292 if (history_service_) { |
| 300 history_service_->MergeFavicon(page_url, icon_url, icon_type, bitmap_data, | 293 history_service_->MergeFavicon(page_url, icon_url, icon_type, bitmap_data, |
| 301 pixel_size); | 294 pixel_size); |
| 302 } | 295 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 426 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
| 434 &resized_bitmap_data)) { | 427 &resized_bitmap_data)) { |
| 435 callback.Run(favicon_base::FaviconRawBitmapResult()); | 428 callback.Run(favicon_base::FaviconRawBitmapResult()); |
| 436 return; | 429 return; |
| 437 } | 430 } |
| 438 | 431 |
| 439 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 432 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
| 440 &resized_bitmap_data); | 433 &resized_bitmap_data); |
| 441 callback.Run(bitmap_result); | 434 callback.Run(bitmap_result); |
| 442 } | 435 } |
| OLD | NEW |