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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 std::vector<float> scales = favicon_base::GetFaviconScales(); | 70 std::vector<float> scales = favicon_base::GetFaviconScales(); |
71 std::vector<int> sizes_in_pixel; | 71 std::vector<int> sizes_in_pixel; |
72 for (size_t i = 0; i < scales.size(); ++i) { | 72 for (size_t i = 0; i < scales.size(); ++i) { |
73 sizes_in_pixel.push_back(std::ceil(size_in_dip * scales[i])); | 73 sizes_in_pixel.push_back(std::ceil(size_in_dip * scales[i])); |
74 } | 74 } |
75 return sizes_in_pixel; | 75 return sizes_in_pixel; |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 FaviconService::FaviconService(Profile* profile) | 80 FaviconService::FaviconService(Profile* profile, FaviconClient* favicon_client) |
81 : history_service_(HistoryServiceFactory::GetForProfile( | 81 : history_service_( |
82 profile, Profile::EXPLICIT_ACCESS)), | 82 HistoryServiceFactory::GetForProfile(profile, |
83 profile_(profile) { | 83 Profile::EXPLICIT_ACCESS)), |
| 84 profile_(profile), |
| 85 favicon_client_(favicon_client) { |
84 } | 86 } |
85 | 87 |
86 // static | 88 // static |
87 void FaviconService::FaviconResultsCallbackRunner( | 89 void FaviconService::FaviconResultsCallbackRunner( |
88 const favicon_base::FaviconResultsCallback& callback, | 90 const favicon_base::FaviconResultsCallback& callback, |
89 const std::vector<favicon_base::FaviconRawBitmapResult>* results) { | 91 const std::vector<favicon_base::FaviconRawBitmapResult>* results) { |
90 callback.Run(*results); | 92 callback.Run(*results); |
91 } | 93 } |
92 | 94 |
93 base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( | 95 base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 433 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
432 &resized_bitmap_data)) { | 434 &resized_bitmap_data)) { |
433 callback.Run(favicon_base::FaviconRawBitmapResult()); | 435 callback.Run(favicon_base::FaviconRawBitmapResult()); |
434 return; | 436 return; |
435 } | 437 } |
436 | 438 |
437 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 439 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
438 &resized_bitmap_data); | 440 &resized_bitmap_data); |
439 callback.Run(bitmap_result); | 441 callback.Run(bitmap_result); |
440 } | 442 } |
OLD | NEW |