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

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

Issue 10545070: Make platform app restrictions more robust. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debugging code Created 8 years, 6 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/restrictions/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var errorMsg = 'Not available for platform apps.'; 5 var errorMsg = 'Not available for platform apps.';
6 var stub = function() { throw errorMsg; }; 6 var stub = function() { throw errorMsg; };
7 7
8 // Disable document.open|close|write. 8 // Disable document.open|close|write.
9 document.open = stub; 9 HTMLDocument.prototype.open = stub;
10 document.close = stub; 10 HTMLDocument.prototype.close = stub;
11 document.write = stub; 11 HTMLDocument.prototype.write = stub;
12 12
13 // Disable history. 13 // Disable history.
14 window.history = { 14 window.history = {
15 open: stub,
16 back: stub, 15 back: stub,
17 forward: stub, 16 forward: stub,
18 go: stub, 17 go: stub,
19 pushState: stub, 18 pushState: stub,
20 replaceState: stub, 19 replaceState: stub,
21 get length() { throw errorMsg; }, 20 get length() { throw errorMsg; },
22 get state() { throw errorMsg; } 21 get state() { throw errorMsg; }
23 }; 22 };
24 23
25 // Disable find. 24 // Disable find.
26 window.find = stub; 25 Window.prototype.find = stub;
27 26
28 // Disable modal dialogs. 27 // Disable modal dialogs. Shell windows disable these anyway, but it's nice to
29 window.alert = stub; 28 // warn.
30 window.confirm = stub; 29 Window.prototype.alert = stub;
31 window.prompt = stub; 30 Window.prototype.confirm = stub;
31 Window.prototype.prompt = stub;
32 32
33 // Disable window.*bar. 33 // Disable window.*bar.
34 var stubBar = { get visible() { throw errorMsg; } }; 34 var stubBar = { get visible() { throw errorMsg; } };
35 window.locationbar = stubBar; 35 window.locationbar = stubBar;
36 window.menubar = stubBar; 36 window.menubar = stubBar;
37 window.personalbar = stubBar; 37 window.personalbar = stubBar;
38 window.scrollbars = stubBar; 38 window.scrollbars = stubBar;
39 window.statusbar = stubBar; 39 window.statusbar = stubBar;
40 window.toolbar = stubBar; 40 window.toolbar = stubBar;
41 41
42 // Disable onunload, onbeforeunload. 42 // Disable onunload, onbeforeunload.
43 window.__defineSetter__('onbeforeunload', stub); 43 Window.prototype.__defineSetter__('onbeforeunload', stub);
44 window.__defineSetter__('onunload', stub); 44 Window.prototype.__defineSetter__('onunload', stub);
45 window.addEventListener = function(type) { 45 var windowAddEventListener = Window.prototype.addEventListener;
46 Window.prototype.addEventListener = function(type) {
46 if (type === 'unload' || type === 'beforeunload') 47 if (type === 'unload' || type === 'beforeunload')
47 stub(); 48 stub();
48 else 49 else
49 return Window.prototype.addEventListener.apply(window, arguments); 50 return windowAddEventListener.apply(window, arguments);
50 }; 51 };
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/restrictions/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698