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/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/favicon/favicon_handler.h" | 8 #include "chrome/browser/favicon/favicon_handler.h" |
9 #include "chrome/browser/favicon/favicon_service_factory.h" | 9 #include "chrome/browser/favicon/favicon_service_factory.h" |
10 #include "chrome/browser/favicon/favicon_util.h" | 10 #include "chrome/browser/favicon/favicon_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 using content::FaviconStatus; | 31 using content::FaviconStatus; |
32 using content::NavigationController; | 32 using content::NavigationController; |
33 using content::NavigationEntry; | 33 using content::NavigationEntry; |
34 using content::WebContents; | 34 using content::WebContents; |
35 | 35 |
36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); | 36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); |
37 | 37 |
38 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) | 38 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) |
39 : content::WebContentsObserver(web_contents), | 39 : content::WebContentsObserver(web_contents), |
40 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { | 40 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
41 favicon_handler_.reset(new FaviconHandler(profile_, this, | 41 favicon_handler_.reset( |
42 FaviconHandler::FAVICON)); | 42 new FaviconHandler(profile_, this, this, FaviconHandler::FAVICON)); |
43 if (chrome::kEnableTouchIcon) | 43 if (chrome::kEnableTouchIcon) |
44 touch_icon_handler_.reset(new FaviconHandler(profile_, this, | 44 touch_icon_handler_.reset( |
45 FaviconHandler::TOUCH)); | 45 new FaviconHandler(profile_, this, this, FaviconHandler::TOUCH)); |
46 } | 46 } |
47 | 47 |
48 FaviconTabHelper::~FaviconTabHelper() { | 48 FaviconTabHelper::~FaviconTabHelper() { |
49 } | 49 } |
50 | 50 |
51 void FaviconTabHelper::FetchFavicon(const GURL& url) { | 51 void FaviconTabHelper::FetchFavicon(const GURL& url) { |
52 favicon_handler_->FetchFavicon(url); | 52 favicon_handler_->FetchFavicon(url); |
53 if (touch_icon_handler_.get()) | 53 if (touch_icon_handler_.get()) |
54 touch_icon_handler_->FetchFavicon(url); | 54 touch_icon_handler_->FetchFavicon(url); |
55 } | 55 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 int32 page_id, | 185 int32 page_id, |
186 const std::vector<content::FaviconURL>& candidates) { | 186 const std::vector<content::FaviconURL>& candidates) { |
187 DCHECK(!candidates.empty()); | 187 DCHECK(!candidates.empty()); |
188 favicon_urls_ = candidates; | 188 favicon_urls_ = candidates; |
189 | 189 |
190 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); | 190 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); |
191 if (touch_icon_handler_.get()) | 191 if (touch_icon_handler_.get()) |
192 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); | 192 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); |
193 } | 193 } |
194 | 194 |
| 195 FaviconService* FaviconTabHelper::GetFaviconService() { |
| 196 return FaviconServiceFactory::GetForProfile(profile_, |
| 197 Profile::EXPLICIT_ACCESS); |
| 198 } |
| 199 |
195 void FaviconTabHelper::DidDownloadFavicon( | 200 void FaviconTabHelper::DidDownloadFavicon( |
196 int id, | 201 int id, |
197 int http_status_code, | 202 int http_status_code, |
198 const GURL& image_url, | 203 const GURL& image_url, |
199 const std::vector<SkBitmap>& bitmaps, | 204 const std::vector<SkBitmap>& bitmaps, |
200 const std::vector<gfx::Size>& original_bitmap_sizes) { | 205 const std::vector<gfx::Size>& original_bitmap_sizes) { |
201 | 206 |
202 if (bitmaps.empty() && http_status_code == 404) { | 207 if (bitmaps.empty() && http_status_code == 404) { |
203 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 208 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
204 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 209 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
205 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); | 210 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); |
206 if (favicon_service) | 211 if (favicon_service) |
207 favicon_service->UnableToDownloadFavicon(image_url); | 212 favicon_service->UnableToDownloadFavicon(image_url); |
208 } | 213 } |
209 | 214 |
210 favicon_handler_->OnDidDownloadFavicon( | 215 favicon_handler_->OnDidDownloadFavicon( |
211 id, image_url, bitmaps, original_bitmap_sizes); | 216 id, image_url, bitmaps, original_bitmap_sizes); |
212 if (touch_icon_handler_.get()) { | 217 if (touch_icon_handler_.get()) { |
213 touch_icon_handler_->OnDidDownloadFavicon( | 218 touch_icon_handler_->OnDidDownloadFavicon( |
214 id, image_url, bitmaps, original_bitmap_sizes); | 219 id, image_url, bitmaps, original_bitmap_sizes); |
215 } | 220 } |
216 } | 221 } |
OLD | NEW |