Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/previews/previews_infobar_tab_helper.cc

Issue 2940083003: Add timestamp to infobar for stale Previews (Closed)
Patch Set: add GetMessageText comment Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loader/chrome_navigation_data.h" 9 #include "chrome/browser/loader/chrome_navigation_data.h"
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (navigation_handle->IsErrorPage()) { 98 if (navigation_handle->IsErrorPage()) {
99 // TODO(ryansturm): Add UMA for errors. 99 // TODO(ryansturm): Add UMA for errors.
100 return; 100 return;
101 } 101 }
102 data_reduction_proxy::DataReductionProxySettings* 102 data_reduction_proxy::DataReductionProxySettings*
103 data_reduction_proxy_settings = 103 data_reduction_proxy_settings =
104 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 104 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
105 web_contents()->GetBrowserContext()); 105 web_contents()->GetBrowserContext());
106 PreviewsInfoBarDelegate::Create( 106 PreviewsInfoBarDelegate::Create(
107 web_contents(), previews::PreviewsType::OFFLINE, 107 web_contents(), previews::PreviewsType::OFFLINE,
108 base::Time() /* previews_freshness */,
108 data_reduction_proxy_settings && 109 data_reduction_proxy_settings &&
109 data_reduction_proxy_settings->IsDataReductionProxyEnabled(), 110 data_reduction_proxy_settings->IsDataReductionProxyEnabled(),
110 base::Bind(&AddPreviewNavigationCallback, browser_context_, 111 base::Bind(&AddPreviewNavigationCallback, browser_context_,
111 navigation_handle->GetRedirectChain()[0], 112 navigation_handle->GetRedirectChain()[0],
112 previews::PreviewsType::OFFLINE)); 113 previews::PreviewsType::OFFLINE));
113 // Don't try to show other infobars if this is an offline preview. 114 // Don't try to show other infobars if this is an offline preview.
114 return; 115 return;
115 } 116 }
116 #endif // defined(OS_ANDROID) 117 #endif // defined(OS_ANDROID)
117 118
118 const net::HttpResponseHeaders* headers = 119 const net::HttpResponseHeaders* headers =
119 navigation_handle->GetResponseHeaders(); 120 navigation_handle->GetResponseHeaders();
120 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { 121 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) {
122 base::Time previews_freshness;
123 headers->GetDateValue(&previews_freshness);
121 PreviewsInfoBarDelegate::Create( 124 PreviewsInfoBarDelegate::Create(
122 web_contents(), previews::PreviewsType::LITE_PAGE, 125 web_contents(), previews::PreviewsType::LITE_PAGE, previews_freshness,
123 true /* is_data_saver_user */, 126 true /* is_data_saver_user */,
124 base::Bind(&AddPreviewNavigationCallback, browser_context_, 127 base::Bind(&AddPreviewNavigationCallback, browser_context_,
125 navigation_handle->GetRedirectChain()[0], 128 navigation_handle->GetRedirectChain()[0],
126 previews::PreviewsType::LITE_PAGE)); 129 previews::PreviewsType::LITE_PAGE));
127 } 130 }
128 } 131 }
129 132
130 void PreviewsInfoBarTabHelper::ClearLastNavigationAsync() const { 133 void PreviewsInfoBarTabHelper::ClearLastNavigationAsync() const {
131 if (!committed_data_saver_navigation_id_) 134 if (!committed_data_saver_navigation_id_)
132 return; 135 return;
133 auto* data_reduction_proxy_settings = 136 auto* data_reduction_proxy_settings =
134 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 137 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
135 browser_context_); 138 browser_context_);
136 if (!data_reduction_proxy_settings || 139 if (!data_reduction_proxy_settings ||
137 !data_reduction_proxy_settings->data_reduction_proxy_service()) { 140 !data_reduction_proxy_settings->data_reduction_proxy_service()) {
138 return; 141 return;
139 } 142 }
140 data_reduction_proxy_settings->data_reduction_proxy_service() 143 data_reduction_proxy_settings->data_reduction_proxy_service()
141 ->pingback_client() 144 ->pingback_client()
142 ->ClearNavigationKeyAsync(committed_data_saver_navigation_id_.value()); 145 ->ClearNavigationKeyAsync(committed_data_saver_navigation_id_.value());
143 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698