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

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: fix unit tests Created 4 years, 4 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|
bengr 2016/08/25 23:26:18 Is this still accurate? You removed references in
megjablon 2016/08/26 22:47:30 Done.
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.
42 // indicates whether the response was a Lo-Fi preview response. 42 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents) {
43 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents,
44 bool is_preview) {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
46 #if defined(OS_ANDROID) 44 PreviewsInfoBarDelegate::Create(web_contents,
47 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); 45 PreviewsInfoBarDelegate::LOFI);
48 if (tab)
49 tab->OnLoFiResponseReceived(is_preview);
50 #endif
51 } 46 }
52 47
53 } // namespace 48 } // namespace
54 49
55 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> 50 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
56 CreateDataReductionProxyChromeIOData( 51 CreateDataReductionProxyChromeIOData(
57 net::NetLog* net_log, 52 net::NetLog* net_log,
58 PrefService* prefs, 53 PrefService* prefs,
59 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 54 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
60 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { 55 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) {
(...skipping 26 matching lines...) Expand all
87 data_reduction_proxy_io_data->set_lofi_decider( 82 data_reduction_proxy_io_data->set_lofi_decider(
88 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider())); 83 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider()));
89 data_reduction_proxy_io_data->set_lofi_ui_service( 84 data_reduction_proxy_io_data->set_lofi_ui_service(
90 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService( 85 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService(
91 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI)))); 86 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI))));
92 data_reduction_proxy_io_data->set_data_usage_source_provider( 87 data_reduction_proxy_io_data->set_data_usage_source_provider(
93 base::WrapUnique(new ChromeDataUseGroupProvider())); 88 base::WrapUnique(new ChromeDataUseGroupProvider()));
94 89
95 return data_reduction_proxy_io_data; 90 return data_reduction_proxy_io_data;
96 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698