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

Side by Side Diff: chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js

Issue 62763003: Leave fullscreen mode in an app window when ESC key is pressed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with esc key overriding handling Created 7 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 chrome.app.runtime.onLaunched.addListener(function() {
6 chrome.app.window.create('main.html', {}, function(win) {
7 // The following key events handler will prevent the default behavior for
8 // the ESC key, thus will prevent the ESC key to leave fullscreen.
9 win.contentWindow.document.addEventListener('keydown', function(e) {
10 e.preventDefault();
11 });
12 win.contentWindow.document.addEventListener('keyup', function(e) {
13 e.preventDefault();
14 });
15
16 chrome.test.sendMessage('Launched', function(reply) {
17 var doc = win.contentWindow.document;
18
19 switch (reply) {
20 case 'window':
21 doc.addEventListener('keydown', function(e) {
22 if (e.keyCode != 66 /* b */)
23 return;
24 doc.removeEventListener('keydown', arguments.callee);
25 console.log('b received');
koz (OOO until 15th September) 2013/11/21 23:12:41 Remove logging.
26 chrome.test.sendMessage('B_KEY_RECEIVED');
27 });
28 win.fullscreen();
29 break;
30
31 case 'dom':
32 doc.addEventListener('keydown', function() {
33 doc.removeEventListener('keydown', arguments.callee);
34
35 doc.addEventListener('keydown', function(e) {
36 if (e.keyCode != 66 /* b */)
37 return;
38 doc.removeEventListener('keydown', arguments.callee);
39 console.log('b received');
koz (OOO until 15th September) 2013/11/21 23:12:41 Remove logging.
40 chrome.test.sendMessage('B_KEY_RECEIVED');
41 });
42
43 doc.body.webkitRequestFullscreen();
44 });
45 break;
46 }
47 });
48 });
49 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698