From 474e1fcd3b79e8d5028fd925d453d854d0ab9fa5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 15 Dec 2013 16:53:07 +0800 Subject: [PATCH] Fix protocol module specs. --- browser/api/atom_api_protocol.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/browser/api/atom_api_protocol.cc b/browser/api/atom_api_protocol.cc index f7e49a23b2f2..01dc0de4bac0 100644 --- a/browser/api/atom_api_protocol.cc +++ b/browser/api/atom_api_protocol.cc @@ -188,7 +188,7 @@ void Protocol::RegisterProtocol( return node::ThrowTypeError("Bad argument"); if (g_handlers.find(scheme) != g_handlers.end() || - net::URLRequest::IsHandledProtocol(scheme)) + GetRequestJobFactory()->IsHandledProtocol(scheme)) return node::ThrowError("The scheme is already registered"); if (AtomBrowserContext::Get()->url_request_context_getter() == NULL) @@ -226,8 +226,11 @@ void Protocol::UnregisterProtocol( // static void Protocol::IsHandledProtocol( const v8::FunctionCallbackInfo& args) { - std::string scheme = FromV8Value(args[0]); - args.GetReturnValue().Set(net::URLRequest::IsHandledProtocol(scheme)); + std::string scheme; + if (!FromV8Arguments(args, &scheme)) + return node::ThrowTypeError("Bad argument"); + + args.GetReturnValue().Set(GetRequestJobFactory()->IsHandledProtocol(scheme)); } // static @@ -361,7 +364,7 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) { // static void Protocol::Initialize(v8::Handle target) { // Remember the protocol object, used for emitting event later. - g_protocol_object.reset(v8::Object::New()); + g_protocol_object.reset(target); NODE_SET_METHOD(target, "registerProtocol", RegisterProtocol); NODE_SET_METHOD(target, "unregisterProtocol", UnregisterProtocol);