48fd8993e5ba3fadec8f9ad505c39b6c01920876
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / certificate_import_error_overlay.js
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
3 // found in the LICENSE file.
4
5 cr.define('options', function() {
6   var Page = cr.ui.pageManager.Page;
7   var PageManager = cr.ui.pageManager.PageManager;
8
9   /**
10    * CertificateImportErrorOverlay class
11    * Displays a list of certificates and errors.
12    * @class
13    */
14   function CertificateImportErrorOverlay() {
15     Page.call(this, 'certificateImportErrorOverlay', '',
16               'certificateImportErrorOverlay');
17   }
18
19   cr.addSingletonGetter(CertificateImportErrorOverlay);
20
21   CertificateImportErrorOverlay.prototype = {
22     // Inherit CertificateImportErrorOverlay from Page.
23     __proto__: Page.prototype,
24
25     /** @override */
26     initializePage: function() {
27       Page.prototype.initializePage.call(this);
28
29       $('certificateImportErrorOverlayOk').onclick = function(event) {
30         PageManager.closeOverlay();
31       };
32     },
33   };
34
35   /**
36    * Show an alert overlay with the given message, button titles, and
37    * callbacks.
38    * @param {string} title The alert title to display to the user.
39    * @param {string} message The alert message to display to the user.
40    * @param {Array} certErrors The list of cert errors.  Each error should have
41    *                           a .name and .error attribute.
42    */
43   CertificateImportErrorOverlay.show = function(title, message, certErrors) {
44     $('certificateImportErrorOverlayTitle').textContent = title;
45     $('certificateImportErrorOverlayMessage').textContent = message;
46
47     ul = $('certificateImportErrorOverlayCertErrors');
48     ul.innerHTML = '';
49     for (var i = 0; i < certErrors.length; ++i) {
50       li = document.createElement('li');
51       li.textContent = loadTimeData.getStringF('certificateImportErrorFormat',
52                                                certErrors[i].name,
53                                                certErrors[i].error);
54       ul.appendChild(li);
55     }
56
57     PageManager.showPageByName('certificateImportErrorOverlay');
58   };
59
60   // Export
61   return {
62     CertificateImportErrorOverlay: CertificateImportErrorOverlay
63   };
64
65 });