Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: extensions/renderer/resources/platform_app.js

Issue 1333303002: bindings: Fixes exposed JS APIs for platform apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $console = window.console; 5 var $console = window.console;
not at google - send to devlin 2015/09/15 20:04:45 cleanup: we now save the console object automatica
Yuki 2015/09/16 03:21:53 Done.
6 6
7 /** 7 /**
8 * Returns a function that logs a 'not available' error to the console and 8 * Returns a function that logs a 'not available' error to the console and
9 * returns undefined. 9 * returns undefined.
10 * 10 *
11 * @param {string} messagePrefix text to prepend to the exception message. 11 * @param {string} messagePrefix text to prepend to the exception message.
12 */ 12 */
13 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) { 13 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) {
14 var message = messagePrefix + ' is not available in packaged apps.'; 14 var message = messagePrefix + ' is not available in packaged apps.';
15 if (opt_messageSuffix) message = message + ' ' + opt_messageSuffix; 15 if (opt_messageSuffix) message = message + ' ' + opt_messageSuffix;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 // Replace evil Document methods with exception-throwing stubs. 151 // Replace evil Document methods with exception-throwing stubs.
152 disableMethods(HTMLDocument.prototype, 'document', ['write', 'writeln'], true); 152 disableMethods(HTMLDocument.prototype, 'document', ['write', 'writeln'], true);
153 153
154 // Disable history. 154 // Disable history.
155 Object.defineProperty(window, "history", { value: {} }); 155 Object.defineProperty(window, "history", { value: {} });
156 disableGetters(window.history, 'history', 156 disableGetters(window.history, 'history',
157 ['back', 'forward', 'go', 'length', 'pushState', 'replaceState']); 157 ['back', 'forward', 'go', 'length', 'pushState', 'replaceState']);
158 158
159 // Disable find. 159 // Disable find.
160 disableMethods(window, 'window', ['find']);
160 disableMethods(Window.prototype, 'window', ['find']); 161 disableMethods(Window.prototype, 'window', ['find']);
161 162
162 // Disable modal dialogs. Shell windows disable these anyway, but it's nice to 163 // Disable modal dialogs. Shell windows disable these anyway, but it's nice to
163 // warn. 164 // warn.
165 disableMethods(window, 'window', ['alert', 'confirm', 'prompt']);
164 disableMethods(Window.prototype, 'window', ['alert', 'confirm', 'prompt']); 166 disableMethods(Window.prototype, 'window', ['alert', 'confirm', 'prompt']);
165 167
166 // Disable window.*bar. 168 // Disable window.*bar.
167 disableGetters(window, 'window', 169 disableGetters(window, 'window',
168 ['locationbar', 'menubar', 'personalbar', 'scrollbars', 'statusbar', 170 ['locationbar', 'menubar', 'personalbar', 'scrollbars', 'statusbar',
169 'toolbar']); 171 'toolbar']);
170 172
171 // Disable window.localStorage. 173 // Disable window.localStorage.
172 // Sometimes DOM security policy prevents us from doing this (e.g. for data: 174 // Sometimes DOM security policy prevents us from doing this (e.g. for data:
173 // URLs) so wrap in try-catch. 175 // URLs) so wrap in try-catch.
(...skipping 17 matching lines...) Expand all
191 // https://developer.mozilla.org/en/DOM/document. 193 // https://developer.mozilla.org/en/DOM/document.
192 // To deprecate document.all, simply changing its getter and setter would 194 // To deprecate document.all, simply changing its getter and setter would
193 // activate its cache mechanism, and degrade the performance. Here we assign 195 // activate its cache mechanism, and degrade the performance. Here we assign
194 // it first to 'undefined' to avoid this. 196 // it first to 'undefined' to avoid this.
195 document.all = undefined; 197 document.all = undefined;
196 disableGetters(document, 'document', 198 disableGetters(document, 'document',
197 ['alinkColor', 'all', 'bgColor', 'fgColor', 'linkColor', 'vlinkColor']); 199 ['alinkColor', 'all', 'bgColor', 'fgColor', 'linkColor', 'vlinkColor']);
198 }, true); 200 }, true);
199 201
200 // Disable onunload, onbeforeunload. 202 // Disable onunload, onbeforeunload.
203 disableSetters(window, 'window', ['onbeforeunload', 'onunload']);
201 disableSetters(Window.prototype, 'window', ['onbeforeunload', 'onunload']); 204 disableSetters(Window.prototype, 'window', ['onbeforeunload', 'onunload']);
202 var windowAddEventListener = Window.prototype.addEventListener; 205 var eventTargetAddEventListener = EventTarget.prototype.addEventListener;
203 Window.prototype.addEventListener = function(type) { 206 EventTarget.prototype.addEventListener = function(type) {
204 if (type === 'unload' || type === 'beforeunload') 207 if (type === 'unload' || type === 'beforeunload')
205 generateDisabledMethodStub(type)(); 208 generateDisabledMethodStub(type)();
206 else 209 else
207 return $Function.apply(windowAddEventListener, window, arguments); 210 return $Function.apply(eventTargetAddEventListener, this, arguments);
208 }; 211 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698