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_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/favicon/favicon_handler.h" | 7 #include "chrome/browser/favicon/favicon_handler.h" |
8 #include "chrome/browser/favicon/favicon_service_factory.h" | 8 #include "chrome/browser/favicon/favicon_service_factory.h" |
9 #include "chrome/browser/favicon/favicon_util.h" | 9 #include "chrome/browser/favicon/favicon_util.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 FaviconService* service = FaviconServiceFactory::GetForProfile( | 107 FaviconService* service = FaviconServiceFactory::GetForProfile( |
108 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); | 108 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); |
109 if (!service) | 109 if (!service) |
110 return; | 110 return; |
111 const FaviconStatus& favicon(entry->GetFavicon()); | 111 const FaviconStatus& favicon(entry->GetFavicon()); |
112 if (!favicon.valid || favicon.url.is_empty() || | 112 if (!favicon.valid || favicon.url.is_empty() || |
113 favicon.image.IsEmpty()) { | 113 favicon.image.IsEmpty()) { |
114 return; | 114 return; |
115 } | 115 } |
116 std::vector<unsigned char> image_data; | 116 service->SetFavicons(entry->GetURL(), favicon.url, history::FAVICON, |
117 // TODO: Save all representations. | 117 favicon.image); |
118 gfx::PNGCodec::EncodeBGRASkBitmap( | |
119 favicon.image.AsBitmap(), false, &image_data); | |
120 service->SetFavicon( | |
121 entry->GetURL(), favicon.url, image_data, history::FAVICON); | |
122 } | 118 } |
123 | 119 |
124 int FaviconTabHelper::DownloadImage(const GURL& image_url, | 120 int FaviconTabHelper::DownloadImage(const GURL& image_url, |
125 int image_size, | 121 int image_size, |
126 history::IconType icon_type, | 122 history::IconType icon_type, |
127 const ImageDownloadCallback& callback) { | 123 const ImageDownloadCallback& callback) { |
128 if (icon_type == history::FAVICON) | 124 if (icon_type == history::FAVICON) |
129 return favicon_handler_->DownloadImage(image_url, image_size, icon_type, | 125 return favicon_handler_->DownloadImage(image_url, image_size, icon_type, |
130 callback); | 126 callback); |
131 else if (touch_icon_handler_.get()) | 127 else if (touch_icon_handler_.get()) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 bool errored, | 191 bool errored, |
196 int requested_size, | 192 int requested_size, |
197 const std::vector<SkBitmap>& bitmaps) { | 193 const std::vector<SkBitmap>& bitmaps) { |
198 favicon_handler_->OnDidDownloadFavicon( | 194 favicon_handler_->OnDidDownloadFavicon( |
199 id, image_url, errored, requested_size, bitmaps); | 195 id, image_url, errored, requested_size, bitmaps); |
200 if (touch_icon_handler_.get()) { | 196 if (touch_icon_handler_.get()) { |
201 touch_icon_handler_->OnDidDownloadFavicon( | 197 touch_icon_handler_->OnDidDownloadFavicon( |
202 id, image_url, errored, requested_size, bitmaps); | 198 id, image_url, errored, requested_size, bitmaps); |
203 } | 199 } |
204 } | 200 } |
OLD | NEW |