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

Side by Side Diff: chrome/browser/resources/options/pack_extension_overlay.js

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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
OLDNEW
(Empty)
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 const OptionsPage = options.OptionsPage;
7
8 /**
9 * PackExtensionOverlay class
10 * Encapsulated handling of the 'Pack Extension' overlay page.
11 * @constructor
12 */
13 function PackExtensionOverlay() {
14 OptionsPage.call(this, 'packExtensionOverlay',
15 templateData.packExtensionOverlayTabTitle,
16 'packExtensionOverlay');
17 }
18
19 cr.addSingletonGetter(PackExtensionOverlay);
20
21 PackExtensionOverlay.prototype = {
22 // Inherit PackExtensionOverlay from OptionsPage.
23 __proto__: OptionsPage.prototype,
24
25 /**
26 * Initialize the page.
27 */
28 initializePage: function() {
29 // Call base class implementation to starts preference initialization.
30 OptionsPage.prototype.initializePage.call(this);
31
32 $('packExtensionDismiss').onclick = function(event) {
33 OptionsPage.closeOverlay();
34 };
35 $('packExtensionCommit').onclick = function(event) {
36 var extensionPath = $('extensionRootDir').value;
37 var privateKeyPath = $('extensionPrivateKey').value;
38 chrome.send('pack', [extensionPath, privateKeyPath, 0]);
39 };
40 $('browseExtensionDir').addEventListener('click',
41 this.handleBrowseExtensionDir_.bind(this));
42 $('browsePrivateKey').addEventListener('click',
43 this.handleBrowsePrivateKey_.bind(this));
44 },
45
46 /**
47 * Utility function which asks the C++ to show a platform-specific file
48 * select dialog, and fire |callback| with the |filePath| that resulted.
49 * |selectType| can be either 'file' or 'folder'. |operation| can be 'load',
50 * 'packRoot', or 'pem' which are signals to the C++ to do some
51 * operation-specific configuration.
52 * @private
53 */
54 showFileDialog_: function(selectType, operation, callback) {
55 handleFilePathSelected = function(filePath) {
56 callback(filePath);
57 handleFilePathSelected = function() {};
58 };
59
60 chrome.send('extensionSettingsSelectFilePath', [selectType, operation]);
61 },
62
63 /**
64 * Handles the showing of the extension directory browser.
65 * @param {Event} e Change event.
66 * @private
67 */
68 handleBrowseExtensionDir_: function(e) {
69 this.showFileDialog_('folder', 'load', function(filePath) {
70 $('extensionRootDir').value = filePath;
71 });
72 },
73
74 /**
75 * Handles the showing of the extension private key file.
76 * @param {Event} e Change event.
77 * @private
78 */
79 handleBrowsePrivateKey_: function(e) {
80 this.showFileDialog_('file', 'pem', function(filePath) {
81 $('extensionPrivateKey').value = filePath;
82 });
83 },
84 };
85
86 /**
87 * Wrap up the pack process by showing the success |message| and closing
88 * the overlay.
89 * @param {String} message The message to show to the user.
90 */
91 PackExtensionOverlay.showSuccessMessage = function(message) {
92 OptionsPage.closeOverlay();
93 AlertOverlay.show(localStrings.getString('packExtensionOverlay'),
94 message, localStrings.getString('ok'), "",
95 function() {
96 OptionsPage.closeOverlay();
97 }, null);
98 }
99
100 /**
101 * Post an alert overlay showing |message|, and upon acknowledgement, close
102 * the alert overlay and return to showing the PackExtensionOverlay.
103 */
104 PackExtensionOverlay.showError = function(message) {
105 OptionsPage.closeOverlay();
106 AlertOverlay.show(localStrings.getString('packExtensionErrorTitle'),
107 message, localStrings.getString('ok'), "",
108 function() {
109 OptionsPage.closeOverlay();
110 OptionsPage.showPageByName('packExtensionOverlay', false);
111 }, null);
112 }
113
114 // Export
115 return {
116 PackExtensionOverlay: PackExtensionOverlay
117 };
118 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698