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

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

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: bengr comments Created 3 years, 8 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_delegate.h" 5 #include "chrome/browser/previews/previews_infobar_delegate.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/optional.h"
8 #include "chrome/browser/android/android_theme_resources.h" 9 #include "chrome/browser/android/android_theme_resources.h"
9 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
12 #include "chrome/browser/previews/previews_infobar_tab_helper.h" 13 #include "chrome/browser/previews/previews_infobar_tab_helper.h"
13 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_ping back_client.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h"
14 #include "components/infobars/core/infobar.h" 17 #include "components/infobars/core/infobar.h"
15 #include "content/public/browser/render_frame_host.h" 18 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
17 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
18 21
19 namespace { 22 namespace {
20 23
21 // Key of the UMA Previews.InfoBarAction.LoFi histogram. 24 // Key of the UMA Previews.InfoBarAction.LoFi histogram.
22 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi"; 25 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi";
23 26
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 144 bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
142 infobar_dismissed_action_ = INFOBAR_LOAD_ORIGINAL_CLICKED; 145 infobar_dismissed_action_ = INFOBAR_LOAD_ORIGINAL_CLICKED;
143 if (!on_dismiss_callback_.is_null()) 146 if (!on_dismiss_callback_.is_null())
144 on_dismiss_callback_.Run(true); 147 on_dismiss_callback_.Run(true);
145 on_dismiss_callback_.Reset(); 148 on_dismiss_callback_.Reset();
146 149
147 content::WebContents* web_contents = 150 content::WebContents* web_contents =
148 InfoBarService::WebContentsFromInfoBar(infobar()); 151 InfoBarService::WebContentsFromInfoBar(infobar());
149 if (infobar_type_ == LITE_PAGE || infobar_type_ == LOFI) { 152 if (infobar_type_ == LITE_PAGE || infobar_type_ == LOFI) {
153 auto* data_reduction_proxy_settings =
154 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
155 web_contents->GetBrowserContext());
156 data_reduction_proxy_settings->IncrementLoFiUserRequestsForImages();
157 PreviewsInfoBarTabHelper* infobar_tab_helper =
158 PreviewsInfoBarTabHelper::FromWebContents(web_contents);
159 if (infobar_tab_helper &&
160 infobar_tab_helper->committed_data_saver_navigation_id()) {
161 data_reduction_proxy_settings->data_reduction_proxy_service()
162 ->pingback_client()
163 ->AddOptOut(
164 infobar_tab_helper->committed_data_saver_navigation_id().value());
165 }
166
150 if (infobar_type_ == LITE_PAGE) 167 if (infobar_type_ == LITE_PAGE)
151 web_contents->GetController().Reload( 168 web_contents->GetController().Reload(
152 content::ReloadType::DISABLE_LOFI_MODE, true); 169 content::ReloadType::DISABLE_LOFI_MODE, true);
153 else if (infobar_type_ == LOFI) 170 else if (infobar_type_ == LOFI)
154 web_contents->ReloadLoFiImages(); 171 web_contents->ReloadLoFiImages();
155
156 auto* data_reduction_proxy_settings =
157 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
158 web_contents->GetBrowserContext());
159 data_reduction_proxy_settings->IncrementLoFiUserRequestsForImages();
160 } else if (infobar_type_ == OFFLINE) { 172 } else if (infobar_type_ == OFFLINE) {
161 // Prevent LoFi and lite page modes from showing after reload. 173 // Prevent LoFi and lite page modes from showing after reload.
162 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS. 174 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS.
163 // crbug.com/707272 175 // crbug.com/707272
164 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE, 176 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE,
165 true); 177 true);
166 } 178 }
167 179
168 return true; 180 return true;
169 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698