mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
docs: move protocol-ns to protocol.md (#23911)
* docs: move protocol-ns to protocol.md * chore: fix up tests and implement missing pieces required for tests Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
@@ -176,11 +176,12 @@ ProtocolError Protocol::RegisterProtocol(ProtocolType type,
|
||||
return added ? ProtocolError::OK : ProtocolError::REGISTERED;
|
||||
}
|
||||
|
||||
void Protocol::UnregisterProtocol(const std::string& scheme,
|
||||
bool Protocol::UnregisterProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
bool removed = protocol_registry_->UnregisterProtocol(scheme);
|
||||
HandleOptionalCallback(
|
||||
args, removed ? ProtocolError::OK : ProtocolError::NOT_REGISTERED);
|
||||
return removed;
|
||||
}
|
||||
|
||||
bool Protocol::IsProtocolRegistered(const std::string& scheme) {
|
||||
@@ -194,11 +195,12 @@ ProtocolError Protocol::InterceptProtocol(ProtocolType type,
|
||||
return added ? ProtocolError::OK : ProtocolError::INTERCEPTED;
|
||||
}
|
||||
|
||||
void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||
bool Protocol::UninterceptProtocol(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
bool removed = protocol_registry_->UninterceptProtocol(scheme);
|
||||
HandleOptionalCallback(
|
||||
args, removed ? ProtocolError::OK : ProtocolError::NOT_INTERCEPTED);
|
||||
return removed;
|
||||
}
|
||||
|
||||
bool Protocol::IsProtocolIntercepted(const std::string& scheme) {
|
||||
|
||||
@@ -58,13 +58,13 @@ class Protocol : public gin::Wrappable<Protocol> {
|
||||
ProtocolError RegisterProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler);
|
||||
void UnregisterProtocol(const std::string& scheme, gin::Arguments* args);
|
||||
bool UnregisterProtocol(const std::string& scheme, gin::Arguments* args);
|
||||
bool IsProtocolRegistered(const std::string& scheme);
|
||||
|
||||
ProtocolError InterceptProtocol(ProtocolType type,
|
||||
const std::string& scheme,
|
||||
const ProtocolHandler& handler);
|
||||
void UninterceptProtocol(const std::string& scheme, gin::Arguments* args);
|
||||
bool UninterceptProtocol(const std::string& scheme, gin::Arguments* args);
|
||||
bool IsProtocolIntercepted(const std::string& scheme);
|
||||
|
||||
// Old async version of IsProtocolRegistered.
|
||||
@@ -73,16 +73,20 @@ class Protocol : public gin::Wrappable<Protocol> {
|
||||
|
||||
// Helper for converting old registration APIs to new RegisterProtocol API.
|
||||
template <ProtocolType type>
|
||||
void RegisterProtocolFor(const std::string& scheme,
|
||||
bool RegisterProtocolFor(const std::string& scheme,
|
||||
const ProtocolHandler& handler,
|
||||
gin::Arguments* args) {
|
||||
HandleOptionalCallback(args, RegisterProtocol(type, scheme, handler));
|
||||
auto result = RegisterProtocol(type, scheme, handler);
|
||||
HandleOptionalCallback(args, result);
|
||||
return result == ProtocolError::OK;
|
||||
}
|
||||
template <ProtocolType type>
|
||||
void InterceptProtocolFor(const std::string& scheme,
|
||||
bool InterceptProtocolFor(const std::string& scheme,
|
||||
const ProtocolHandler& handler,
|
||||
gin::Arguments* args) {
|
||||
HandleOptionalCallback(args, InterceptProtocol(type, scheme, handler));
|
||||
auto result = InterceptProtocol(type, scheme, handler);
|
||||
HandleOptionalCallback(args, result);
|
||||
return result == ProtocolError::OK;
|
||||
}
|
||||
|
||||
// Be compatible with old interface, which accepts optional callback.
|
||||
|
||||
Reference in New Issue
Block a user