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 "base/metrics/field_trial.h" | |
8 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/favicon/chrome_favicon_client.h" | 9 #include "chrome/browser/favicon/chrome_favicon_client.h" |
11 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 10 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
12 #include "chrome/browser/favicon/favicon_service_factory.h" | 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
13 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
16 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
18 #include "components/favicon/content/favicon_url_util.h" | 17 #include "components/favicon/content/favicon_url_util.h" |
19 #include "components/favicon/core/favicon_handler.h" | 18 #include "components/favicon/core/favicon_handler.h" |
20 #include "components/favicon/core/favicon_service.h" | 19 #include "components/favicon/core/favicon_service.h" |
21 #include "components/favicon/core/favicon_tab_helper_observer.h" | 20 #include "components/favicon/core/favicon_tab_helper_observer.h" |
22 #include "components/favicon_base/favicon_types.h" | 21 #include "components/favicon_base/favicon_types.h" |
23 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
23 #include "components/variations/variations_associated_data.h" | |
24 #include "content/public/browser/favicon_status.h" | 24 #include "content/public/browser/favicon_status.h" |
25 #include "content/public/browser/invalidate_type.h" | 25 #include "content/public/browser/invalidate_type.h" |
26 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
27 #include "content/public/browser/navigation_details.h" | 27 #include "content/public/browser/navigation_details.h" |
28 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_contents_delegate.h" | 32 #include "content/public/browser/web_contents_delegate.h" |
33 #include "content/public/common/favicon_url.h" | 33 #include "content/public/common/favicon_url.h" |
34 #include "ui/gfx/codec/png_codec.h" | 34 #include "ui/gfx/codec/png_codec.h" |
35 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
36 #include "ui/gfx/image/image_skia.h" | 36 #include "ui/gfx/image/image_skia.h" |
37 #include "ui/gfx/image/image_skia_rep.h" | 37 #include "ui/gfx/image/image_skia_rep.h" |
38 | 38 |
39 using content::FaviconStatus; | 39 using content::FaviconStatus; |
40 using content::NavigationController; | 40 using content::NavigationController; |
41 using content::NavigationEntry; | 41 using content::NavigationEntry; |
42 using content::WebContents; | 42 using content::WebContents; |
43 | 43 |
44 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); | 44 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Returns whether icon NTP is enabled. | 48 // Returns whether icon NTP is enabled. |
49 bool IsIconNTPEnabled() { | 49 bool IsIconNTPEnabled() { |
kmadhusu
2015/03/26 16:25:11
This helper function is used by both browser and r
beaudoin
2015/03/26 16:50:08
Agreed it's not optimal, but I'd propose leaving i
kmadhusu
2015/03/26 17:10:25
I am fine with the current state. I suggested inst
| |
50 return StartsWithASCII(base::FieldTrialList::FindFullName("IconNTP"), | 50 return variations::GetVariationParamValue("IconNTP", "state") == "enabled"; |
kmadhusu
2015/03/26 16:25:11
You are checking for "enabled" instead of "Enabled
beaudoin
2015/03/26 16:50:10
Yes, this seems to be the pattern used by other Fi
kmadhusu
2015/03/26 17:10:25
Acknowledged.
| |
51 "Enabled", true); | |
52 } | 51 } |
53 | 52 |
54 } // namespace | 53 } // namespace |
55 | 54 |
56 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) | 55 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) |
57 : content::WebContentsObserver(web_contents), | 56 : content::WebContentsObserver(web_contents), |
58 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { | 57 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
59 client_ = ChromeFaviconClientFactory::GetForProfile(profile_); | 58 client_ = ChromeFaviconClientFactory::GetForProfile(profile_); |
60 #if defined(OS_ANDROID) || defined(OS_IOS) | 59 #if defined(OS_ANDROID) || defined(OS_IOS) |
61 bool download_largest_icon = true; | 60 bool download_largest_icon = true; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 id, image_url, bitmaps, original_bitmap_sizes); | 315 id, image_url, bitmaps, original_bitmap_sizes); |
317 if (touch_icon_handler_.get()) { | 316 if (touch_icon_handler_.get()) { |
318 touch_icon_handler_->OnDidDownloadFavicon( | 317 touch_icon_handler_->OnDidDownloadFavicon( |
319 id, image_url, bitmaps, original_bitmap_sizes); | 318 id, image_url, bitmaps, original_bitmap_sizes); |
320 } | 319 } |
321 if (large_icon_handler_.get()) { | 320 if (large_icon_handler_.get()) { |
322 large_icon_handler_->OnDidDownloadFavicon( | 321 large_icon_handler_->OnDidDownloadFavicon( |
323 id, image_url, bitmaps, original_bitmap_sizes); | 322 id, image_url, bitmaps, original_bitmap_sizes); |
324 } | 323 } |
325 } | 324 } |
OLD | NEW |