OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | |
9 #include <utility> | 8 #include <utility> |
10 | 9 |
11 #include "base/bind.h" | 10 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 12 #include "base/callback.h" |
14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
16 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
17 #include "base/logging.h" | 16 #include "base/logging.h" |
18 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/metrics/field_trial.h" | |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
51 #include "chrome/common/chrome_paths.h" | 51 #include "chrome/common/chrome_paths.h" |
52 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
53 #include "chrome/common/features.h" | 53 #include "chrome/common/features.h" |
54 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
55 #include "chrome/common/url_constants.h" | 55 #include "chrome/common/url_constants.h" |
56 #include "components/about_handler/about_protocol_handler.h" | 56 #include "components/about_handler/about_protocol_handler.h" |
57 #include "components/content_settings/core/browser/content_settings_provider.h" | 57 #include "components/content_settings/core/browser/content_settings_provider.h" |
58 #include "components/content_settings/core/browser/cookie_settings.h" | 58 #include "components/content_settings/core/browser/cookie_settings.h" |
59 #include "components/content_settings/core/browser/host_content_settings_map.h" | 59 #include "components/content_settings/core/browser/host_content_settings_map.h" |
60 #include "components/cookie_config/cookie_store_util.h" | 60 #include "components/cookie_config/cookie_store_util.h" |
61 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" | |
61 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" | 62 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" |
62 #include "components/dom_distiller/core/url_constants.h" | 63 #include "components/dom_distiller/core/url_constants.h" |
63 #include "components/metrics/metrics_pref_names.h" | 64 #include "components/metrics/metrics_pref_names.h" |
64 #include "components/net_log/chrome_net_log.h" | 65 #include "components/net_log/chrome_net_log.h" |
65 #include "components/signin/core/common/signin_pref_names.h" | 66 #include "components/signin/core/common/signin_pref_names.h" |
66 #include "components/sync_driver/pref_names.h" | 67 #include "components/sync_driver/pref_names.h" |
67 #include "components/url_formatter/url_fixer.h" | 68 #include "components/url_formatter/url_fixer.h" |
68 #include "content/public/browser/browser_thread.h" | 69 #include "content/public/browser/browser_thread.h" |
69 #include "content/public/browser/host_zoom_map.h" | 70 #include "content/public/browser/host_zoom_map.h" |
70 #include "content/public/browser/notification_service.h" | 71 #include "content/public/browser/notification_service.h" |
71 #include "content/public/browser/resource_context.h" | 72 #include "content/public/browser/resource_context.h" |
73 #include "net/base/host_port_pair.h" | |
72 #include "net/base/keygen_handler.h" | 74 #include "net/base/keygen_handler.h" |
73 #include "net/base/network_quality_estimator.h" | 75 #include "net/base/network_quality_estimator.h" |
74 #include "net/cert/cert_verifier.h" | 76 #include "net/cert/cert_verifier.h" |
75 #include "net/cert/multi_log_ct_verifier.h" | 77 #include "net/cert/multi_log_ct_verifier.h" |
76 #include "net/cookies/canonical_cookie.h" | 78 #include "net/cookies/canonical_cookie.h" |
77 #include "net/http/http_network_session.h" | 79 #include "net/http/http_network_session.h" |
78 #include "net/http/http_transaction_factory.h" | 80 #include "net/http/http_transaction_factory.h" |
79 #include "net/http/http_util.h" | 81 #include "net/http/http_util.h" |
80 #include "net/http/transport_security_persister.h" | 82 #include "net/http/transport_security_persister.h" |
81 #include "net/proxy/proxy_config_service_fixed.h" | 83 #include "net/proxy/proxy_config_service_fixed.h" |
82 #include "net/proxy/proxy_script_fetcher_impl.h" | 84 #include "net/proxy/proxy_script_fetcher_impl.h" |
85 #include "net/proxy/proxy_server.h" | |
83 #include "net/proxy/proxy_service.h" | 86 #include "net/proxy/proxy_service.h" |
84 #include "net/ssl/channel_id_service.h" | 87 #include "net/ssl/channel_id_service.h" |
85 #include "net/ssl/client_cert_store.h" | 88 #include "net/ssl/client_cert_store.h" |
86 #include "net/url_request/certificate_report_sender.h" | 89 #include "net/url_request/certificate_report_sender.h" |
87 #include "net/url_request/data_protocol_handler.h" | 90 #include "net/url_request/data_protocol_handler.h" |
88 #include "net/url_request/file_protocol_handler.h" | 91 #include "net/url_request/file_protocol_handler.h" |
89 #include "net/url_request/ftp_protocol_handler.h" | 92 #include "net/url_request/ftp_protocol_handler.h" |
90 #include "net/url_request/url_request.h" | 93 #include "net/url_request/url_request.h" |
91 #include "net/url_request/url_request_context.h" | 94 #include "net/url_request/url_request_context.h" |
92 #include "net/url_request/url_request_context_builder.h" | 95 #include "net/url_request/url_request_context_builder.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 #if defined(OS_MACOSX) | 165 #if defined(OS_MACOSX) |
163 #include "net/ssl/client_cert_store_mac.h" | 166 #include "net/ssl/client_cert_store_mac.h" |
164 #endif | 167 #endif |
165 | 168 |
166 using content::BrowserContext; | 169 using content::BrowserContext; |
167 using content::BrowserThread; | 170 using content::BrowserThread; |
168 using content::ResourceContext; | 171 using content::ResourceContext; |
169 | 172 |
170 namespace { | 173 namespace { |
171 | 174 |
175 const char kTrustedSpdyProxyFieldTrialName[] = "TrustedSpdyProxy"; | |
176 | |
172 net::CertVerifier* g_cert_verifier_for_testing = nullptr; | 177 net::CertVerifier* g_cert_verifier_for_testing = nullptr; |
173 | 178 |
174 #if defined(DEBUG_DEVTOOLS) | 179 #if defined(DEBUG_DEVTOOLS) |
175 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { | 180 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { |
176 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); | 181 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); |
177 bundled_path_prefix = "/" + bundled_path_prefix + "/"; | 182 bundled_path_prefix = "/" + bundled_path_prefix + "/"; |
178 | 183 |
179 if (!url.SchemeIs(content::kChromeDevToolsScheme) || | 184 if (!url.SchemeIs(content::kChromeDevToolsScheme) || |
180 url.host() != chrome::kChromeUIDevToolsHost || | 185 url.host() != chrome::kChromeUIDevToolsHost || |
181 !base::StartsWith(url.path(), bundled_path_prefix, | 186 !base::StartsWith(url.path(), bundled_path_prefix, |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 net::URLRequestContext* context = main_request_context(); | 1296 net::URLRequestContext* context = main_request_context(); |
1292 | 1297 |
1293 IOThread* const io_thread = profile_params.io_thread; | 1298 IOThread* const io_thread = profile_params.io_thread; |
1294 | 1299 |
1295 io_thread->InitializeNetworkSessionParams(¶ms); | 1300 io_thread->InitializeNetworkSessionParams(¶ms); |
1296 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(context, | 1301 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(context, |
1297 ¶ms); | 1302 ¶ms); |
1298 if (!IsOffTheRecord()) { | 1303 if (!IsOffTheRecord()) { |
1299 params.socket_performance_watcher_factory = | 1304 params.socket_performance_watcher_factory = |
1300 io_thread->globals()->network_quality_estimator.get(); | 1305 io_thread->globals()->network_quality_estimator.get(); |
1306 | |
1307 // Set trusted SPDY proxy if it is not set through command line switch, data | |
bengr
2015/12/29 17:46:00
Set -> Set the
through -> through the
data -> the
tbansal1
2015/12/29 23:34:21
Done.
| |
1308 // reduction proxy is enabled by the user, and the session is part of the | |
1309 // enabled group of kTrustedSpdyProxyFieldTrialName field trial. | |
1310 if (params.trusted_spdy_proxy.empty() && IsDataReductionProxyEnabled() && | |
bengr
2015/12/29 17:46:00
I would move this block to a helper method.
tbansal1
2015/12/29 23:34:21
Obsolete, since this is a single line change now.
| |
1311 base::FieldTrialList::FindFullName(kTrustedSpdyProxyFieldTrialName) | |
1312 .find("Enabled") == 0) { | |
1313 if (data_reduction_proxy_io_data()->config()) { | |
bengr
2015/12/29 17:46:00
Why not do the following so that a lot of the busi
tbansal1
2015/12/29 23:34:21
Done.
| |
1314 // proxies_for_http contains the data reduction proxies for HTTP | |
1315 // requests. | |
1316 const std::vector<net::ProxyServer> proxies_for_http = | |
1317 data_reduction_proxy_io_data()->config()->proxies_for_http(); | |
1318 // Make sure that the proxy is a secure proxy before setting it as a | |
1319 // trusted SPDY proxy. | |
1320 if (proxies_for_http.size() >= 1 && proxies_for_http[0].is_valid() && | |
1321 (proxies_for_http[0].is_https() || proxies_for_http[0].is_quic())) { | |
1322 params.trusted_spdy_proxy = | |
1323 proxies_for_http[0].host_port_pair().ToString(); | |
1324 } | |
1325 } | |
1326 } | |
bengr
2015/12/29 17:46:00
Once you rewrite and move to a helper method, plea
tbansal1
2015/12/29 23:34:21
Added tests for methods in DRPConfig.
| |
1301 } | 1327 } |
1302 if (data_reduction_proxy_io_data_.get()) | 1328 if (data_reduction_proxy_io_data_.get()) |
1303 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate(); | 1329 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate(); |
1304 | 1330 |
1305 return scoped_ptr<net::HttpNetworkSession>( | 1331 return scoped_ptr<net::HttpNetworkSession>( |
1306 new net::HttpNetworkSession(params)); | 1332 new net::HttpNetworkSession(params)); |
1307 } | 1333 } |
1308 | 1334 |
1309 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( | 1335 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( |
1310 net::HttpNetworkSession* session, | 1336 net::HttpNetworkSession* session, |
(...skipping 11 matching lines...) Expand all Loading... | |
1322 make_scoped_ptr(new DevToolsNetworkTransactionFactory( | 1348 make_scoped_ptr(new DevToolsNetworkTransactionFactory( |
1323 network_controller_handle_.GetController(), shared_session)), | 1349 network_controller_handle_.GetController(), shared_session)), |
1324 std::move(backend), true /* set_up_quic_server_info */)); | 1350 std::move(backend), true /* set_up_quic_server_info */)); |
1325 } | 1351 } |
1326 | 1352 |
1327 void ProfileIOData::SetCookieSettingsForTesting( | 1353 void ProfileIOData::SetCookieSettingsForTesting( |
1328 content_settings::CookieSettings* cookie_settings) { | 1354 content_settings::CookieSettings* cookie_settings) { |
1329 DCHECK(!cookie_settings_.get()); | 1355 DCHECK(!cookie_settings_.get()); |
1330 cookie_settings_ = cookie_settings; | 1356 cookie_settings_ = cookie_settings; |
1331 } | 1357 } |
OLD | NEW |