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

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

Issue 22849012: Update WebUI calls to use extensions namespace, update IDs in c/b/r/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change all HTML IDs in c/b/r/extensions to be in-hyphenated-case Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('extensions', function() { 5 cr.define('extensions', function() {
6 /** 6 /**
7 * PackExtensionOverlay class 7 * PackExtensionOverlay class
8 * Encapsulated handling of the 'Pack Extension' overlay page. 8 * Encapsulated handling of the 'Pack Extension' overlay page.
9 * @constructor 9 * @constructor
10 */ 10 */
11 function PackExtensionOverlay() { 11 function PackExtensionOverlay() {
12 } 12 }
13 13
14 cr.addSingletonGetter(PackExtensionOverlay); 14 cr.addSingletonGetter(PackExtensionOverlay);
15 15
16 PackExtensionOverlay.prototype = { 16 PackExtensionOverlay.prototype = {
17 /** 17 /**
18 * Initialize the page. 18 * Initialize the page.
19 */ 19 */
20 initializePage: function() { 20 initializePage: function() {
21 var overlay = $('overlay'); 21 var overlay = $('overlay');
22 cr.ui.overlay.setupOverlay(overlay); 22 cr.ui.overlay.setupOverlay(overlay);
23 cr.ui.overlay.globalInitialization(); 23 cr.ui.overlay.globalInitialization();
24 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); 24 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
25 25
26 $('packExtensionDismiss').addEventListener('click', 26 $('pack-extension-dismiss').addEventListener('click',
27 this.handleDismiss_.bind(this)); 27 this.handleDismiss_.bind(this));
28 $('packExtensionCommit').addEventListener('click', 28 $('pack-extension-commit').addEventListener('click',
29 this.handleCommit_.bind(this)); 29 this.handleCommit_.bind(this));
30 $('browseExtensionDir').addEventListener('click', 30 $('browse-extension-dir').addEventListener('click',
31 this.handleBrowseExtensionDir_.bind(this)); 31 this.handleBrowseExtensionDir_.bind(this));
32 $('browsePrivateKey').addEventListener('click', 32 $('browse-private-key').addEventListener('click',
33 this.handleBrowsePrivateKey_.bind(this)); 33 this.handleBrowsePrivateKey_.bind(this));
34 }, 34 },
35 35
36 /** 36 /**
37 * Handles a click on the dismiss button. 37 * Handles a click on the dismiss button.
38 * @param {Event} e The click event. 38 * @param {Event} e The click event.
39 */ 39 */
40 handleDismiss_: function(e) { 40 handleDismiss_: function(e) {
41 ExtensionSettings.showOverlay(null); 41 extensions.ExtensionSettings.showOverlay(null);
42 }, 42 },
43 43
44 /** 44 /**
45 * Handles a click on the pack button. 45 * Handles a click on the pack button.
46 * @param {Event} e The click event. 46 * @param {Event} e The click event.
47 */ 47 */
48 handleCommit_: function(e) { 48 handleCommit_: function(e) {
49 var extensionPath = $('extensionRootDir').value; 49 var extensionPath = $('extension-root-dir').value;
50 var privateKeyPath = $('extensionPrivateKey').value; 50 var privateKeyPath = $('extension-private-key').value;
51 chrome.send('pack', [extensionPath, privateKeyPath, 0]); 51 chrome.send('pack', [extensionPath, privateKeyPath, 0]);
52 }, 52 },
53 53
54 /** 54 /**
55 * Utility function which asks the C++ to show a platform-specific file 55 * Utility function which asks the C++ to show a platform-specific file
56 * select dialog, and fire |callback| with the |filePath| that resulted. 56 * select dialog, and fire |callback| with the |filePath| that resulted.
57 * |selectType| can be either 'file' or 'folder'. |operation| can be 'load' 57 * |selectType| can be either 'file' or 'folder'. |operation| can be 'load'
58 * or 'pem' which are signals to the C++ to do some operation-specific 58 * or 'pem' which are signals to the C++ to do some operation-specific
59 * configuration. 59 * configuration.
60 * @private 60 * @private
61 */ 61 */
62 showFileDialog_: function(selectType, operation, callback) { 62 showFileDialog_: function(selectType, operation, callback) {
63 handleFilePathSelected = function(filePath) { 63 handleFilePathSelected = function(filePath) {
64 callback(filePath); 64 callback(filePath);
65 handleFilePathSelected = function() {}; 65 handleFilePathSelected = function() {};
66 }; 66 };
67 67
68 chrome.send('packExtensionSelectFilePath', [selectType, operation]); 68 chrome.send('packExtensionSelectFilePath', [selectType, operation]);
69 }, 69 },
70 70
71 /** 71 /**
72 * Handles the showing of the extension directory browser. 72 * Handles the showing of the extension directory browser.
73 * @param {Event} e Change event. 73 * @param {Event} e Change event.
74 * @private 74 * @private
75 */ 75 */
76 handleBrowseExtensionDir_: function(e) { 76 handleBrowseExtensionDir_: function(e) {
77 this.showFileDialog_('folder', 'load', function(filePath) { 77 this.showFileDialog_('folder', 'load', function(filePath) {
78 $('extensionRootDir').value = filePath; 78 $('extension-root-dir').value = filePath;
79 }); 79 });
80 }, 80 },
81 81
82 /** 82 /**
83 * Handles the showing of the extension private key file. 83 * Handles the showing of the extension private key file.
84 * @param {Event} e Change event. 84 * @param {Event} e Change event.
85 * @private 85 * @private
86 */ 86 */
87 handleBrowsePrivateKey_: function(e) { 87 handleBrowsePrivateKey_: function(e) {
88 this.showFileDialog_('file', 'pem', function(filePath) { 88 this.showFileDialog_('file', 'pem', function(filePath) {
89 $('extensionPrivateKey').value = filePath; 89 $('extension-private-key').value = filePath;
90 }); 90 });
91 }, 91 },
92 }; 92 };
93 93
94 /** 94 /**
95 * Wrap up the pack process by showing the success |message| and closing 95 * Wrap up the pack process by showing the success |message| and closing
96 * the overlay. 96 * the overlay.
97 * @param {string} message The message to show to the user. 97 * @param {string} message The message to show to the user.
98 */ 98 */
99 PackExtensionOverlay.showSuccessMessage = function(message) { 99 PackExtensionOverlay.showSuccessMessage = function(message) {
100 alertOverlay.setValues( 100 alertOverlay.setValues(
101 loadTimeData.getString('packExtensionOverlay'), 101 loadTimeData.getString('packExtensionOverlay'),
102 message, 102 message,
103 loadTimeData.getString('ok'), 103 loadTimeData.getString('ok'),
104 '', 104 '',
105 function() { 105 function() {
106 ExtensionSettings.showOverlay(null); 106 extensions.ExtensionSettings.showOverlay(null);
107 }, 107 },
108 null); 108 null);
109 ExtensionSettings.showOverlay($('alertOverlay')); 109 extensions.ExtensionSettings.showOverlay($('alertOverlay'));
110 }; 110 };
111 111
112 /** 112 /**
113 * Post an alert overlay showing |message|, and upon acknowledgement, close 113 * Post an alert overlay showing |message|, and upon acknowledgement, close
114 * the alert overlay and return to showing the PackExtensionOverlay. 114 * the alert overlay and return to showing the PackExtensionOverlay.
115 */ 115 */
116 PackExtensionOverlay.showError = function(message) { 116 PackExtensionOverlay.showError = function(message) {
117 alertOverlay.setValues( 117 alertOverlay.setValues(
118 loadTimeData.getString('packExtensionErrorTitle'), 118 loadTimeData.getString('packExtensionErrorTitle'),
119 message, 119 message,
120 loadTimeData.getString('ok'), 120 loadTimeData.getString('ok'),
121 '', 121 '',
122 function() { 122 function() {
123 ExtensionSettings.showOverlay($('packExtensionOverlay')); 123 extensions.ExtensionSettings.showOverlay($('pack-extension-overlay'));
124 }, 124 },
125 null); 125 null);
126 ExtensionSettings.showOverlay($('alertOverlay')); 126 extensions.ExtensionSettings.showOverlay($('alertOverlay'));
127 }; 127 };
128 128
129 // Export 129 // Export
130 return { 130 return {
131 PackExtensionOverlay: PackExtensionOverlay 131 PackExtensionOverlay: PackExtensionOverlay
132 }; 132 };
133 }); 133 });
134
135 // Update the C++ call so this isn't necessary.
136 var PackExtensionOverlay = extensions.PackExtensionOverlay;
OLDNEW
« no previous file with comments | « chrome/browser/resources/extensions/pack_extension_overlay.html ('k') | chrome/browser/ui/webui/extensions/command_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698