Move the warning of registerStandardSchemes to native code

This commit is contained in:
Cheng Zhao 2016-07-12 16:51:31 +09:00
parent 13e1818bf7
commit 4ebb83e999
2 changed files with 9 additions and 8 deletions

View file

@ -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<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();
for (const auto& scheme : schemes) {
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);

View file

@ -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