Implement protocol.isHandledProtocol

This commit is contained in:
Cheng Zhao 2015-08-13 19:33:53 +08:00
parent 05fd81ebdc
commit 374d83ed9c
2 changed files with 22 additions and 2 deletions

View file

@ -34,6 +34,7 @@ class Protocol : public mate::Wrappable {
using Handler =
base::Callback<void(const net::URLRequest*, v8::Local<v8::Value>)>;
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
using BooleanCallback = base::Callback<void(bool)>;
static mate::Handle<Protocol> Create(
v8::Isolate* isolate, AtomBrowserContext* browser_context);
@ -118,10 +119,15 @@ class Protocol : public mate::Wrappable {
return PROTOCOL_FAIL;
}
// Unregistered the protocol handler that handles |scheme|.
// Unregister the protocol handler that handles |scheme|.
void UnregisterProtocol(const std::string& scheme, mate::Arguments* args);
ProtocolError UnregisterProtocolInIO(const std::string& scheme);
// Whether the protocol has handler registered.
void IsHandledProtocol(const std::string& scheme,
const BooleanCallback& callback);
bool IsHandledProtocolInIO(const std::string& scheme);
// Convert error code to JS exception and call the callback.
void OnIOCompleted(const CompletionCallback& callback, ProtocolError error);