Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 1227943002: Allow browser tests to use a MockCertVerifier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix username_hash_, use_system_key_slot_ Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
159 #if defined(DEBUG_DEVTOOLS) 162 #if defined(DEBUG_DEVTOOLS)
160 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { 163 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
161 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); 164 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
162 bundled_path_prefix = "/" + bundled_path_prefix + "/"; 165 bundled_path_prefix = "/" + bundled_path_prefix + "/";
163 166
164 if (!url.SchemeIs(content::kChromeDevToolsScheme) || 167 if (!url.SchemeIs(content::kChromeDevToolsScheme) ||
165 url.host() != chrome::kChromeUIDevToolsHost || 168 url.host() != chrome::kChromeUIDevToolsHost ||
166 !base::StartsWith(url.path(), bundled_path_prefix, 169 !base::StartsWith(url.path(), bundled_path_prefix,
167 base::CompareCase::INSENSITIVE_ASCII)) { 170 base::CompareCase::INSENSITIVE_ASCII)) {
168 return false; 171 return false;
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 protocol_handlers->begin(); 744 protocol_handlers->begin();
742 it != protocol_handlers->end(); 745 it != protocol_handlers->end();
743 ++it) { 746 ++it) {
744 bool set_protocol = job_factory->SetProtocolHandler( 747 bool set_protocol = job_factory->SetProtocolHandler(
745 it->first, it->second.release()); 748 it->first, it->second.release());
746 DCHECK(set_protocol); 749 DCHECK(set_protocol);
747 } 750 }
748 protocol_handlers->clear(); 751 protocol_handlers->clear();
749 } 752 }
750 753
754 // static
755 void ProfileIOData::SetCertVerifierForTesting(
756 net::CertVerifier* cert_verifier) {
757 g_cert_verifier_for_testing = cert_verifier;
758 }
759
751 content::ResourceContext* ProfileIOData::GetResourceContext() const { 760 content::ResourceContext* ProfileIOData::GetResourceContext() const {
752 return resource_context_.get(); 761 return resource_context_.get();
753 } 762 }
754 763
755 net::URLRequestContext* ProfileIOData::GetMainRequestContext() const { 764 net::URLRequestContext* ProfileIOData::GetMainRequestContext() const {
756 DCHECK(initialized_); 765 DCHECK(initialized_);
757 return main_request_context_.get(); 766 return main_request_context_.get();
758 } 767 }
759 768
760 net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const { 769 net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1100 }
1092 1101
1093 #if defined(ENABLE_SUPERVISED_USERS) 1102 #if defined(ENABLE_SUPERVISED_USERS)
1094 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter; 1103 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter;
1095 #endif 1104 #endif
1096 1105
1097 #if defined(OS_CHROMEOS) 1106 #if defined(OS_CHROMEOS)
1098 username_hash_ = profile_params_->username_hash; 1107 username_hash_ = profile_params_->username_hash;
1099 use_system_key_slot_ = profile_params_->use_system_key_slot; 1108 use_system_key_slot_ = profile_params_->use_system_key_slot;
1100 if (use_system_key_slot_) 1109 if (use_system_key_slot_)
1101 EnableNSSSystemKeySlotForResourceContext(resource_context_.get()); 1110 EnableNSSSystemKeySlotForResourceContext(resource_context_.get());
mmenke 2015/08/05 20:59:13 I think two OS_CHROMEOS blocks is a little prettie
estark 2015/08/05 21:09:53 Ok, done.
1102 1111
1103 crypto::ScopedPK11Slot public_slot = 1112 if (g_cert_verifier_for_testing) {
1104 crypto::GetPublicSlotForChromeOSUser(username_hash_); 1113 main_request_context_->set_cert_verifier(g_cert_verifier_for_testing);
1105 // The private slot won't be ready by this point. It shouldn't be necessary
1106 // for cert trust purposes anyway.
1107 scoped_refptr<net::CertVerifyProc> verify_proc(
1108 new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
1109 if (policy_cert_verifier_) {
1110 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
1111 policy_cert_verifier_->InitializeOnIOThread(verify_proc);
1112 } else { 1114 } else {
1113 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get())); 1115 crypto::ScopedPK11Slot public_slot =
1116 crypto::GetPublicSlotForChromeOSUser(username_hash_);
1117 // The private slot won't be ready by this point. It shouldn't be necessary
1118 // for cert trust purposes anyway.
1119 scoped_refptr<net::CertVerifyProc> verify_proc(
1120 new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
1121 if (policy_cert_verifier_) {
1122 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
1123 policy_cert_verifier_->InitializeOnIOThread(verify_proc);
1124 } else {
1125 cert_verifier_.reset(
1126 new net::MultiThreadedCertVerifier(verify_proc.get()));
1127 }
1128 main_request_context_->set_cert_verifier(cert_verifier_.get());
1114 } 1129 }
1115 main_request_context_->set_cert_verifier(cert_verifier_.get());
1116 #else 1130 #else
1117 main_request_context_->set_cert_verifier( 1131 if (g_cert_verifier_for_testing) {
1118 io_thread_globals->cert_verifier.get()); 1132 main_request_context_->set_cert_verifier(g_cert_verifier_for_testing);
1133 } else {
1134 main_request_context_->set_cert_verifier(
1135 io_thread_globals->cert_verifier.get());
1136 }
1119 #endif 1137 #endif
1120 1138
1121 // Install the New Tab Page Interceptor. 1139 // Install the New Tab Page Interceptor.
1122 if (profile_params_->new_tab_page_interceptor.get()) { 1140 if (profile_params_->new_tab_page_interceptor.get()) {
1123 request_interceptors.push_back( 1141 request_interceptors.push_back(
1124 profile_params_->new_tab_page_interceptor.release()); 1142 profile_params_->new_tab_page_interceptor.release());
1125 } 1143 }
1126 1144
1127 InitializeInternal( 1145 InitializeInternal(
1128 network_delegate.Pass(), profile_params_.get(), 1146 network_delegate.Pass(), profile_params_.get(),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 new DevToolsNetworkTransactionFactory( 1331 new DevToolsNetworkTransactionFactory(
1314 network_controller_.get(), shared_session), 1332 network_controller_.get(), shared_session),
1315 shared_session->net_log(), backend)); 1333 shared_session->net_log(), backend));
1316 } 1334 }
1317 1335
1318 void ProfileIOData::SetCookieSettingsForTesting( 1336 void ProfileIOData::SetCookieSettingsForTesting(
1319 content_settings::CookieSettings* cookie_settings) { 1337 content_settings::CookieSettings* cookie_settings) {
1320 DCHECK(!cookie_settings_.get()); 1338 DCHECK(!cookie_settings_.get());
1321 cookie_settings_ = cookie_settings; 1339 cookie_settings_ = cookie_settings;
1322 } 1340 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | chrome/browser/ssl/cert_verifier_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698