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

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

Issue 2581533003: Show the Data Saver string for offline previews when Data Saver is enabled (Closed)
Patch Set: bengr comments Created 4 years 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
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
9 #include "chrome/browser/previews/previews_infobar_delegate.h" 11 #include "chrome/browser/previews/previews_infobar_delegate.h"
10 #include "chrome/browser/previews/previews_service.h" 12 #include "chrome/browser/previews/previews_service.h"
11 #include "chrome/browser/previews/previews_service_factory.h" 13 #include "chrome/browser/previews/previews_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/features.h" 15 #include "chrome/common/features.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
14 #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"
15 #include "components/previews/core/previews_experiments.h" 18 #include "components/previews/core/previews_experiments.h"
16 #include "components/previews/core/previews_ui_service.h" 19 #include "components/previews/core/previews_ui_service.h"
17 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
20 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
22 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
23 #include "url/gurl.h" 26 #include "url/gurl.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 71
69 #if BUILDFLAG(ANDROID_JAVA_UI) 72 #if BUILDFLAG(ANDROID_JAVA_UI)
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 data_reduction_proxy::DataReductionProxySettings*
82 data_reduction_proxy_settings =
83 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
84 web_contents()->GetBrowserContext());
78 is_showing_offline_preview_ = true; 85 is_showing_offline_preview_ = true;
79 PreviewsInfoBarDelegate::Create( 86 PreviewsInfoBarDelegate::Create(
80 web_contents(), PreviewsInfoBarDelegate::OFFLINE, 87 web_contents(), PreviewsInfoBarDelegate::OFFLINE,
88 data_reduction_proxy_settings &&
89 data_reduction_proxy_settings->IsDataReductionProxyEnabled(),
81 base::Bind( 90 base::Bind(
82 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(), 91 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(),
83 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE)); 92 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE));
84 // Don't try to show other infobars if this is an offline preview. 93 // Don't try to show other infobars if this is an offline preview.
85 return; 94 return;
86 } 95 }
87 #endif // BUILDFLAG(ANDROID_JAVA_UI) 96 #endif // BUILDFLAG(ANDROID_JAVA_UI)
88 97
89 const net::HttpResponseHeaders* headers = 98 const net::HttpResponseHeaders* headers =
90 navigation_handle->GetResponseHeaders(); 99 navigation_handle->GetResponseHeaders();
91 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { 100 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) {
92 PreviewsInfoBarDelegate::Create( 101 PreviewsInfoBarDelegate::Create(
93 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, 102 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE,
103 true /* is_data_saver_user */,
94 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); 104 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
95 } 105 }
96 } 106 }
97 107
OLDNEW
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698