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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_io_data.cc
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index a1493878f535560da8cb5027c6662032084c85ec..4a7e2caae6924e7721ff3718a5f11886ac6df173 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -64,6 +64,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/resource_context.h"
#include "net/base/keygen_handler.h"
+#include "net/cert/cert_verifier.h"
#include "net/cookies/canonical_cookie.h"
#include "net/http/http_transaction_factory.h"
#include "net/http/http_util.h"
@@ -156,6 +157,8 @@ using content::ResourceContext;
namespace {
+net::CertVerifier* g_cert_verifier_for_testing = nullptr;
+
#if defined(DEBUG_DEVTOOLS)
bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
@@ -748,6 +751,12 @@ void ProfileIOData::InstallProtocolHandlers(
protocol_handlers->clear();
}
+// static
+void ProfileIOData::SetCertVerifierForTesting(
+ net::CertVerifier* cert_verifier) {
+ g_cert_verifier_for_testing = cert_verifier;
+}
+
content::ResourceContext* ProfileIOData::GetResourceContext() const {
return resource_context_.get();
}
@@ -1100,22 +1109,31 @@ void ProfileIOData::Init(
if (use_system_key_slot_)
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.
- crypto::ScopedPK11Slot public_slot =
- crypto::GetPublicSlotForChromeOSUser(username_hash_);
- // The private slot won't be ready by this point. It shouldn't be necessary
- // for cert trust purposes anyway.
- scoped_refptr<net::CertVerifyProc> verify_proc(
- new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
- if (policy_cert_verifier_) {
- DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
- policy_cert_verifier_->InitializeOnIOThread(verify_proc);
+ if (g_cert_verifier_for_testing) {
+ main_request_context_->set_cert_verifier(g_cert_verifier_for_testing);
} else {
- cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get()));
+ crypto::ScopedPK11Slot public_slot =
+ crypto::GetPublicSlotForChromeOSUser(username_hash_);
+ // The private slot won't be ready by this point. It shouldn't be necessary
+ // for cert trust purposes anyway.
+ scoped_refptr<net::CertVerifyProc> verify_proc(
+ new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
+ if (policy_cert_verifier_) {
+ DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
+ policy_cert_verifier_->InitializeOnIOThread(verify_proc);
+ } else {
+ cert_verifier_.reset(
+ new net::MultiThreadedCertVerifier(verify_proc.get()));
+ }
+ main_request_context_->set_cert_verifier(cert_verifier_.get());
}
- main_request_context_->set_cert_verifier(cert_verifier_.get());
#else
- main_request_context_->set_cert_verifier(
- io_thread_globals->cert_verifier.get());
+ if (g_cert_verifier_for_testing) {
+ main_request_context_->set_cert_verifier(g_cert_verifier_for_testing);
+ } else {
+ main_request_context_->set_cert_verifier(
+ io_thread_globals->cert_verifier.get());
+ }
#endif
// Install the New Tab Page Interceptor.
« 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