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