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

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: moved definition up 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 140
138 bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 141 bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
139 RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_LOAD_ORIGINAL_CLICKED); 142 RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_LOAD_ORIGINAL_CLICKED);
140 if (!on_dismiss_callback_.is_null()) 143 if (!on_dismiss_callback_.is_null())
141 on_dismiss_callback_.Run(true); 144 on_dismiss_callback_.Run(true);
142 on_dismiss_callback_.Reset(); 145 on_dismiss_callback_.Reset();
143 146
144 content::WebContents* web_contents = 147 content::WebContents* web_contents =
145 InfoBarService::WebContentsFromInfoBar(infobar()); 148 InfoBarService::WebContentsFromInfoBar(infobar());
146 if (infobar_type_ == LITE_PAGE || infobar_type_ == LOFI) { 149 if (infobar_type_ == LITE_PAGE || infobar_type_ == LOFI) {
150 auto* data_reduction_proxy_settings =
151 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
bengr 2017/04/20 01:02:33 I'm assuming this never gets run from incognito?
RyanSturm 2017/04/20 20:25:44 It should not; it would be an interesting crash to
152 web_contents->GetBrowserContext());
153 data_reduction_proxy_settings->IncrementLoFiUserRequestsForImages();
154 PreviewsInfoBarTabHelper* infobar_tab_helper =
155 PreviewsInfoBarTabHelper::FromWebContents(web_contents);
156 if (infobar_tab_helper &&
157 infobar_tab_helper->committed_data_saver_page_id()) {
158 data_reduction_proxy_settings->data_reduction_proxy_service()
159 ->pingback_client()
160 ->AddOptOut(
161 web_contents /* tab_identifier_key */,
162 infobar_tab_helper->committed_data_saver_page_id().value());
163 }
164
147 if (infobar_type_ == LITE_PAGE) 165 if (infobar_type_ == LITE_PAGE)
148 web_contents->GetController().Reload( 166 web_contents->GetController().Reload(
149 content::ReloadType::DISABLE_LOFI_MODE, true); 167 content::ReloadType::DISABLE_LOFI_MODE, true);
150 else if (infobar_type_ == LOFI) 168 else if (infobar_type_ == LOFI)
151 web_contents->ReloadLoFiImages(); 169 web_contents->ReloadLoFiImages();
152
153 auto* data_reduction_proxy_settings =
154 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
155 web_contents->GetBrowserContext());
156 data_reduction_proxy_settings->IncrementLoFiUserRequestsForImages();
157 } else if (infobar_type_ == OFFLINE) { 170 } else if (infobar_type_ == OFFLINE) {
158 // Prevent LoFi and lite page modes from showing after reload. 171 // Prevent LoFi and lite page modes from showing after reload.
159 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS. 172 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS.
160 // crbug.com/707272 173 // crbug.com/707272
161 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE, 174 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE,
162 true); 175 true);
163 } 176 }
164 177
165 return true; 178 return true;
166 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698