OLD | NEW |
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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
12 #include "chrome/common/chrome_content_client.h" | 13 #include "chrome/common/chrome_content_client.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h
" | 15 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h
" |
| 16 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic
e.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_retrieval_params.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_retrieval_params.h" |
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_expe
riments_stats.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_expe
riments_stats.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/web_contents.h" |
19 | 23 |
20 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
21 #include "base/android/build_info.h" | 25 #include "base/android/build_info.h" |
| 26 #include "chrome/browser/android/tab_android.h" |
22 #endif | 27 #endif |
23 | 28 |
24 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 29 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
25 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
26 #include "components/data_reduction_proxy/content/browser/content_data_reduction
_proxy_debug_ui_service.h" | 31 #include "components/data_reduction_proxy/content/browser/content_data_reduction
_proxy_debug_ui_service.h" |
27 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 32 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
28 #endif | 33 #endif |
29 | 34 |
30 namespace content { | 35 namespace content { |
31 class BrowserContext; | 36 class BrowserContext; |
32 } | 37 } |
33 | 38 |
34 using data_reduction_proxy::DataReductionProxyParams; | 39 using data_reduction_proxy::DataReductionProxyParams; |
35 | 40 |
| 41 namespace { |
| 42 |
| 43 // For Android builds, notifies the TabAndroid associated with |web_contents| |
| 44 // that a Lo-Fi response has been received. The TabAndroid then handles showing |
| 45 // Lo-Fi UI if this is the first Lo-Fi response for a page load. |
| 46 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents) { |
| 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 48 #if defined(OS_ANDROID) |
| 49 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| 50 if (tab) |
| 51 tab->OnLoFiResponseReceived(); |
| 52 #endif |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 |
36 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | 57 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
37 CreateDataReductionProxyChromeIOData( | 58 CreateDataReductionProxyChromeIOData( |
38 net::NetLog* net_log, | 59 net::NetLog* net_log, |
39 PrefService* prefs, | 60 PrefService* prefs, |
40 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 61 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
41 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 62 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
42 bool enable_quic) { | 63 bool enable_quic) { |
43 DCHECK(net_log); | 64 DCHECK(net_log); |
44 DCHECK(prefs); | 65 DCHECK(prefs); |
45 | 66 |
(...skipping 18 matching lines...) Expand all Loading... |
64 new data_reduction_proxy::DataReductionProxyIOData( | 85 new data_reduction_proxy::DataReductionProxyIOData( |
65 DataReductionProxyChromeSettings::GetClient(), flags, net_log, | 86 DataReductionProxyChromeSettings::GetClient(), flags, net_log, |
66 io_task_runner, ui_task_runner, enabled, enable_quic, | 87 io_task_runner, ui_task_runner, enabled, enable_quic, |
67 GetUserAgent())); | 88 GetUserAgent())); |
68 data_reduction_proxy_io_data->experiments_stats()->InitializeOnUIThread( | 89 data_reduction_proxy_io_data->experiments_stats()->InitializeOnUIThread( |
69 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create( | 90 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create( |
70 prefs)); | 91 prefs)); |
71 | 92 |
72 data_reduction_proxy_io_data->set_lofi_decider( | 93 data_reduction_proxy_io_data->set_lofi_decider( |
73 make_scoped_ptr(new data_reduction_proxy::ContentLoFiDecider())); | 94 make_scoped_ptr(new data_reduction_proxy::ContentLoFiDecider())); |
| 95 data_reduction_proxy_io_data->set_lofi_ui_service( |
| 96 make_scoped_ptr(new data_reduction_proxy::ContentLoFiUIService( |
| 97 ui_task_runner, |
| 98 base::Bind(&OnLoFiResponseReceivedOnUI)))); |
74 | 99 |
75 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 100 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
76 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> | 101 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> |
77 data_reduction_proxy_ui_service( | 102 data_reduction_proxy_ui_service( |
78 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( | 103 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( |
79 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: | 104 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: |
80 GetProxyConfig, | 105 GetProxyConfig, |
81 base::Unretained( | 106 base::Unretained( |
82 data_reduction_proxy_io_data->configurator())), | 107 data_reduction_proxy_io_data->configurator())), |
83 ui_task_runner, io_task_runner, | 108 ui_task_runner, io_task_runner, |
84 g_browser_process->GetApplicationLocale())); | 109 g_browser_process->GetApplicationLocale())); |
85 data_reduction_proxy_io_data->set_debug_ui_service( | 110 data_reduction_proxy_io_data->set_debug_ui_service( |
86 std::move(data_reduction_proxy_ui_service)); | 111 std::move(data_reduction_proxy_ui_service)); |
87 #endif | 112 #endif |
88 | 113 |
89 return data_reduction_proxy_io_data; | 114 return data_reduction_proxy_io_data; |
90 } | 115 } |
OLD | NEW |