feat: migrate protocol module to NetworkService (Part 7) (#18290)
* fix: make IsProtocolHandled return true for builtin schemes * fix: return ERR_NOT_IMPLEMENTED for wrong arg * Initial work of AsarURLLoader * Put normal file logics in AsarURLLoader * Implement asar file reading * Don't change URL for unpacked file * Fix cpplint warning
This commit is contained in:
parent
fde3137b90
commit
2ad62cedc3
5 changed files with 340 additions and 5 deletions
|
@ -17,6 +17,10 @@ namespace api {
|
|||
|
||||
namespace {
|
||||
|
||||
const char* kBuiltinSchemes[] = {
|
||||
"about", "file", "http", "https", "data", "filesystem",
|
||||
};
|
||||
|
||||
// Convert error code to string.
|
||||
std::string ErrorCodeToString(ProtocolError error) {
|
||||
switch (error) {
|
||||
|
@ -86,7 +90,15 @@ void ProtocolNS::UninterceptProtocol(const std::string& scheme,
|
|||
v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(
|
||||
const std::string& scheme) {
|
||||
util::Promise promise(isolate());
|
||||
promise.Resolve(IsProtocolRegistered(scheme));
|
||||
promise.Resolve(IsProtocolRegistered(scheme) ||
|
||||
// The |isProtocolHandled| should return true for builtin
|
||||
// schemes, however with NetworkService it is impossible to
|
||||
// know which schemes are registered until a real network
|
||||
// request is sent.
|
||||
// So we have to test against a hard-coded builtin schemes
|
||||
// list make it work with old code. We should deprecate this
|
||||
// API with the new |isProtocolRegistered| API.
|
||||
base::ContainsValue(kBuiltinSchemes, scheme));
|
||||
return promise.GetHandle();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue