- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / ssl / ssl_errors_common.js
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 // Should match SSLBlockingPageCommands in ssl_blocking_page.cc.
6 var CMD_DONT_PROCEED = 0;
7 var CMD_PROCEED = 1;
8 var CMD_MORE = 2;
9 var CMD_RELOAD = 3;
10
11 var keyPressState = 0;
12
13 function $(o) {
14   return document.getElementById(o);
15 }
16
17 function sendCommand(cmd) {
18   window.domAutomationController.setAutomationId(1);
19   window.domAutomationController.send(cmd);
20 }
21
22 // This allows errors to be skippped by typing "proceed" into the page.
23 function keyPressHandler(e) {
24   var sequence = 'proceed';
25   if (sequence.charCodeAt(keyPressState) == e.keyCode) {
26     keyPressState++;
27     if (keyPressState == sequence.length) {
28       sendCommand(CMD_PROCEED);
29       keyPressState = 0;
30     }
31   } else {
32     keyPressState = 0;
33   }
34 }
35
36 function sharedSetup() {
37   document.addEventListener('contextmenu', function(e) {
38     e.preventDefault();
39   });
40   document.addEventListener('keypress', keyPressHandler);
41 }
42
43 document.addEventListener('DOMContentLoaded', sharedSetup);