Chromium Code Reviews| Index: chrome/browser/previews/previews_infobar_delegate.cc |
| diff --git a/chrome/browser/previews/previews_infobar_delegate.cc b/chrome/browser/previews/previews_infobar_delegate.cc |
| index d1cce99234847cefd53d42907083c327d9b40760..bd169729db41dcba24e018d29ce7c21fd4ed0560 100644 |
| --- a/chrome/browser/previews/previews_infobar_delegate.cc |
| +++ b/chrome/browser/previews/previews_infobar_delegate.cc |
| @@ -17,6 +17,7 @@ |
| #include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h" |
| +#include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| #include "chrome/browser/previews/previews_infobar_tab_helper.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h" |
| @@ -35,6 +36,8 @@ |
| namespace { |
| +const void* const kOptOutEventKey = 0; |
| + |
| const char kMinStalenessParamName[] = "min_staleness_in_minutes"; |
| const char kMaxStalenessParamName[] = "max_staleness_in_minutes"; |
| const int kMinStalenessParamDefaultValue = 2; |
| @@ -107,6 +110,17 @@ void ReloadWithoutPreviews(previews::PreviewsType previews_type, |
| } |
| } |
| +void NotifyPLMOfOptOut(content::WebContents* web_contents) { |
| + page_load_metrics::MetricsWebContentsObserver* metrics_web_contents_observer = |
| + page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
| + web_contents); |
| + if (!metrics_web_contents_observer) |
| + return; |
| + |
| + metrics_web_contents_observer->BroadcastEventToObservers( |
| + PreviewsInfoBarDelegate::OptOutEventKey()); |
|
dougarnett
2017/07/13 16:02:18
Should we be able to correlate this event somehow
RyanSturm
2017/07/17 18:48:30
That detection is done in the observer itself. Sin
dougarnett
2017/07/17 20:41:21
I'm asking a question not (yet) asking for a chang
|
| +} |
| + |
| } // namespace |
| PreviewsInfoBarDelegate::~PreviewsInfoBarDelegate() { |
| @@ -240,6 +254,8 @@ bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
| ReportPingbackInformation(web_contents); |
| + NotifyPLMOfOptOut(web_contents); |
|
tbansal1
2017/07/12 21:58:45
Does this class live on UI thread or IO thread?
RyanSturm
2017/07/17 18:48:30
It's all UI thread. I renamed this to "InformPLMOf
|
| + |
| if ((previews_type_ == previews::PreviewsType::LITE_PAGE || |
| previews_type_ == previews::PreviewsType::LOFI) && |
| !data_reduction_proxy::params::IsBlackListEnabledForServerPreviews()) { |
| @@ -318,3 +334,8 @@ base::string16 PreviewsInfoBarDelegate::GetTimestampText() const { |
| base::IntToString16(staleness_in_minutes / 60)); |
| } |
| } |
| + |
| +// static |
| +const void* PreviewsInfoBarDelegate::OptOutEventKey() { |
| + return &kOptOutEventKey; |
| +} |