Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / certificate_manager_dialog.js
blobed35f86f49f5f0c96706c395eb22699f02141194
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
3 // found in the LICENSE file.
5 var AlertOverlay = options.AlertOverlay;
6 var OptionsPage = options.OptionsPage;
7 var PageManager = cr.ui.pageManager.PageManager;
8 var CertificateManager = options.CertificateManager;
9 var CertificateRestoreOverlay = options.CertificateRestoreOverlay;
10 var CertificateBackupOverlay = options.CertificateBackupOverlay;
11 var CertificateEditCaTrustOverlay = options.CertificateEditCaTrustOverlay;
12 var CertificateImportErrorOverlay = options.CertificateImportErrorOverlay;
14 /**
15  * DOMContentLoaded handler, sets up the page.
16  */
17 function load() {
18   if (cr.isChromeOS)
19     document.documentElement.setAttribute('os', 'chromeos');
21   // Setup tab change handers.
22   var subpagesNavTabs = document.querySelectorAll('.subpages-nav-tabs');
23   for (var i = 0; i < subpagesNavTabs.length; i++) {
24     subpagesNavTabs[i].onclick = function(event) {
25       OptionsPage.showTab(event.srcElement);
26     };
27   }
29   // Shake the dialog if the user clicks outside the dialog bounds.
30   var containers = [$('overlay-container-2')];
31   for (var i = 0; i < containers.length; i++) {
32     var overlay = containers[i];
33     cr.ui.overlay.setupOverlay(overlay);
34     overlay.addEventListener('cancelOverlay',
35                              PageManager.cancelOverlay.bind(PageManager));
36   }
38   // Hide elements that should not be part of the dialog.
39   $('certificate-confirm').hidden = true;
40   $('cert-manager-header').hidden = true;
42   PageManager.isDialog = true;
43   CertificateManager.getInstance().setIsKiosk(true);
44   CertificateManager.getInstance().initializePage();
45   PageManager.registerOverlay(AlertOverlay.getInstance(),
46       CertificateManager.getInstance());
47   PageManager.registerOverlay(CertificateBackupOverlay.getInstance(),
48       CertificateManager.getInstance());
49   PageManager.registerOverlay(CertificateEditCaTrustOverlay.getInstance(),
50       CertificateManager.getInstance());
51   PageManager.registerOverlay(CertificateImportErrorOverlay.getInstance(),
52       CertificateManager.getInstance());
53   PageManager.registerOverlay(CertificateManager.getInstance());
54   PageManager.registerOverlay(CertificateRestoreOverlay.getInstance(),
55       CertificateManager.getInstance());
57   PageManager.showPageByName('certificates', false);
60 disableTextSelectAndDrag(function(e) {
61   var src = e.target;
62   return src instanceof HTMLTextAreaElement ||
63          src instanceof HTMLInputElement &&
64          /text|url/.test(src.type);
65 });
67 document.addEventListener('DOMContentLoaded', load);