From 6f0471f6cb129edc758929079c66ca62ea9211b4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:42:06 -0700 Subject: [PATCH] Remove deprecated options check in BrowserWindow --- atom/browser/api/atom_api_window.cc | 18 ---------- lib/browser/api/browser-window.js | 55 +---------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ae5eec64cf93..2ef065bf51c9 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -52,11 +52,6 @@ namespace api { namespace { -// This function is implemented in JavaScript -using DeprecatedOptionsCheckCallback = - base::Callback)>; -DeprecatedOptionsCheckCallback g_deprecated_options_check; - void OnCapturePageDone( v8::Isolate* isolate, const base::Callback& callback, @@ -304,13 +299,6 @@ mate::WrappableBase* Window::New(v8::Isolate* isolate, mate::Arguments* args) { options = mate::Dictionary::CreateEmpty(isolate); } - std::string deprecation_message = g_deprecated_options_check.Run( - options.GetHandle()); - if (deprecation_message.length() > 0) { - args->ThrowError(deprecation_message); - return nullptr; - } - return new Window(isolate, options); } @@ -822,10 +810,6 @@ v8::Local Window::From(v8::Isolate* isolate, return v8::Null(isolate); } -void SetDeprecatedOptionsCheck(const DeprecatedOptionsCheckCallback& callback) { - g_deprecated_options_check = callback; -} - } // namespace api } // namespace atom @@ -848,8 +832,6 @@ void Initialize(v8::Local exports, v8::Local unused, mate::Dictionary dict(isolate, exports); dict.Set("BrowserWindow", browser_window); - dict.SetMethod("_setDeprecatedOptionsCheck", - &atom::api::SetDeprecatedOptionsCheck); } } // namespace diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 7eec5c1cc441..e433580ba638 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -1,9 +1,8 @@ 'use strict' const ipcMain = require('electron').ipcMain -const deprecate = require('electron').deprecate const EventEmitter = require('events').EventEmitter -const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window') +const {BrowserWindow} = process.atomBinding('window') Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype) @@ -196,56 +195,4 @@ BrowserWindow.prototype.inspectServiceWorker = function () { return this.webContents.inspectServiceWorker() } -const isDeprecatedKey = function (key) { - return key.indexOf('-') >= 0 -} - -// Map deprecated key with hyphens to camel case key -const getNonDeprecatedKey = function (deprecatedKey) { - return deprecatedKey.replace(/-./g, function (match) { - return match[1].toUpperCase() - }) -} - -// TODO Remove for 1.0 -const checkForDeprecatedOptions = function (options) { - if (!options) return '' - - let keysToCheck = Object.keys(options) - if (options.webPreferences) { - keysToCheck = keysToCheck.concat(Object.keys(options.webPreferences)) - } - - // Check options for keys with hyphens in them - let deprecatedKey = keysToCheck.filter(isDeprecatedKey)[0] - if (deprecatedKey) { - try { - deprecate.warn(deprecatedKey, getNonDeprecatedKey(deprecatedKey)) - } catch (error) { - // Return error message so it can be rethrown via C++ - return error.message - } - } - - let webPreferenceOption - if (options.hasOwnProperty('nodeIntegration')) { - webPreferenceOption = 'nodeIntegration' - } else if (options.hasOwnProperty('preload')) { - webPreferenceOption = 'preload' - } else if (options.hasOwnProperty('zoomFactor')) { - webPreferenceOption = 'zoomFactor' - } - if (webPreferenceOption) { - try { - deprecate.warn(`options.${webPreferenceOption}`, `options.webPreferences.${webPreferenceOption}`) - } catch (error) { - // Return error message so it can be rethrown via C++ - return error.message - } - } - - return '' -} -_setDeprecatedOptionsCheck(checkForDeprecatedOptions) - module.exports = BrowserWindow