Chromium Code Reviews| 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" | 7 #include "base/metrics/field_trial.h" |
|
pkotwicz1
2015/03/25 22:25:41
You can remove this include?
beaudoin
2015/03/26 14:07:08
Good catch! Thanks.
Done.
| |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/favicon/chrome_favicon_client.h" | 10 #include "chrome/browser/favicon/chrome_favicon_client.h" |
| 11 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 11 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
| 12 #include "chrome/browser/favicon/favicon_service_factory.h" | 12 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/favicon/content/favicon_url_util.h" | 18 #include "components/favicon/content/favicon_url_util.h" |
| 19 #include "components/favicon/core/favicon_handler.h" | 19 #include "components/favicon/core/favicon_handler.h" |
| 20 #include "components/favicon/core/favicon_service.h" | 20 #include "components/favicon/core/favicon_service.h" |
| 21 #include "components/favicon/core/favicon_tab_helper_observer.h" | 21 #include "components/favicon/core/favicon_tab_helper_observer.h" |
| 22 #include "components/favicon_base/favicon_types.h" | 22 #include "components/favicon_base/favicon_types.h" |
| 23 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
| 24 #include "components/variations/variations_associated_data.h" | |
| 24 #include "content/public/browser/favicon_status.h" | 25 #include "content/public/browser/favicon_status.h" |
| 25 #include "content/public/browser/invalidate_type.h" | 26 #include "content/public/browser/invalidate_type.h" |
| 26 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
| 27 #include "content/public/browser/navigation_details.h" | 28 #include "content/public/browser/navigation_details.h" |
| 28 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
| 29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
| 31 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/browser/web_contents_delegate.h" | 33 #include "content/public/browser/web_contents_delegate.h" |
| 33 #include "content/public/common/favicon_url.h" | 34 #include "content/public/common/favicon_url.h" |
| 34 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
| 35 #include "ui/gfx/image/image.h" | 36 #include "ui/gfx/image/image.h" |
| 36 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
| 37 #include "ui/gfx/image/image_skia_rep.h" | 38 #include "ui/gfx/image/image_skia_rep.h" |
| 38 | 39 |
| 39 using content::FaviconStatus; | 40 using content::FaviconStatus; |
| 40 using content::NavigationController; | 41 using content::NavigationController; |
| 41 using content::NavigationEntry; | 42 using content::NavigationEntry; |
| 42 using content::WebContents; | 43 using content::WebContents; |
| 43 | 44 |
| 44 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); | 45 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); |
| 45 | 46 |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| 48 // Returns whether icon NTP is enabled. | 49 // Returns whether icon NTP is enabled. |
| 49 bool IsIconNTPEnabled() { | 50 bool IsIconNTPEnabled() { |
| 50 return StartsWithASCII(base::FieldTrialList::FindFullName("IconNTP"), | 51 return variations::GetVariationParamValue("IconNTP", "state") == "enabled"; |
| 51 "Enabled", true); | |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) | 56 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) |
| 57 : content::WebContentsObserver(web_contents), | 57 : content::WebContentsObserver(web_contents), |
| 58 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { | 58 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
| 59 client_ = ChromeFaviconClientFactory::GetForProfile(profile_); | 59 client_ = ChromeFaviconClientFactory::GetForProfile(profile_); |
| 60 #if defined(OS_ANDROID) || defined(OS_IOS) | 60 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 61 bool download_largest_icon = true; | 61 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); | 316 id, image_url, bitmaps, original_bitmap_sizes); |
| 317 if (touch_icon_handler_.get()) { | 317 if (touch_icon_handler_.get()) { |
| 318 touch_icon_handler_->OnDidDownloadFavicon( | 318 touch_icon_handler_->OnDidDownloadFavicon( |
| 319 id, image_url, bitmaps, original_bitmap_sizes); | 319 id, image_url, bitmaps, original_bitmap_sizes); |
| 320 } | 320 } |
| 321 if (large_icon_handler_.get()) { | 321 if (large_icon_handler_.get()) { |
| 322 large_icon_handler_->OnDidDownloadFavicon( | 322 large_icon_handler_->OnDidDownloadFavicon( |
| 323 id, image_url, bitmaps, original_bitmap_sizes); | 323 id, image_url, bitmaps, original_bitmap_sizes); |
| 324 } | 324 } |
| 325 } | 325 } |
| OLD | NEW |