docs: documentation of NetworkService-based protocol module (#18952)

* docs: NetworkService-based protocol module

* docs: separate ProtocolRequest

* docs: separate ProtocolResponse

* docs: fix lint warning

* docs: fix electron.d.ts

* fix: print deprecation warnings for protocol module

* docs: fix links

* Apply suggestions from code review

Co-Authored-By: Felix Rieseberg <felix@felixrieseberg.com>

* Apply suggestions from code review

Co-Authored-By: Samuel Attard <samuel.r.attard@gmail.com>

* Do not publish NetworkService changes draft

* Apply suggestions from code review

Co-Authored-By: Samuel Attard <samuel.r.attard@gmail.com>

* docs: filePath must be absolute
This commit is contained in:
Cheng Zhao 2019-06-28 16:25:30 +09:00 committed by GitHub
parent 127d617db5
commit 0a9438dbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 451 additions and 6 deletions

View file

@ -9,6 +9,7 @@
#include "base/stl_util.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/common/deprecate_util.h"
#include "shell/common/native_mate_converters/net_converter.h"
#include "shell/common/native_mate_converters/once_callback.h"
#include "shell/common/promise_util.h"
@ -106,8 +107,15 @@ bool ProtocolNS::IsProtocolIntercepted(const std::string& scheme) {
return base::ContainsKey(intercept_handlers_, scheme);
}
v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(
const std::string& scheme) {
v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(const std::string& scheme,
mate::Arguments* args) {
node::Environment* env = node::Environment::GetCurrent(args->isolate());
EmitDeprecationWarning(
env,
"The protocol.isProtocolHandled API is deprecated, use "
"protocol.isProtocolRegistered or protocol.isProtocolIntercepted "
"instead.",
"ProtocolDeprecateIsProtocolHandled");
util::Promise promise(isolate());
promise.Resolve(IsProtocolRegistered(scheme) ||
IsProtocolIntercepted(scheme) ||
@ -126,6 +134,11 @@ void ProtocolNS::HandleOptionalCallback(mate::Arguments* args,
ProtocolError error) {
CompletionCallback callback;
if (args->GetNext(&callback)) {
node::Environment* env = node::Environment::GetCurrent(args->isolate());
EmitDeprecationWarning(
env,
"The callback argument of protocol module APIs is no longer needed.",
"ProtocolDeprecateCallback");
if (error == ProtocolError::OK)
callback.Run(v8::Null(args->isolate()));
else

View file

@ -65,7 +65,8 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
bool IsProtocolIntercepted(const std::string& scheme);
// Old async version of IsProtocolRegistered.
v8::Local<v8::Promise> IsProtocolHandled(const std::string& scheme);
v8::Local<v8::Promise> IsProtocolHandled(const std::string& scheme,
mate::Arguments* args);
// Helper for converting old registration APIs to new RegisterProtocol API.
template <ProtocolType type>