]> khamidou — GitHub mirrors - electron.git/commitdiff
Add protocol.isHandledProtocol API.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 29 Aug 2013 12:22:52 +0000 (20:22 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 29 Aug 2013 12:22:52 +0000 (20:22 +0800)
browser/api/atom_api_protocol.cc
browser/api/atom_api_protocol.h

index 8fe1571c274bfa2d81b13d367386e8bf984634a5..69f7ebe719f8cbfb483d253b1e29e68ae2c2fccd 100644 (file)
@@ -298,6 +298,12 @@ v8::Handle<v8::Value> Protocol::UnregisterProtocol(const v8::Arguments& args) {
   return v8::Undefined();
 }
 
+// static
+v8::Handle<v8::Value> Protocol::IsHandledProtocol(const v8::Arguments& args) {
+  return v8::Boolean::New(net::URLRequest::IsHandledProtocol(
+      *v8::String::Utf8Value(args[0])));
+}
+
 // static
 void Protocol::RegisterProtocolInIO(const std::string& scheme) {
   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
@@ -316,6 +322,7 @@ void Protocol::UnregisterProtocolInIO(const std::string& scheme) {
 void Protocol::Initialize(v8::Handle<v8::Object> target) {
   node::SetMethod(target, "registerProtocol", RegisterProtocol);
   node::SetMethod(target, "unregisterProtocol", UnregisterProtocol);
+  node::SetMethod(target, "isHandledProtocol", IsHandledProtocol);
 }
 
 }  // namespace api
index 7e2f0bf36d27f7eb73bc1ba7181dd1d3a0f362a4..4b9b0bfe3293b49ac32472ac4e9d544a97fc72b4 100644 (file)
@@ -22,6 +22,7 @@ class Protocol {
  private:
   static v8::Handle<v8::Value> RegisterProtocol(const v8::Arguments& args);
   static v8::Handle<v8::Value> UnregisterProtocol(const v8::Arguments& args);
+  static v8::Handle<v8::Value> IsHandledProtocol(const v8::Arguments& args);
 
   static void RegisterProtocolInIO(const std::string& scheme);
   static void UnregisterProtocolInIO(const std::string& scheme);