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

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

Issue 2848293002: Adding the Previews infobar to pages that show a client LoFi image (Closed)
Patch Set: removed range check 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_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 "base/optional.h"
9 #include "chrome/browser/android/android_theme_resources.h" 9 #include "chrome/browser/android/android_theme_resources.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace { 22 namespace {
23 23
24 // Key of the UMA Previews.InfoBarAction.LoFi histogram. 24 // Key of the UMA Previews.InfoBarAction.LoFi histogram.
25 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi"; 25 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi";
26 26
27 // Key of the UMA Previews.InfoBarAction.Offline histogram. 27 // Key of the UMA Previews.InfoBarAction.Offline histogram.
28 const char kUMAPreviewsInfoBarActionOffline[] = 28 const char kUMAPreviewsInfoBarActionOffline[] =
29 "Previews.InfoBarAction.Offline"; 29 "Previews.InfoBarAction.Offline";
30 30
31 // Key of the UMA Previews.InfoBarAction.ClientLoFi histogram.
32 const char kUMAPreviewsInfoBarActionClientLoFi[] =
33 "Previews.InfoBarAction.ClientLoFi";
34
31 // Key of the UMA Previews.InfoBarAction.LitePage histogram. 35 // Key of the UMA Previews.InfoBarAction.LitePage histogram.
32 const char kUMAPreviewsInfoBarActionLitePage[] = 36 const char kUMAPreviewsInfoBarActionLitePage[] =
33 "Previews.InfoBarAction.LitePage"; 37 "Previews.InfoBarAction.LitePage";
34 38
35 void RecordPreviewsInfoBarAction( 39 void RecordPreviewsInfoBarAction(
36 PreviewsInfoBarDelegate::PreviewsInfoBarType infobar_type, 40 PreviewsInfoBarDelegate::PreviewsInfoBarType infobar_type,
37 PreviewsInfoBarDelegate::PreviewsInfoBarAction action) { 41 PreviewsInfoBarDelegate::PreviewsInfoBarAction action) {
38 if (infobar_type == PreviewsInfoBarDelegate::LOFI) { 42 if (infobar_type == PreviewsInfoBarDelegate::LOFI) {
39 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLoFi, action, 43 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLoFi, action,
40 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY); 44 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY);
41 } else if (infobar_type == PreviewsInfoBarDelegate::LITE_PAGE) { 45 } else if (infobar_type == PreviewsInfoBarDelegate::LITE_PAGE) {
42 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLitePage, action, 46 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLitePage, action,
43 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY); 47 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY);
44 } else if (infobar_type == PreviewsInfoBarDelegate::OFFLINE) { 48 } else if (infobar_type == PreviewsInfoBarDelegate::OFFLINE) {
45 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionOffline, action, 49 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionOffline, action,
46 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY); 50 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY);
51 } else if (infobar_type == PreviewsInfoBarDelegate::CLIENT_LOFI) {
52 UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionClientLoFi, action,
53 PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY);
47 } 54 }
48 } 55 }
49 56
50 } // namespace 57 } // namespace
51 58
52 PreviewsInfoBarDelegate::~PreviewsInfoBarDelegate() { 59 PreviewsInfoBarDelegate::~PreviewsInfoBarDelegate() {
53 if (!on_dismiss_callback_.is_null()) 60 if (!on_dismiss_callback_.is_null())
54 on_dismiss_callback_.Run(false); 61 on_dismiss_callback_.Run(false);
55 62
56 RecordPreviewsInfoBarAction(infobar_type_, infobar_dismissed_action_); 63 RecordPreviewsInfoBarAction(infobar_type_, infobar_dismissed_action_);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 PreviewsInfoBarTabHelper* infobar_tab_helper = 164 PreviewsInfoBarTabHelper* infobar_tab_helper =
158 PreviewsInfoBarTabHelper::FromWebContents(web_contents); 165 PreviewsInfoBarTabHelper::FromWebContents(web_contents);
159 if (infobar_tab_helper && 166 if (infobar_tab_helper &&
160 infobar_tab_helper->committed_data_saver_navigation_id()) { 167 infobar_tab_helper->committed_data_saver_navigation_id()) {
161 data_reduction_proxy_settings->data_reduction_proxy_service() 168 data_reduction_proxy_settings->data_reduction_proxy_service()
162 ->pingback_client() 169 ->pingback_client()
163 ->AddOptOut( 170 ->AddOptOut(
164 infobar_tab_helper->committed_data_saver_navigation_id().value()); 171 infobar_tab_helper->committed_data_saver_navigation_id().value());
165 } 172 }
166 173
167 if (infobar_type_ == LITE_PAGE) 174 if (infobar_type_ == LITE_PAGE) {
168 web_contents->GetController().Reload( 175 web_contents->GetController().Reload(
169 content::ReloadType::DISABLE_LOFI_MODE, true); 176 content::ReloadType::DISABLE_LOFI_MODE, true);
170 else if (infobar_type_ == LOFI) 177 } else if (infobar_type_ == LOFI) {
171 web_contents->ReloadLoFiImages(); 178 web_contents->ReloadLoFiImages();
179 }
180 } else if (infobar_type_ == CLIENT_LOFI) {
181 web_contents->ReloadLoFiImages();
sclittle 2017/05/03 18:40:21 If "Show Original" is clicked on a page with both
RyanSturm 2017/05/03 18:48:52 Yes. It's definitely a race between the two. What
sclittle 2017/05/03 19:02:46 http:// pages with ads/analytics/social widgets ar
172 } else if (infobar_type_ == OFFLINE) { 182 } else if (infobar_type_ == OFFLINE) {
173 // Prevent LoFi and lite page modes from showing after reload. 183 // Prevent LoFi and lite page modes from showing after reload.
174 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS. 184 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS.
175 // crbug.com/707272 185 // crbug.com/707272
176 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE, 186 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE,
177 true); 187 true);
178 } 188 }
179 189
180 return true; 190 return true;
181 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698