Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / net / spdyproxy / data_reduction_proxy_chrome_io_data.cc
blobc5efc4dc8c268b9612d96176621b9bee97f33e00
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 if (data_reduction_proxy::params::IsIncludedInPromoFieldTrial())
45 flags |= DataReductionProxyParams::kPromoAllowed;
46 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial())
47 flags |= DataReductionProxyParams::kHoldback;
48 #if defined(OS_ANDROID)
49 if (data_reduction_proxy::params::IsIncludedInAndroidOnePromoFieldTrial(
50 base::android::BuildInfo::GetInstance()->android_build_fp())) {
51 flags |= DataReductionProxyParams::kPromoAllowed;
53 #endif
55 bool enabled =
56 prefs->GetBoolean(
57 data_reduction_proxy::prefs::kDataReductionProxyEnabled) ||
58 data_reduction_proxy::params::ShouldForceEnableDataReductionProxy();
59 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
60 data_reduction_proxy_io_data(
61 new data_reduction_proxy::DataReductionProxyIOData(
62 DataReductionProxyChromeSettings::GetClient(), flags, net_log,
63 io_task_runner, ui_task_runner, enabled, enable_quic,
64 GetUserAgent()));
65 data_reduction_proxy_io_data->experiments_stats()->InitializeOnUIThread(
66 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create(
67 prefs));
69 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
70 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService>
71 data_reduction_proxy_ui_service(
72 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
73 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
74 GetProxyConfig,
75 base::Unretained(
76 data_reduction_proxy_io_data->configurator())),
77 ui_task_runner, io_task_runner,
78 g_browser_process->GetApplicationLocale()));
79 data_reduction_proxy_io_data->set_debug_ui_service(
80 data_reduction_proxy_ui_service.Pass());
81 #endif
83 return data_reduction_proxy_io_data.Pass();