Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/previews/previews_infobar_tab_helper.h" | 5 #include "chrome/browser/previews/previews_infobar_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/feature_engagement_tracker/feature_engagement_tracker_f actory.h" | |
| 9 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" |
| 11 #include "chrome/browser/previews/previews_infobar_delegate.h" | 12 #include "chrome/browser/previews/previews_infobar_delegate.h" |
| 12 #include "chrome/browser/previews/previews_service.h" | 13 #include "chrome/browser/previews/previews_service.h" |
| 13 #include "chrome/browser/previews/previews_service_factory.h" | 14 #include "chrome/browser/previews/previews_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" |
| 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" | 17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" |
| 18 #include "components/feature_engagement_tracker/public/event_constants.h" | |
| 19 #include "components/feature_engagement_tracker/public/feature_engagement_tracke r.h" | |
| 17 #include "components/previews/core/previews_experiments.h" | 20 #include "components/previews/core/previews_experiments.h" |
| 18 #include "components/previews/core/previews_ui_service.h" | 21 #include "components/previews/core/previews_ui_service.h" |
| 19 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/navigation_handle.h" | 24 #include "content/public/browser/navigation_handle.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 24 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
| 25 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 26 | 29 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 71 |
| 69 #if defined(OS_ANDROID) | 72 #if defined(OS_ANDROID) |
| 70 offline_pages::OfflinePageTabHelper* tab_helper = | 73 offline_pages::OfflinePageTabHelper* tab_helper = |
| 71 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()); | 74 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()); |
| 72 | 75 |
| 73 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { | 76 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { |
| 74 if (navigation_handle->IsErrorPage()) { | 77 if (navigation_handle->IsErrorPage()) { |
| 75 // TODO(ryansturm): Add UMA for errors. | 78 // TODO(ryansturm): Add UMA for errors. |
| 76 return; | 79 return; |
| 77 } | 80 } |
| 81 | |
| 82 feature_engagement_tracker::FeatureEngagementTracker* tracker = | |
|
gone
2017/04/18 21:05:19
Maybe this should be called after the infobar dele
David Trainor- moved to gerrit
2017/04/25 05:01:05
Ideally we want the precondition events to be fire
| |
| 83 FeatureEngagementTrackerFactory::GetInstance()->GetForBrowserContext( | |
| 84 web_contents()->GetBrowserContext()); | |
| 85 tracker->NotifyEvent( | |
| 86 feature_engagement_tracker::kIPHEventDataSaverPreviewOpened); | |
| 87 | |
| 78 data_reduction_proxy::DataReductionProxySettings* | 88 data_reduction_proxy::DataReductionProxySettings* |
| 79 data_reduction_proxy_settings = | 89 data_reduction_proxy_settings = |
| 80 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 90 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 81 web_contents()->GetBrowserContext()); | 91 web_contents()->GetBrowserContext()); |
| 82 PreviewsInfoBarDelegate::Create( | 92 PreviewsInfoBarDelegate::Create( |
| 83 web_contents(), PreviewsInfoBarDelegate::OFFLINE, | 93 web_contents(), PreviewsInfoBarDelegate::OFFLINE, |
| 84 data_reduction_proxy_settings && | 94 data_reduction_proxy_settings && |
| 85 data_reduction_proxy_settings->IsDataReductionProxyEnabled(), | 95 data_reduction_proxy_settings->IsDataReductionProxyEnabled(), |
| 86 base::Bind( | 96 base::Bind( |
| 87 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(), | 97 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(), |
| 88 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE)); | 98 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE)); |
| 89 // Don't try to show other infobars if this is an offline preview. | 99 // Don't try to show other infobars if this is an offline preview. |
| 90 return; | 100 return; |
| 91 } | 101 } |
| 92 #endif // defined(OS_ANDROID) | 102 #endif // defined(OS_ANDROID) |
| 93 | 103 |
| 94 const net::HttpResponseHeaders* headers = | 104 const net::HttpResponseHeaders* headers = |
| 95 navigation_handle->GetResponseHeaders(); | 105 navigation_handle->GetResponseHeaders(); |
| 96 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { | 106 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { |
| 97 PreviewsInfoBarDelegate::Create( | 107 PreviewsInfoBarDelegate::Create( |
| 98 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, | 108 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, |
| 99 true /* is_data_saver_user */, | 109 true /* is_data_saver_user */, |
| 100 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); | 110 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); |
| 101 } | 111 } |
| 102 } | 112 } |
| 103 | 113 |
| OLD | NEW |