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

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

Issue 2860083003: Add timestamp support to the Previews infobar (Closed)
Patch Set: sync and rebase 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
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | 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_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"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
12 #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"
13 #include "chrome/browser/previews/previews_infobar_tab_helper.h" 13 #include "chrome/browser/previews/previews_infobar_tab_helper.h"
14 #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" 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" 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h"
17 #include "components/infobars/core/infobar.h" 17 #include "components/infobars/core/infobar.h"
18 #include "content/public/browser/render_frame_host.h" 18 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 21
22 #if defined(OS_ANDROID)
23 #include "chrome/browser/ui/android/infobars/previews_infobar.h"
24 #endif
25
22 namespace { 26 namespace {
23 27
24 // Key of the UMA Previews.InfoBarAction.LoFi histogram. 28 // Key of the UMA Previews.InfoBarAction.LoFi histogram.
25 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi"; 29 const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi";
26 30
27 // Key of the UMA Previews.InfoBarAction.Offline histogram. 31 // Key of the UMA Previews.InfoBarAction.Offline histogram.
28 const char kUMAPreviewsInfoBarActionOffline[] = 32 const char kUMAPreviewsInfoBarActionOffline[] =
29 "Previews.InfoBarAction.Offline"; 33 "Previews.InfoBarAction.Offline";
30 34
31 // Key of the UMA Previews.InfoBarAction.LitePage histogram. 35 // Key of the UMA Previews.InfoBarAction.LitePage histogram.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 InfoBarService* infobar_service = 71 InfoBarService* infobar_service =
68 InfoBarService::FromWebContents(web_contents); 72 InfoBarService::FromWebContents(web_contents);
69 73
70 // The WebContents may not have TabHelpers set. If TabHelpers are not set, 74 // The WebContents may not have TabHelpers set. If TabHelpers are not set,
71 // don't show Previews infobars. 75 // don't show Previews infobars.
72 if (!infobar_tab_helper || !infobar_service) 76 if (!infobar_tab_helper || !infobar_service)
73 return; 77 return;
74 if (infobar_tab_helper->displayed_preview_infobar()) 78 if (infobar_tab_helper->displayed_preview_infobar())
75 return; 79 return;
76 80
81 std::unique_ptr<PreviewsInfoBarDelegate> delegate(new PreviewsInfoBarDelegate(
82 web_contents, infobar_type, is_data_saver_user, on_dismiss_callback));
83
84 #if defined(OS_ANDROID)
85 std::unique_ptr<infobars::InfoBar> infobar_ptr(
86 PreviewsInfoBar::CreateInfoBar(infobar_service, std::move(delegate)));
87 #else
88 std::unique_ptr<infobars::InfoBar> infobar_ptr(
89 infobar_service->CreateConfirmInfoBar(std::move(delegate)));
90 #endif
91
77 infobars::InfoBar* infobar = 92 infobars::InfoBar* infobar =
78 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 93 infobar_service->AddInfoBar(std::move(infobar_ptr));
79 std::unique_ptr<ConfirmInfoBarDelegate>(new PreviewsInfoBarDelegate(
80 web_contents, infobar_type, is_data_saver_user,
81 on_dismiss_callback))));
82 94
83 if (infobar && (infobar_type == LITE_PAGE || infobar_type == LOFI)) { 95 if (infobar && (infobar_type == LITE_PAGE || infobar_type == LOFI)) {
84 auto* data_reduction_proxy_settings = 96 auto* data_reduction_proxy_settings =
85 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 97 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
86 web_contents->GetBrowserContext()); 98 web_contents->GetBrowserContext());
87 data_reduction_proxy_settings->IncrementLoFiUIShown(); 99 data_reduction_proxy_settings->IncrementLoFiUIShown();
88 } 100 }
89 101
90 RecordPreviewsInfoBarAction(infobar_type, INFOBAR_SHOWN); 102 RecordPreviewsInfoBarAction(infobar_type, INFOBAR_SHOWN);
91 infobar_tab_helper->set_displayed_preview_infobar(true); 103 infobar_tab_helper->set_displayed_preview_infobar(true);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } else if (infobar_type_ == OFFLINE) { 184 } else if (infobar_type_ == OFFLINE) {
173 // Prevent LoFi and lite page modes from showing after reload. 185 // Prevent LoFi and lite page modes from showing after reload.
174 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS. 186 // TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS.
175 // crbug.com/707272 187 // crbug.com/707272
176 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE, 188 web_contents->GetController().Reload(content::ReloadType::DISABLE_LOFI_MODE,
177 true); 189 true);
178 } 190 }
179 191
180 return true; 192 return true;
181 } 193 }
194
195 base::string16 PreviewsInfoBarDelegate::GetTimestampText() const {
196 return base::string16();
197 }
OLDNEW
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698