Move the warning of registerStandardSchemes to native code
This commit is contained in:
parent
13e1818bf7
commit
4ebb83e999
2 changed files with 9 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "atom/browser/atom_browser_client.h"
|
#include "atom/browser/atom_browser_client.h"
|
||||||
#include "atom/browser/atom_browser_main_parts.h"
|
#include "atom/browser/atom_browser_main_parts.h"
|
||||||
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/net/url_request_async_asar_job.h"
|
#include "atom/browser/net/url_request_async_asar_job.h"
|
||||||
#include "atom/browser/net/url_request_buffer_job.h"
|
#include "atom/browser/net/url_request_buffer_job.h"
|
||||||
#include "atom/browser/net/url_request_fetch_job.h"
|
#include "atom/browser/net/url_request_fetch_job.h"
|
||||||
|
@ -192,7 +193,13 @@ void Protocol::BuildPrototype(
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void RegisterStandardSchemes(
|
void RegisterStandardSchemes(
|
||||||
const std::vector<std::string>& schemes) {
|
const std::vector<std::string>& schemes, mate::Arguments* args) {
|
||||||
|
if (atom::Browser::Get()->is_ready()) {
|
||||||
|
args->ThrowError("protocol.registerStandardSchemes should be called before "
|
||||||
|
"app is ready");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto policy = content::ChildProcessSecurityPolicy::GetInstance();
|
auto policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||||
for (const auto& scheme : schemes) {
|
for (const auto& scheme : schemes) {
|
||||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
const {app, session} = require('electron')
|
const {app, session} = require('electron')
|
||||||
const {registerStandardSchemes} = process.atomBinding('protocol')
|
const {registerStandardSchemes} = process.atomBinding('protocol')
|
||||||
|
|
||||||
exports.registerStandardSchemes = function (schemes) {
|
exports.registerStandardSchemes = registerStandardSchemes
|
||||||
if (app.isReady()) {
|
|
||||||
console.warn('protocol.registerStandardSchemes should be called before app is ready')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
registerStandardSchemes(schemes)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setupProtocol = function () {
|
const setupProtocol = function () {
|
||||||
let protocol = session.defaultSession.protocol
|
let protocol = session.defaultSession.protocol
|
||||||
|
|
Loading…
Reference in a new issue