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

Side by Side Diff: chrome/browser/resources/options/extension_settings.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 // Used for observing function of the backend datasource for this page by
6 // tests.
7 var webui_responded_ = false;
8
9 cr.define('options', function() {
10 var OptionsPage = options.OptionsPage;
11 var ExtensionsList = options.ExtensionsList;
12
13 /**
14 * ExtensionSettings class
15 * Encapsulated handling of the 'Manage Extensions' page.
16 * @class
17 */
18 function ExtensionSettings() {
19 OptionsPage.call(this, 'extensions',
20 templateData.extensionSettingsTabTitle,
21 'extension-settings');
22 }
23
24 cr.addSingletonGetter(ExtensionSettings);
25
26 ExtensionSettings.prototype = {
27 __proto__: OptionsPage.prototype,
28
29 /**
30 * Initialize the page.
31 */
32 initializePage: function() {
33 OptionsPage.prototype.initializePage.call(this);
34
35 // This will request the data to show on the page and will get a response
36 // back in returnExtensionsData.
37 chrome.send('extensionSettingsRequestExtensionsData');
38
39 // Set up the developer mode button.
40 var toggleDevMode = $('toggle-dev-on');
41 toggleDevMode.addEventListener('click',
42 this.handleToggleDevMode_.bind(this));
43
44 // Setup the gallery related links and text.
45 $('suggest-gallery').innerHTML =
46 localStrings.getString('extensionSettingsSuggestGallery');
47 $('get-more-extensions').innerHTML = localStrings.getString(
48 'extensionSettingsGetMoreExtensionsDeprecated');
49
50 // Set up the three dev mode buttons (load unpacked, pack and update).
51 $('load-unpacked').addEventListener('click',
52 this.handleLoadUnpackedExtension_.bind(this));
53 $('pack-extension').addEventListener('click',
54 this.handlePackExtension_.bind(this));
55 $('update-extensions-now').addEventListener('click',
56 this.handleUpdateExtensionNow_.bind(this));
57 },
58
59 /**
60 * Utility function which asks the C++ to show a platform-specific file
61 * select dialog, and fire |callback| with the |filePath| that resulted.
62 * |selectType| can be either 'file' or 'folder'. |operation| can be 'load',
63 * 'packRoot', or 'pem' which are signals to the C++ to do some
64 * operation-specific configuration.
65 * @private
66 */
67 showFileDialog_: function(selectType, operation, callback) {
68 handleFilePathSelected = function(filePath) {
69 callback(filePath);
70 handleFilePathSelected = function() {};
71 };
72
73 chrome.send('extensionSettingsSelectFilePath', [selectType, operation]);
74 },
75
76 /**
77 * Handles the Load Unpacked Extension button.
78 * @param {Event} e Change event.
79 * @private
80 */
81 handleLoadUnpackedExtension_: function(e) {
82 this.showFileDialog_('folder', 'load', function(filePath) {
83 chrome.send('extensionSettingsLoad', [String(filePath)]);
84 });
85
86 chrome.send('coreOptionsUserMetricsAction',
87 ['Options_LoadUnpackedExtension']);
88 },
89
90 /**
91 * Handles the Pack Extension button.
92 * @param {Event} e Change event.
93 * @private
94 */
95 handlePackExtension_: function(e) {
96 OptionsPage.navigateToPage('packExtensionOverlay');
97 chrome.send('coreOptionsUserMetricsAction', ['Options_PackExtension']);
98 },
99
100 /**
101 * Handles the Update Extension Now button.
102 * @param {Event} e Change event.
103 * @private
104 */
105 handleUpdateExtensionNow_: function(e) {
106 chrome.send('extensionSettingsAutoupdate', []);
107 },
108
109 /**
110 * Handles the Toggle Dev Mode button.
111 * @param {Event} e Change event.
112 * @private
113 */
114 handleToggleDevMode_: function(e) {
115 var dev = $('dev');
116 if (!dev.classList.contains('dev-open')) {
117 // Make the Dev section visible.
118 dev.classList.add('dev-open');
119 dev.classList.remove('dev-closed');
120
121 $('load-unpacked').classList.add('dev-button-visible');
122 $('load-unpacked').classList.remove('dev-button-hidden');
123 $('pack-extension').classList.add('dev-button-visible');
124 $('pack-extension').classList.remove('dev-button-hidden');
125 $('update-extensions-now').classList.add('dev-button-visible');
126 $('update-extensions-now').classList.remove('dev-button-hidden');
127 } else {
128 // Hide the Dev section.
129 dev.classList.add('dev-closed');
130 dev.classList.remove('dev-open');
131
132 $('load-unpacked').classList.add('dev-button-hidden');
133 $('load-unpacked').classList.remove('dev-button-visible');
134 $('pack-extension').classList.add('dev-button-hidden');
135 $('pack-extension').classList.remove('dev-button-visible');
136 $('update-extensions-now').classList.add('dev-button-hidden');
137 $('update-extensions-now').classList.remove('dev-button-visible');
138 }
139
140 chrome.send('extensionSettingsToggleDeveloperMode', []);
141 },
142 };
143
144 /**
145 * Called by the dom_ui_ to re-populate the page with data representing
146 * the current state of installed extensions.
147 */
148 ExtensionSettings.returnExtensionsData = function(extensionsData) {
149 webui_responded_ = true;
150
151 $('no-extensions').hidden = true;
152 $('suggest-gallery').hidden = true;
153 $('get-more-extensions-container').hidden = true;
154
155 if (extensionsData.extensions.length > 0) {
156 // Enforce order specified in the data or (if equal) then sort by
157 // extension name (case-insensitive).
158 extensionsData.extensions.sort(function(a, b) {
159 if (a.order == b.order) {
160 a = a.name.toLowerCase();
161 b = b.name.toLowerCase();
162 return a < b ? -1 : (a > b ? 1 : 0);
163 } else {
164 return a.order < b.order ? -1 : 1;
165 }
166 });
167
168 $('get-more-extensions-container').hidden = false;
169 } else {
170 $('no-extensions').hidden = false;
171 $('suggest-gallery').hidden = false;
172 }
173
174 ExtensionsList.prototype.data_ = extensionsData;
175
176 var extensionList = $('extension-settings-list');
177 ExtensionsList.decorate(extensionList);
178 }
179
180 // Indicate that warning |message| has occured for pack of |crx_path| and
181 // |pem_path| files. Ask if user wants override the warning. Send
182 // |overrideFlags| to repeated 'pack' call to accomplish the override.
183 ExtensionSettings.askToOverrideWarning
184 = function(message, crx_path, pem_path, overrideFlags) {
185 OptionsPage.closeOverlay();
186 AlertOverlay.show(
187 localStrings.getString('packExtensionWarningTitle'),
188 message,
189 localStrings.getString('packExtensionProceedAnyway'),
190 localStrings.getString('cancel'),
191 function() {
192 chrome.send('pack', [crx_path, pem_path, overrideFlags]);
193 },
194 function() {
195 OptionsPage.closeOverlay();
196 });
197 }
198
199 // Export
200 return {
201 ExtensionSettings: ExtensionSettings
202 };
203 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698