Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / net / spdyproxy / data_reduction_proxy_chrome_io_data.cc
blob1b47bd8eea03717b6ccfa640abaae10f0abf13ec
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
3 // found in the LICENSE file.
5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
9 #include "chrome/common/chrome_content_client.h"
10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_retrieval_params.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h"
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
13 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
14 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
16 #if defined(OS_ANDROID)
17 #include "base/android/build_info.h"
18 #endif
20 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
21 #include "chrome/browser/browser_process.h"
22 #include "components/data_reduction_proxy/content/browser/content_data_reduction_proxy_debug_ui_service.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
24 #endif
26 namespace content {
27 class BrowserContext;
30 using data_reduction_proxy::DataReductionProxyParams;
32 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
33 CreateDataReductionProxyChromeIOData(
34 net::NetLog* net_log,
35 PrefService* prefs,
36 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
37 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
38 bool enable_quic) {
39 DCHECK(net_log);
40 DCHECK(prefs);
42 int flags = DataReductionProxyParams::kAllowed |
43 DataReductionProxyParams::kFallbackAllowed |
44 DataReductionProxyParams::kAlternativeAllowed;
45 if (data_reduction_proxy::params::IsIncludedInPromoFieldTrial())
46 flags |= DataReductionProxyParams::kPromoAllowed;
47 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial())
48 flags |= DataReductionProxyParams::kHoldback;
49 #if defined(OS_ANDROID)
50 if (data_reduction_proxy::params::IsIncludedInAndroidOnePromoFieldTrial(
51 base::android::BuildInfo::GetInstance()->android_build_fp())) {
52 flags |= DataReductionProxyParams::kPromoAllowed;
54 #endif
56 bool enabled =
57 prefs->GetBoolean(
58 data_reduction_proxy::prefs::kDataReductionProxyEnabled) ||
59 data_reduction_proxy::params::ShouldForceEnableDataReductionProxy();
60 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
61 data_reduction_proxy_io_data(
62 new data_reduction_proxy::DataReductionProxyIOData(
63 DataReductionProxyChromeSettings::GetClient(), flags, net_log,
64 io_task_runner, ui_task_runner, enabled, enable_quic,
65 GetUserAgent()));
66 data_reduction_proxy_io_data->experiments_stats()->InitializeOnUIThread(
67 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create(
68 prefs));
70 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
71 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService>
72 data_reduction_proxy_ui_service(
73 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
74 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
75 GetProxyConfig,
76 base::Unretained(
77 data_reduction_proxy_io_data->configurator())),
78 ui_task_runner, io_task_runner,
79 g_browser_process->GetApplicationLocale()));
80 data_reduction_proxy_io_data->set_debug_ui_service(
81 data_reduction_proxy_ui_service.Pass());
82 #endif
84 return data_reduction_proxy_io_data.Pass();