From 04910b8391d877df4ec8d904add59b74d86e23e0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 30 Aug 2013 10:15:15 +0800 Subject: [PATCH] Skelecton for interceptor APIs. --- browser/api/atom_api_protocol.cc | 22 ++++++++++++++++++++++ browser/api/atom_api_protocol.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/browser/api/atom_api_protocol.cc b/browser/api/atom_api_protocol.cc index 25808125..170ef1e5 100644 --- a/browser/api/atom_api_protocol.cc +++ b/browser/api/atom_api_protocol.cc @@ -25,6 +25,7 @@ namespace { // Remember the protocol module object. v8::Persistent g_protocol_object; +// Registered protocol handlers. typedef std::map> HandlersMap; static HandlersMap g_handlers; @@ -331,6 +332,16 @@ v8::Handle Protocol::IsHandledProtocol(const v8::Arguments& args) { *v8::String::Utf8Value(args[0]))); } +// static +v8::Handle Protocol::InterceptProtocol(const v8::Arguments& args) { + return v8::Undefined(); +} + +// static +v8::Handle Protocol::UninterceptProtocol(const v8::Arguments& args) { + return v8::Undefined(); +} + // static void Protocol::RegisterProtocolInIO(const std::string& scheme) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); @@ -357,6 +368,17 @@ void Protocol::UnregisterProtocolInIO(const std::string& scheme) { scheme)); } +// static +void Protocol::InterceptProtocolInIO(const std::string& scheme) { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); + net::URLRequestJobFactoryImpl* job_factory(GetRequestJobFactory()); + job_factory->SetProtocolHandler(scheme, new AdapterProtocolHandler); +} + +// static +void Protocol::UninterceptProtocolInIO(const std::string& scheme) { +} + // static void Protocol::Initialize(v8::Handle target) { g_protocol_object = v8::Persistent::New( diff --git a/browser/api/atom_api_protocol.h b/browser/api/atom_api_protocol.h index 4b9b0bfe..6e38b501 100644 --- a/browser/api/atom_api_protocol.h +++ b/browser/api/atom_api_protocol.h @@ -24,9 +24,15 @@ class Protocol { static v8::Handle UnregisterProtocol(const v8::Arguments& args); static v8::Handle IsHandledProtocol(const v8::Arguments& args); + static v8::Handle InterceptProtocol(const v8::Arguments& args); + static v8::Handle UninterceptProtocol(const v8::Arguments& args); + static void RegisterProtocolInIO(const std::string& scheme); static void UnregisterProtocolInIO(const std::string& scheme); + static void InterceptProtocolInIO(const std::string& scheme); + static void UninterceptProtocolInIO(const std::string& scheme); + DISALLOW_IMPLICIT_CONSTRUCTORS(Protocol); }; -- 2.43.0