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

Side by Side Diff: chrome/browser/resources/md_extensions/service.js

Issue 2101933005: [MD Extensions] Implement keyboard shortcuts page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Michael's Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * @constructor 9 * @constructor
10 * @implements {extensions.ItemDelegate} 10 * @implements {extensions.ItemDelegate}
11 * @implements {extensions.SidebarDelegate} 11 * @implements {extensions.SidebarDelegate}
12 * @implements {extensions.PackDialogDelegate} 12 * @implements {extensions.PackDialogDelegate}
13 */ 13 */
14 function Service() {} 14 function Service() {}
15 15
16 Service.prototype = { 16 Service.prototype = {
17 /** @private {boolean} */ 17 /** @private {boolean} */
18 isDeleting_: false, 18 isDeleting_: false,
19 19
20 /** @param {extensions.Manager} manager */ 20 /** @param {extensions.Manager} manager */
21 managerReady: function(manager) { 21 managerReady: function(manager) {
22 /** @private {extensions.Manager} */ 22 /** @private {extensions.Manager} */
23 this.manager_ = manager; 23 this.manager_ = manager;
24 this.manager_.sidebar.setDelegate(this); 24 this.manager_.sidebar.setDelegate(this);
25 this.manager_.set('itemDelegate', this); 25 this.manager_.set('itemDelegate', this);
26 this.manager_.$['pack-dialog'].set('delegate', this); 26 this.manager_.$['pack-dialog'].set('delegate', this);
27 var keyboardShortcuts = this.manager_.$['keyboard-shortcuts'];
28 keyboardShortcuts.addEventListener(
29 'shortcut-updated',
30 this.onExtensionCommandUpdated_.bind(this));
31 keyboardShortcuts.addEventListener(
32 'shortcut-capture-started',
33 this.onShortcutCaptureChanged_.bind(this, true));
34 keyboardShortcuts.addEventListener(
35 'shortcut-capture-ended',
36 this.onShortcutCaptureChanged_.bind(this, false));
27 chrome.developerPrivate.onProfileStateChanged.addListener( 37 chrome.developerPrivate.onProfileStateChanged.addListener(
28 this.onProfileStateChanged_.bind(this)); 38 this.onProfileStateChanged_.bind(this));
29 chrome.developerPrivate.onItemStateChanged.addListener( 39 chrome.developerPrivate.onItemStateChanged.addListener(
30 this.onItemStateChanged_.bind(this)); 40 this.onItemStateChanged_.bind(this));
31 chrome.developerPrivate.getExtensionsInfo( 41 chrome.developerPrivate.getExtensionsInfo(
32 {includeDisabled: true, includeTerminated: true}, 42 {includeDisabled: true, includeTerminated: true},
33 function(extensions) { 43 function(extensions) {
34 /** @private {Array<chrome.developerPrivate.ExtensionInfo>} */ 44 /** @private {Array<chrome.developerPrivate.ExtensionInfo>} */
35 this.extensions_ = extensions; 45 this.extensions_ = extensions;
36 for (let extension of extensions) 46 for (let extension of extensions)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (chrome.runtime.lastError && 114 if (chrome.runtime.lastError &&
105 chrome.runtime.lastError != 'File selection was canceled.') { 115 chrome.runtime.lastError != 'File selection was canceled.') {
106 reject(chrome.runtime.lastError); 116 reject(chrome.runtime.lastError);
107 } else { 117 } else {
108 resolve(path || ''); 118 resolve(path || '');
109 } 119 }
110 }); 120 });
111 }); 121 });
112 }, 122 },
113 123
124 /**
125 * Updates an extension command.
126 * @param {!CustomEvent} e
127 * @private
128 */
129 onExtensionCommandUpdated_: function(e) {
130 chrome.developerPrivate.updateExtensionCommand({
131 extensionId: e.detail.item,
132 commandName: e.detail.commandName,
133 keybinding: e.detail.keybinding,
134 });
135 },
136
137 /**
138 * Called when shortcut capturing changes in order to suspend or re-enable
139 * global shortcut handling. This is important so that the shortcuts aren't
140 * processed normally as the user types them.
141 * TODO(devlin): From very brief experimentation, it looks like preventing
142 * the default handling on the event also does this. Investigate more in the
143 * future.
144 * @param {boolean} isCapturing
145 * @param {!CustomEvent} e
146 * @private
147 */
148 onShortcutCaptureChanged_: function(isCapturing, e) {
149 chrome.developerPrivate.setShortcutHandlingSuspended(isCapturing);
150 },
151
114 /** @override */ 152 /** @override */
115 deleteItem: function(id) { 153 deleteItem: function(id) {
116 if (this.isDeleting_) 154 if (this.isDeleting_)
117 return; 155 return;
118 this.isDeleting_ = true; 156 this.isDeleting_ = true;
119 chrome.management.uninstall(id, {showConfirmDialog: true}, function() { 157 chrome.management.uninstall(id, {showConfirmDialog: true}, function() {
120 // The "last error" was almost certainly the user canceling the dialog. 158 // The "last error" was almost certainly the user canceling the dialog.
121 // Do nothing. We only check it so we don't get noisy logs. 159 // Do nothing. We only check it so we don't get noisy logs.
122 /** @suppress {suspiciousCode} */ 160 /** @suppress {suspiciousCode} */
123 chrome.runtime.lastError; 161 chrome.runtime.lastError;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 /** @override */ 248 /** @override */
211 updateAllExtensions: function() { 249 updateAllExtensions: function() {
212 chrome.developerPrivate.autoUpdate(); 250 chrome.developerPrivate.autoUpdate();
213 }, 251 },
214 }; 252 };
215 253
216 cr.addSingletonGetter(Service); 254 cr.addSingletonGetter(Service);
217 255
218 return {Service: Service}; 256 return {Service: Service};
219 }); 257 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698