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

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

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

Powered by Google App Engine
This is Rietveld 408576698