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

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: move factory-setter to ProfileIOData to work with ChromeOS 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
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 73f9efbd44439248fb9a8e8ee81d64a5f897133a..d9bb5822d7400d5955acd0e4fccf3d049aa2a022 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,14 @@ using content::ResourceContext;
namespace {
+net::CertVerifierFactory* g_cert_verifier_factory_for_testing = nullptr;
+
+net::CertVerifier* GetCertVerifierFromTestingFactory() {
+ if (g_cert_verifier_factory_for_testing)
+ return g_cert_verifier_factory_for_testing->CreateCertVerifier();
+ return nullptr;
+}
+
#if defined(DEBUG_DEVTOOLS)
bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
@@ -747,6 +756,12 @@ void ProfileIOData::InstallProtocolHandlers(
protocol_handlers->clear();
}
+// static
+void ProfileIOData::SetCertVerifierFactoryForTesting(
+ net::CertVerifierFactory* cert_verifier_factory) {
+ g_cert_verifier_factory_for_testing = cert_verifier_factory;
+}
+
content::ResourceContext* ProfileIOData::GetResourceContext() const {
return resource_context_.get();
}
@@ -1093,6 +1108,7 @@ void ProfileIOData::Init(
supervised_user_url_filter_ = profile_params_->supervised_user_url_filter;
#endif
+ net::CertVerifier* cert_verifier = GetCertVerifierFromTestingFactory();
#if defined(OS_CHROMEOS)
username_hash_ = profile_params_->username_hash;
use_system_key_slot_ = profile_params_->use_system_key_slot;
@@ -1105,7 +1121,9 @@ void ProfileIOData::Init(
// for cert trust purposes anyway.
scoped_refptr<net::CertVerifyProc> verify_proc(
new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
- if (policy_cert_verifier_) {
+ if (cert_verifier) {
+ cert_verifier_.reset(cert_verifier);
+ } else if (policy_cert_verifier_) {
DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
policy_cert_verifier_->InitializeOnIOThread(verify_proc);
} else {
@@ -1113,8 +1131,13 @@ void ProfileIOData::Init(
}
main_request_context_->set_cert_verifier(cert_verifier_.get());
#else
- main_request_context_->set_cert_verifier(
- io_thread_globals->cert_verifier.get());
+ if (cert_verifier) {
+ cert_verifier_.reset(cert_verifier);
+ main_request_context_->set_cert_verifier(cert_verifier_.get());
+ } else {
+ main_request_context_->set_cert_verifier(
+ io_thread_globals->cert_verifier.get());
+ }
#endif
// Install the New Tab Page Interceptor.

Powered by Google App Engine
This is Rietveld 408576698