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

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: put the files in the right .gypi 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
1111 #endif
1102 1112
1103 crypto::ScopedPK11Slot public_slot = 1113 if (g_cert_verifier_for_testing) {
1104 crypto::GetPublicSlotForChromeOSUser(username_hash_); 1114 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 { 1115 } else {
1113 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get())); 1116 #if defined(OS_CHROMEOS)
1117 crypto::ScopedPK11Slot public_slot =
1118 crypto::GetPublicSlotForChromeOSUser(username_hash_);
1119 // The private slot won't be ready by this point. It shouldn't be necessary
1120 // for cert trust purposes anyway.
1121 scoped_refptr<net::CertVerifyProc> verify_proc(
1122 new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
1123 if (policy_cert_verifier_) {
1124 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
1125 policy_cert_verifier_->InitializeOnIOThread(verify_proc);
1126 } else {
1127 cert_verifier_.reset(
1128 new net::MultiThreadedCertVerifier(verify_proc.get()));
1129 }
1130 main_request_context_->set_cert_verifier(cert_verifier_.get());
1131 #else
1132 main_request_context_->set_cert_verifier(
1133 io_thread_globals->cert_verifier.get());
1134 #endif
1114 } 1135 }
1115 main_request_context_->set_cert_verifier(cert_verifier_.get());
1116 #else
1117 main_request_context_->set_cert_verifier(
1118 io_thread_globals->cert_verifier.get());
1119 #endif
1120 1136
1121 // Install the New Tab Page Interceptor. 1137 // Install the New Tab Page Interceptor.
1122 if (profile_params_->new_tab_page_interceptor.get()) { 1138 if (profile_params_->new_tab_page_interceptor.get()) {
1123 request_interceptors.push_back( 1139 request_interceptors.push_back(
1124 profile_params_->new_tab_page_interceptor.release()); 1140 profile_params_->new_tab_page_interceptor.release());
1125 } 1141 }
1126 1142
1127 InitializeInternal( 1143 InitializeInternal(
1128 network_delegate.Pass(), profile_params_.get(), 1144 network_delegate.Pass(), profile_params_.get(),
1129 protocol_handlers, request_interceptors.Pass()); 1145 protocol_handlers, request_interceptors.Pass());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 new DevToolsNetworkTransactionFactory( 1329 new DevToolsNetworkTransactionFactory(
1314 network_controller_.get(), shared_session), 1330 network_controller_.get(), shared_session),
1315 shared_session->net_log(), backend)); 1331 shared_session->net_log(), backend));
1316 } 1332 }
1317 1333
1318 void ProfileIOData::SetCookieSettingsForTesting( 1334 void ProfileIOData::SetCookieSettingsForTesting(
1319 content_settings::CookieSettings* cookie_settings) { 1335 content_settings::CookieSettings* cookie_settings) {
1320 DCHECK(!cookie_settings_.get()); 1336 DCHECK(!cookie_settings_.get());
1321 cookie_settings_ = cookie_settings; 1337 cookie_settings_ = cookie_settings;
1322 } 1338 }
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