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

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

Issue 2875993002: Converging the two previews type enums (Closed)
Patch Set: megjablon nit Created 3 years, 7 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { 97 if (tab_helper && tab_helper->IsShowingOfflinePreview()) {
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(), PreviewsInfoBarDelegate::OFFLINE, 107 web_contents(), previews::PreviewsType::OFFLINE,
108 data_reduction_proxy_settings && 108 data_reduction_proxy_settings &&
109 data_reduction_proxy_settings->IsDataReductionProxyEnabled(), 109 data_reduction_proxy_settings->IsDataReductionProxyEnabled(),
110 base::Bind(&AddPreviewNavigationCallback, browser_context_, 110 base::Bind(&AddPreviewNavigationCallback, browser_context_,
111 navigation_handle->GetRedirectChain()[0], 111 navigation_handle->GetRedirectChain()[0],
112 previews::PreviewsType::OFFLINE)); 112 previews::PreviewsType::OFFLINE));
113 // Don't try to show other infobars if this is an offline preview. 113 // Don't try to show other infobars if this is an offline preview.
114 return; 114 return;
115 } 115 }
116 #endif // defined(OS_ANDROID) 116 #endif // defined(OS_ANDROID)
117 117
118 const net::HttpResponseHeaders* headers = 118 const net::HttpResponseHeaders* headers =
119 navigation_handle->GetResponseHeaders(); 119 navigation_handle->GetResponseHeaders();
120 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { 120 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) {
121 PreviewsInfoBarDelegate::Create( 121 PreviewsInfoBarDelegate::Create(
122 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, 122 web_contents(), previews::PreviewsType::LITE_PAGE,
123 true /* is_data_saver_user */, 123 true /* is_data_saver_user */,
124 base::Bind(&AddPreviewNavigationCallback, browser_context_, 124 base::Bind(&AddPreviewNavigationCallback, browser_context_,
125 navigation_handle->GetRedirectChain()[0], 125 navigation_handle->GetRedirectChain()[0],
126 previews::PreviewsType::LITE_PAGE)); 126 previews::PreviewsType::LITE_PAGE));
127 } 127 }
128 } 128 }
129 129
130 void PreviewsInfoBarTabHelper::ClearLastNavigationAsync() const { 130 void PreviewsInfoBarTabHelper::ClearLastNavigationAsync() const {
131 if (!committed_data_saver_navigation_id_) 131 if (!committed_data_saver_navigation_id_)
132 return; 132 return;
133 auto* data_reduction_proxy_settings = 133 auto* data_reduction_proxy_settings =
134 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 134 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
135 browser_context_); 135 browser_context_);
136 if (!data_reduction_proxy_settings || 136 if (!data_reduction_proxy_settings ||
137 !data_reduction_proxy_settings->data_reduction_proxy_service()) { 137 !data_reduction_proxy_settings->data_reduction_proxy_service()) {
138 return; 138 return;
139 } 139 }
140 data_reduction_proxy_settings->data_reduction_proxy_service() 140 data_reduction_proxy_settings->data_reduction_proxy_service()
141 ->pingback_client() 141 ->pingback_client()
142 ->ClearNavigationKeyAsync(committed_data_saver_navigation_id_.value()); 142 ->ClearNavigationKeyAsync(committed_data_saver_navigation_id_.value());
143 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698