Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "components/content_settings/core/browser/host_content_settings_map.h" | 57 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 58 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" | 58 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" |
| 59 #include "components/dom_distiller/core/url_constants.h" | 59 #include "components/dom_distiller/core/url_constants.h" |
| 60 #include "components/sync_driver/pref_names.h" | 60 #include "components/sync_driver/pref_names.h" |
| 61 #include "components/url_fixer/url_fixer.h" | 61 #include "components/url_fixer/url_fixer.h" |
| 62 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
| 63 #include "content/public/browser/host_zoom_map.h" | 63 #include "content/public/browser/host_zoom_map.h" |
| 64 #include "content/public/browser/notification_service.h" | 64 #include "content/public/browser/notification_service.h" |
| 65 #include "content/public/browser/resource_context.h" | 65 #include "content/public/browser/resource_context.h" |
| 66 #include "net/base/keygen_handler.h" | 66 #include "net/base/keygen_handler.h" |
| 67 #include "net/cert/cert_verifier.h" | |
| 67 #include "net/cookies/canonical_cookie.h" | 68 #include "net/cookies/canonical_cookie.h" |
| 68 #include "net/http/http_transaction_factory.h" | 69 #include "net/http/http_transaction_factory.h" |
| 69 #include "net/http/http_util.h" | 70 #include "net/http/http_util.h" |
| 70 #include "net/http/transport_security_persister.h" | 71 #include "net/http/transport_security_persister.h" |
| 71 #include "net/proxy/proxy_config_service_fixed.h" | 72 #include "net/proxy/proxy_config_service_fixed.h" |
| 72 #include "net/proxy/proxy_script_fetcher_impl.h" | 73 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 73 #include "net/proxy/proxy_service.h" | 74 #include "net/proxy/proxy_service.h" |
| 74 #include "net/ssl/channel_id_service.h" | 75 #include "net/ssl/channel_id_service.h" |
| 75 #include "net/ssl/client_cert_store.h" | 76 #include "net/ssl/client_cert_store.h" |
| 76 #include "net/url_request/certificate_report_sender.h" | 77 #include "net/url_request/certificate_report_sender.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 #if defined(OS_MACOSX) | 150 #if defined(OS_MACOSX) |
| 150 #include "net/ssl/client_cert_store_mac.h" | 151 #include "net/ssl/client_cert_store_mac.h" |
| 151 #endif | 152 #endif |
| 152 | 153 |
| 153 using content::BrowserContext; | 154 using content::BrowserContext; |
| 154 using content::BrowserThread; | 155 using content::BrowserThread; |
| 155 using content::ResourceContext; | 156 using content::ResourceContext; |
| 156 | 157 |
| 157 namespace { | 158 namespace { |
| 158 | 159 |
| 160 net::CertVerifier* g_cert_verifier_for_testing = nullptr; | |
| 161 | |
| 162 net::CertVerifier* GetCertVerifierForTesting() { | |
| 163 if (g_cert_verifier_for_testing) | |
| 164 return g_cert_verifier_for_testing; | |
| 165 return nullptr; | |
| 166 } | |
|
Ryan Sleevi
2015/08/04 18:24:34
This function isn't necessary, is it? I mean, it's
estark
2015/08/04 19:32:19
Done.
| |
| 167 | |
| 159 #if defined(DEBUG_DEVTOOLS) | 168 #if defined(DEBUG_DEVTOOLS) |
| 160 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { | 169 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { |
| 161 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); | 170 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); |
| 162 bundled_path_prefix = "/" + bundled_path_prefix + "/"; | 171 bundled_path_prefix = "/" + bundled_path_prefix + "/"; |
| 163 | 172 |
| 164 if (!url.SchemeIs(content::kChromeDevToolsScheme) || | 173 if (!url.SchemeIs(content::kChromeDevToolsScheme) || |
| 165 url.host() != chrome::kChromeUIDevToolsHost || | 174 url.host() != chrome::kChromeUIDevToolsHost || |
| 166 !base::StartsWith(url.path(), bundled_path_prefix, | 175 !base::StartsWith(url.path(), bundled_path_prefix, |
| 167 base::CompareCase::INSENSITIVE_ASCII)) { | 176 base::CompareCase::INSENSITIVE_ASCII)) { |
| 168 return false; | 177 return false; |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 protocol_handlers->begin(); | 749 protocol_handlers->begin(); |
| 741 it != protocol_handlers->end(); | 750 it != protocol_handlers->end(); |
| 742 ++it) { | 751 ++it) { |
| 743 bool set_protocol = job_factory->SetProtocolHandler( | 752 bool set_protocol = job_factory->SetProtocolHandler( |
| 744 it->first, it->second.release()); | 753 it->first, it->second.release()); |
| 745 DCHECK(set_protocol); | 754 DCHECK(set_protocol); |
| 746 } | 755 } |
| 747 protocol_handlers->clear(); | 756 protocol_handlers->clear(); |
| 748 } | 757 } |
| 749 | 758 |
| 759 // static | |
| 760 void ProfileIOData::SetCertVerifierForTesting( | |
| 761 net::CertVerifier* cert_verifier) { | |
| 762 g_cert_verifier_for_testing = cert_verifier; | |
| 763 } | |
| 764 | |
| 750 content::ResourceContext* ProfileIOData::GetResourceContext() const { | 765 content::ResourceContext* ProfileIOData::GetResourceContext() const { |
| 751 return resource_context_.get(); | 766 return resource_context_.get(); |
| 752 } | 767 } |
| 753 | 768 |
| 754 net::URLRequestContext* ProfileIOData::GetMainRequestContext() const { | 769 net::URLRequestContext* ProfileIOData::GetMainRequestContext() const { |
| 755 DCHECK(initialized_); | 770 DCHECK(initialized_); |
| 756 return main_request_context_.get(); | 771 return main_request_context_.get(); |
| 757 } | 772 } |
| 758 | 773 |
| 759 net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const { | 774 net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 | 1101 |
| 1087 if (profile_params_->resource_prefetch_predictor_observer_) { | 1102 if (profile_params_->resource_prefetch_predictor_observer_) { |
| 1088 resource_prefetch_predictor_observer_.reset( | 1103 resource_prefetch_predictor_observer_.reset( |
| 1089 profile_params_->resource_prefetch_predictor_observer_.release()); | 1104 profile_params_->resource_prefetch_predictor_observer_.release()); |
| 1090 } | 1105 } |
| 1091 | 1106 |
| 1092 #if defined(ENABLE_SUPERVISED_USERS) | 1107 #if defined(ENABLE_SUPERVISED_USERS) |
| 1093 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter; | 1108 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter; |
| 1094 #endif | 1109 #endif |
| 1095 | 1110 |
| 1111 net::CertVerifier* cert_verifier = GetCertVerifierForTesting(); | |
| 1096 #if defined(OS_CHROMEOS) | 1112 #if defined(OS_CHROMEOS) |
| 1097 username_hash_ = profile_params_->username_hash; | 1113 username_hash_ = profile_params_->username_hash; |
| 1098 use_system_key_slot_ = profile_params_->use_system_key_slot; | 1114 use_system_key_slot_ = profile_params_->use_system_key_slot; |
| 1099 if (use_system_key_slot_) | 1115 if (use_system_key_slot_) |
| 1100 EnableNSSSystemKeySlotForResourceContext(resource_context_.get()); | 1116 EnableNSSSystemKeySlotForResourceContext(resource_context_.get()); |
| 1101 | 1117 |
| 1102 crypto::ScopedPK11Slot public_slot = | 1118 crypto::ScopedPK11Slot public_slot = |
| 1103 crypto::GetPublicSlotForChromeOSUser(username_hash_); | 1119 crypto::GetPublicSlotForChromeOSUser(username_hash_); |
| 1104 // The private slot won't be ready by this point. It shouldn't be necessary | 1120 // The private slot won't be ready by this point. It shouldn't be necessary |
| 1105 // for cert trust purposes anyway. | 1121 // for cert trust purposes anyway. |
| 1106 scoped_refptr<net::CertVerifyProc> verify_proc( | 1122 scoped_refptr<net::CertVerifyProc> verify_proc( |
| 1107 new chromeos::CertVerifyProcChromeOS(public_slot.Pass())); | 1123 new chromeos::CertVerifyProcChromeOS(public_slot.Pass())); |
| 1108 if (policy_cert_verifier_) { | 1124 if (!cert_verifier) { |
|
Ryan Sleevi
2015/08/04 18:24:34
Rather than both sides of the #ifdef checking for
estark
2015/08/04 19:32:19
Done.
| |
| 1109 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get()); | 1125 if (policy_cert_verifier_) { |
| 1110 policy_cert_verifier_->InitializeOnIOThread(verify_proc); | 1126 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get()); |
| 1127 policy_cert_verifier_->InitializeOnIOThread(verify_proc); | |
| 1128 } else { | |
| 1129 cert_verifier_.reset( | |
| 1130 new net::MultiThreadedCertVerifier(verify_proc.get())); | |
| 1131 } | |
| 1132 cert_verifier = cert_verifier_.get(); | |
| 1133 } | |
| 1134 main_request_context_->set_cert_verifier(cert_verifier); | |
| 1135 #else | |
| 1136 if (cert_verifier) { | |
| 1137 main_request_context_->set_cert_verifier(cert_verifier); | |
| 1111 } else { | 1138 } else { |
| 1112 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get())); | 1139 main_request_context_->set_cert_verifier( |
| 1140 io_thread_globals->cert_verifier.get()); | |
| 1113 } | 1141 } |
| 1114 main_request_context_->set_cert_verifier(cert_verifier_.get()); | |
| 1115 #else | |
| 1116 main_request_context_->set_cert_verifier( | |
| 1117 io_thread_globals->cert_verifier.get()); | |
| 1118 #endif | 1142 #endif |
| 1119 | 1143 |
| 1120 // Install the New Tab Page Interceptor. | 1144 // Install the New Tab Page Interceptor. |
| 1121 if (profile_params_->new_tab_page_interceptor.get()) { | 1145 if (profile_params_->new_tab_page_interceptor.get()) { |
| 1122 request_interceptors.push_back( | 1146 request_interceptors.push_back( |
| 1123 profile_params_->new_tab_page_interceptor.release()); | 1147 profile_params_->new_tab_page_interceptor.release()); |
| 1124 } | 1148 } |
| 1125 | 1149 |
| 1126 InitializeInternal( | 1150 InitializeInternal( |
| 1127 network_delegate.Pass(), profile_params_.get(), | 1151 network_delegate.Pass(), profile_params_.get(), |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1312 new DevToolsNetworkTransactionFactory( | 1336 new DevToolsNetworkTransactionFactory( |
| 1313 network_controller_.get(), shared_session), | 1337 network_controller_.get(), shared_session), |
| 1314 shared_session->net_log(), backend)); | 1338 shared_session->net_log(), backend)); |
| 1315 } | 1339 } |
| 1316 | 1340 |
| 1317 void ProfileIOData::SetCookieSettingsForTesting( | 1341 void ProfileIOData::SetCookieSettingsForTesting( |
| 1318 content_settings::CookieSettings* cookie_settings) { | 1342 content_settings::CookieSettings* cookie_settings) { |
| 1319 DCHECK(!cookie_settings_.get()); | 1343 DCHECK(!cookie_settings_.get()); |
| 1320 cookie_settings_ = cookie_settings; | 1344 cookie_settings_ = cookie_settings; |
| 1321 } | 1345 } |
| OLD | NEW |