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

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

Issue 11196055: Disable pushState and the rest of the history API in packaged apps via runtime-enabled features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * Returns a function that throws a 'not available' exception when called. 6 * Returns a function that throws a 'not available' exception when called.
7 * 7 *
8 * @param {string} messagePrefix text to prepend to the exception message. 8 * @param {string} messagePrefix text to prepend to the exception message.
9 */ 9 */
10 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) { 10 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 }); 72 });
73 } 73 }
74 74
75 // Disable document.open|close|write|etc. 75 // Disable document.open|close|write|etc.
76 disableMethods(HTMLDocument.prototype, 'document', 76 disableMethods(HTMLDocument.prototype, 'document',
77 ['open', 'clear', 'close', 'write', 'writeln']); 77 ['open', 'clear', 'close', 'write', 'writeln']);
78 78
79 // Disable history. 79 // Disable history.
80 window.history = {}; 80 window.history = {};
81 disableMethods(window.history, 'history', 81 disableMethods(window.history, 'history',
82 ['back', 'forward', 'go', 'pushState', 'replaceState']); 82 ['back', 'forward', 'go']);
83 disableGetters(window.history, 'history', ['length', 'state']); 83 disableGetters(window.history, 'history', ['length']);
84 84
85 // Disable find. 85 // Disable find.
86 disableMethods(Window.prototype, 'window', ['find']); 86 disableMethods(Window.prototype, 'window', ['find']);
87 87
88 // Disable modal dialogs. Shell windows disable these anyway, but it's nice to 88 // Disable modal dialogs. Shell windows disable these anyway, but it's nice to
89 // warn. 89 // warn.
90 disableMethods(Window.prototype, 'window', ['alert', 'confirm', 'prompt']); 90 disableMethods(Window.prototype, 'window', ['alert', 'confirm', 'prompt']);
91 91
92 // Disable window.*bar. 92 // Disable window.*bar.
93 disableGetters(window, 'window', 93 disableGetters(window, 'window',
(...skipping 27 matching lines...) Expand all
121 'onbeforeunload', generateDisabledMethodStub('onbeforeunload')); 121 'onbeforeunload', generateDisabledMethodStub('onbeforeunload'));
122 Window.prototype.__defineSetter__( 122 Window.prototype.__defineSetter__(
123 'onunload', generateDisabledMethodStub('onunload')); 123 'onunload', generateDisabledMethodStub('onunload'));
124 var windowAddEventListener = Window.prototype.addEventListener; 124 var windowAddEventListener = Window.prototype.addEventListener;
125 Window.prototype.addEventListener = function(type) { 125 Window.prototype.addEventListener = function(type) {
126 if (type === 'unload' || type === 'beforeunload') 126 if (type === 'unload' || type === 'beforeunload')
127 generateDisabledMethodStub(type)(); 127 generateDisabledMethodStub(type)();
128 else 128 else
129 return windowAddEventListener.apply(window, arguments); 129 return windowAddEventListener.apply(window, arguments);
130 }; 130 };
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | chrome/test/data/extensions/platform_apps/restrictions/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698