| 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/chrome_favicon_client.h" | 8 #include "chrome/browser/favicon/chrome_favicon_client.h" |
| 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
| 9 #include "chrome/browser/favicon/favicon_handler.h" | 10 #include "chrome/browser/favicon/favicon_handler.h" |
| 10 #include "chrome/browser/favicon/favicon_service.h" | 11 #include "chrome/browser/favicon/favicon_service.h" |
| 11 #include "chrome/browser/favicon/favicon_service_factory.h" | 12 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 12 #include "chrome/browser/favicon/favicon_util.h" | 13 #include "chrome/browser/favicon/favicon_util.h" |
| 13 #include "chrome/browser/history/history_service.h" | 14 #include "chrome/browser/history/history_service.h" |
| 14 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 17 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 using content::FaviconStatus; | 36 using content::FaviconStatus; |
| 36 using content::NavigationController; | 37 using content::NavigationController; |
| 37 using content::NavigationEntry; | 38 using content::NavigationEntry; |
| 38 using content::WebContents; | 39 using content::WebContents; |
| 39 | 40 |
| 40 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); | 41 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); |
| 41 | 42 |
| 42 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) | 43 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) |
| 43 : content::WebContentsObserver(web_contents), | 44 : content::WebContentsObserver(web_contents), |
| 44 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { | 45 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
| 45 client_.reset(new ChromeFaviconClient(profile_)); | 46 client_ = ChromeFaviconClientFactory::GetForProfile(profile_); |
| 46 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
| 47 bool download_largest_icon = true; | 48 bool download_largest_icon = true; |
| 48 #else | 49 #else |
| 49 bool download_largest_icon = false; | 50 bool download_largest_icon = false; |
| 50 #endif | 51 #endif |
| 51 favicon_handler_.reset(new FaviconHandler(client_.get(), | 52 favicon_handler_.reset(new FaviconHandler( |
| 52 this, | 53 client_, this, FaviconHandler::FAVICON, download_largest_icon)); |
| 53 FaviconHandler::FAVICON, | |
| 54 download_largest_icon)); | |
| 55 if (chrome::kEnableTouchIcon) | 54 if (chrome::kEnableTouchIcon) |
| 56 touch_icon_handler_.reset(new FaviconHandler(client_.get(), | 55 touch_icon_handler_.reset(new FaviconHandler( |
| 57 this, | 56 client_, this, FaviconHandler::TOUCH, download_largest_icon)); |
| 58 FaviconHandler::TOUCH, | |
| 59 download_largest_icon)); | |
| 60 } | 57 } |
| 61 | 58 |
| 62 FaviconTabHelper::~FaviconTabHelper() { | 59 FaviconTabHelper::~FaviconTabHelper() { |
| 63 } | 60 } |
| 64 | 61 |
| 65 void FaviconTabHelper::FetchFavicon(const GURL& url) { | 62 void FaviconTabHelper::FetchFavicon(const GURL& url) { |
| 66 favicon_handler_->FetchFavicon(url); | 63 favicon_handler_->FetchFavicon(url); |
| 67 if (touch_icon_handler_.get()) | 64 if (touch_icon_handler_.get()) |
| 68 touch_icon_handler_->FetchFavicon(url); | 65 touch_icon_handler_->FetchFavicon(url); |
| 69 } | 66 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 favicon_service->UnableToDownloadFavicon(image_url); | 275 favicon_service->UnableToDownloadFavicon(image_url); |
| 279 } | 276 } |
| 280 | 277 |
| 281 favicon_handler_->OnDidDownloadFavicon( | 278 favicon_handler_->OnDidDownloadFavicon( |
| 282 id, image_url, bitmaps, original_bitmap_sizes); | 279 id, image_url, bitmaps, original_bitmap_sizes); |
| 283 if (touch_icon_handler_.get()) { | 280 if (touch_icon_handler_.get()) { |
| 284 touch_icon_handler_->OnDidDownloadFavicon( | 281 touch_icon_handler_->OnDidDownloadFavicon( |
| 285 id, image_url, bitmaps, original_bitmap_sizes); | 282 id, image_url, bitmaps, original_bitmap_sizes); |
| 286 } | 283 } |
| 287 } | 284 } |
| OLD | NEW |