diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index 8d542b36f9d7..6f4f158073d4 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -6,6 +6,7 @@ #include "atom/browser/atom_browser_client.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_buffer_job.h" #include "atom/browser/net/url_request_fetch_job.h" @@ -192,7 +193,13 @@ void Protocol::BuildPrototype( namespace { void RegisterStandardSchemes( - const std::vector& schemes) { + const std::vector& 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(); for (const auto& scheme : schemes) { url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT); diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index 1f729240016b..f7bf48a250c2 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -1,13 +1,7 @@ const {app, session} = require('electron') const {registerStandardSchemes} = process.atomBinding('protocol') -exports.registerStandardSchemes = function (schemes) { - if (app.isReady()) { - console.warn('protocol.registerStandardSchemes should be called before app is ready') - return - } - registerStandardSchemes(schemes) -} +exports.registerStandardSchemes = registerStandardSchemes const setupProtocol = function () { let protocol = session.defaultSession.protocol