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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc

Issue 2250223002: Add InfoBar delegate for previews (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add count of infobars shown per session Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/net/spdyproxy/chrome_data_use_group_provider.h" 12 #include "chrome/browser/net/spdyproxy/chrome_data_use_group_provider.h"
13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
14 #include "chrome/browser/previews/previews_infobar_delegate.h"
14 #include "chrome/common/channel_info.h" 15 #include "chrome/common/channel_info.h"
15 #include "chrome/common/chrome_content_client.h" 16 #include "chrome/common/chrome_content_client.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h " 18 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h "
18 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h" 19 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
21 #include "components/prefs/pref_service.h" 22 #include "components/prefs/pref_service.h"
22 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 26
26 #if defined(OS_ANDROID) 27 #if defined(OS_ANDROID)
27 #include "base/android/build_info.h" 28 #include "base/android/build_info.h"
28 #include "chrome/browser/android/tab_android.h"
29 #endif 29 #endif
30 30
31 namespace content { 31 namespace content {
32 class BrowserContext; 32 class BrowserContext;
33 } 33 }
34 34
35 using data_reduction_proxy::DataReductionProxyParams; 35 using data_reduction_proxy::DataReductionProxyParams;
36 36
37 namespace { 37 namespace {
38 38
39 // For Android builds, notifies the TabAndroid associated with |web_contents| 39 // For Android builds, notifies the TabAndroid associated with |web_contents|
40 // that a Lo-Fi response has been received. The TabAndroid then handles showing 40 // that a Lo-Fi response has been received. The TabAndroid then handles showing
41 // Lo-Fi UI if this is the first Lo-Fi response for a page load. |is_preview| 41 // Lo-Fi UI if this is the first Lo-Fi response for a page load. |is_preview|
42 // indicates whether the response was a Lo-Fi preview response. 42 // indicates whether the response was a Lo-Fi preview response.
43 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents, 43 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents,
44 bool is_preview) { 44 bool is_preview) {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
46 #if defined(OS_ANDROID) 46 PreviewsInfoBarDelegate::Create(web_contents,
Peter Kasting 2016/08/23 19:48:17 Is this code accessible on non-Android builds? Ri
megjablon 2016/08/23 23:54:16 Right now we can enable previews on desktop via a
Peter Kasting 2016/08/24 03:18:27 I am OK with resolving this issue as a follow-up,
megjablon 2016/08/24 21:44:29 The code fully works on all platforms so it doesn'
47 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); 47 is_preview ? PreviewsInfoBarDelegate::PREVIEW
48 if (tab) 48 : PreviewsInfoBarDelegate::LOFI);
49 tab->OnLoFiResponseReceived(is_preview);
50 #endif
51 } 49 }
52 50
53 } // namespace 51 } // namespace
54 52
55 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> 53 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
56 CreateDataReductionProxyChromeIOData( 54 CreateDataReductionProxyChromeIOData(
57 net::NetLog* net_log, 55 net::NetLog* net_log,
58 PrefService* prefs, 56 PrefService* prefs,
59 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 57 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
60 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { 58 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) {
(...skipping 26 matching lines...) Expand all
87 data_reduction_proxy_io_data->set_lofi_decider( 85 data_reduction_proxy_io_data->set_lofi_decider(
88 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider())); 86 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider()));
89 data_reduction_proxy_io_data->set_lofi_ui_service( 87 data_reduction_proxy_io_data->set_lofi_ui_service(
90 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService( 88 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService(
91 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI)))); 89 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI))));
92 data_reduction_proxy_io_data->set_data_usage_source_provider( 90 data_reduction_proxy_io_data->set_data_usage_source_provider(
93 base::WrapUnique(new ChromeDataUseGroupProvider())); 91 base::WrapUnique(new ChromeDataUseGroupProvider()));
94 92
95 return data_reduction_proxy_io_data; 93 return data_reduction_proxy_io_data;
96 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698