From 335db788a51261a33a082ac34e12cd0f83a54d10 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 30 Aug 2013 21:15:46 +0800 Subject: [PATCH] Add InterceptProtocol AtomURLRequestJobFactory. --- browser/net/atom_url_request_job_factory.cc | 15 +++++++++++++++ browser/net/atom_url_request_job_factory.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/browser/net/atom_url_request_job_factory.cc b/browser/net/atom_url_request_job_factory.cc index a2c8f76..f32a3ee 100644 --- a/browser/net/atom_url_request_job_factory.cc +++ b/browser/net/atom_url_request_job_factory.cc @@ -12,6 +12,8 @@ namespace atom { +typedef net::URLRequestJobFactory::ProtocolHandler ProtocolHandler; + AtomURLRequestJobFactory::AtomURLRequestJobFactory() {} AtomURLRequestJobFactory::~AtomURLRequestJobFactory() { @@ -39,6 +41,19 @@ bool AtomURLRequestJobFactory::SetProtocolHandler( return true; } +ProtocolHandler* AtomURLRequestJobFactory::InterceptProtocol( + const std::string& scheme, + ProtocolHandler* protocol_handler) { + DCHECK(CalledOnValidThread()); + DCHECK(protocol_handler); + + if (!ContainsKey(protocol_handler_map_, scheme)) + return NULL; + ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme]; + protocol_handler_map_[scheme] = protocol_handler; + return original_protocol_handler; +} + net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( const std::string& scheme, net::URLRequest* request, diff --git a/browser/net/atom_url_request_job_factory.h b/browser/net/atom_url_request_job_factory.h index 989e5e8..8fa5d5b 100644 --- a/browser/net/atom_url_request_job_factory.h +++ b/browser/net/atom_url_request_job_factory.h @@ -26,6 +26,11 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory { bool SetProtocolHandler(const std::string& scheme, ProtocolHandler* protocol_handler); + // Intercepts the ProtocolHandler for a scheme. Returns the original protocol + // handler on success, otherwise returns NULL. + ProtocolHandler* InterceptProtocol(const std::string& scheme, + ProtocolHandler* protocol_handler); + // URLRequestJobFactory implementation virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( const std::string& scheme, -- 2.7.4