]> khamidou — GitHub mirrors - electron.git/commitdiff
Skelecton for interceptor APIs.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 02:15:15 +0000 (10:15 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 02:15:15 +0000 (10:15 +0800)
browser/api/atom_api_protocol.cc
browser/api/atom_api_protocol.h

index 258081251902b4772ae791b95fcd65a78f8560cf..170ef1e55e5b5fcf876a4de2ea308d7da8a2032a 100644 (file)
@@ -25,6 +25,7 @@ namespace {
 // Remember the protocol module object.
 v8::Persistent<v8::Object> g_protocol_object;
 
+// Registered protocol handlers.
 typedef std::map<std::string, v8::Persistent<v8::Function>> HandlersMap;
 static HandlersMap g_handlers;
 
@@ -331,6 +332,16 @@ v8::Handle<v8::Value> Protocol::IsHandledProtocol(const v8::Arguments& args) {
       *v8::String::Utf8Value(args[0])));
 }
 
+// static
+v8::Handle<v8::Value> Protocol::InterceptProtocol(const v8::Arguments& args) {
+  return v8::Undefined();
+}
+
+// static
+v8::Handle<v8::Value> 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<v8::Object> target) {
   g_protocol_object = v8::Persistent<v8::Object>::New(
index 4b9b0bfe3293b49ac32472ac4e9d544a97fc72b4..6e38b5014695ed4d272530bbe655d3cf0ef15abd 100644 (file)
@@ -24,9 +24,15 @@ class Protocol {
   static v8::Handle<v8::Value> UnregisterProtocol(const v8::Arguments& args);
   static v8::Handle<v8::Value> IsHandledProtocol(const v8::Arguments& args);
 
+  static v8::Handle<v8::Value> InterceptProtocol(const v8::Arguments& args);
+  static v8::Handle<v8::Value> 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);
 };