chore: use dummy WebRequestNS when NetworkService is enabled (#19300)
This commit is contained in:
parent
c79613b037
commit
478360f317
4 changed files with 82 additions and 2 deletions
|
@ -105,6 +105,8 @@ filenames = {
|
||||||
"shell/browser/api/atom_api_web_contents_view.h",
|
"shell/browser/api/atom_api_web_contents_view.h",
|
||||||
"shell/browser/api/atom_api_web_request.cc",
|
"shell/browser/api/atom_api_web_request.cc",
|
||||||
"shell/browser/api/atom_api_web_request.h",
|
"shell/browser/api/atom_api_web_request.h",
|
||||||
|
"shell/browser/api/atom_api_web_request_ns.cc",
|
||||||
|
"shell/browser/api/atom_api_web_request_ns.h",
|
||||||
"shell/browser/api/atom_api_web_view_manager.cc",
|
"shell/browser/api/atom_api_web_view_manager.cc",
|
||||||
"shell/browser/api/atom_api_browser_window.cc",
|
"shell/browser/api/atom_api_browser_window.cc",
|
||||||
"shell/browser/api/atom_api_browser_window.h",
|
"shell/browser/api/atom_api_browser_window.h",
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "shell/browser/api/atom_api_protocol.h"
|
#include "shell/browser/api/atom_api_protocol.h"
|
||||||
#include "shell/browser/api/atom_api_protocol_ns.h"
|
#include "shell/browser/api/atom_api_protocol_ns.h"
|
||||||
#include "shell/browser/api/atom_api_web_request.h"
|
#include "shell/browser/api/atom_api_web_request.h"
|
||||||
|
#include "shell/browser/api/atom_api_web_request_ns.h"
|
||||||
#include "shell/browser/atom_browser_context.h"
|
#include "shell/browser/atom_browser_context.h"
|
||||||
#include "shell/browser/atom_browser_main_parts.h"
|
#include "shell/browser/atom_browser_main_parts.h"
|
||||||
#include "shell/browser/atom_permission_manager.h"
|
#include "shell/browser/atom_permission_manager.h"
|
||||||
|
@ -659,8 +660,12 @@ v8::Local<v8::Value> Session::Protocol(v8::Isolate* isolate) {
|
||||||
|
|
||||||
v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
|
v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
|
||||||
if (web_request_.IsEmpty()) {
|
if (web_request_.IsEmpty()) {
|
||||||
auto handle = electron::api::WebRequest::Create(isolate, browser_context());
|
v8::Local<v8::Value> handle;
|
||||||
web_request_.Reset(isolate, handle.ToV8());
|
if (base::FeatureList::IsEnabled(network::features::kNetworkService))
|
||||||
|
handle = WebRequestNS::Create(isolate, browser_context()).ToV8();
|
||||||
|
else
|
||||||
|
handle = WebRequest::Create(isolate, browser_context()).ToV8();
|
||||||
|
web_request_.Reset(isolate, handle);
|
||||||
}
|
}
|
||||||
return v8::Local<v8::Value>::New(isolate, web_request_);
|
return v8::Local<v8::Value>::New(isolate, web_request_);
|
||||||
}
|
}
|
||||||
|
|
38
shell/browser/api/atom_api_web_request_ns.cc
Normal file
38
shell/browser/api/atom_api_web_request_ns.cc
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "shell/browser/api/atom_api_web_request_ns.h"
|
||||||
|
|
||||||
|
#include "shell/browser/atom_browser_context.h"
|
||||||
|
|
||||||
|
namespace electron {
|
||||||
|
|
||||||
|
namespace api {
|
||||||
|
|
||||||
|
WebRequestNS::WebRequestNS(v8::Isolate* isolate,
|
||||||
|
AtomBrowserContext* browser_context) {
|
||||||
|
Init(isolate);
|
||||||
|
AttachAsUserData(browser_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRequestNS::~WebRequestNS() = default;
|
||||||
|
|
||||||
|
// static
|
||||||
|
mate::Handle<WebRequestNS> WebRequestNS::Create(
|
||||||
|
v8::Isolate* isolate,
|
||||||
|
AtomBrowserContext* browser_context) {
|
||||||
|
return mate::CreateHandle(isolate,
|
||||||
|
new WebRequestNS(isolate, browser_context));
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void WebRequestNS::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
|
prototype->SetClassName(mate::StringToV8(isolate, "WebRequest"));
|
||||||
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace api
|
||||||
|
|
||||||
|
} // namespace electron
|
35
shell/browser/api/atom_api_web_request_ns.h
Normal file
35
shell/browser/api/atom_api_web_request_ns.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
||||||
|
#define SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
||||||
|
|
||||||
|
#include "native_mate/dictionary.h"
|
||||||
|
#include "native_mate/handle.h"
|
||||||
|
#include "shell/browser/api/trackable_object.h"
|
||||||
|
|
||||||
|
namespace electron {
|
||||||
|
|
||||||
|
class AtomBrowserContext;
|
||||||
|
|
||||||
|
namespace api {
|
||||||
|
|
||||||
|
class WebRequestNS : public mate::TrackableObject<WebRequestNS> {
|
||||||
|
public:
|
||||||
|
static mate::Handle<WebRequestNS> Create(v8::Isolate* isolate,
|
||||||
|
AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
|
private:
|
||||||
|
WebRequestNS(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||||
|
~WebRequestNS() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace api
|
||||||
|
|
||||||
|
} // namespace electron
|
||||||
|
|
||||||
|
#endif // SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
|
Loading…
Add table
Add a link
Reference in a new issue