Chromium Code Reviews| Index: chrome/browser/resources/print_preview/search/destination_list_item.js |
| diff --git a/chrome/browser/resources/print_preview/search/destination_list_item.js b/chrome/browser/resources/print_preview/search/destination_list_item.js |
| index a8c19aa9d075f9e10189880c7f589e363bb776bc..dc7c3bd0495d93ffd96326cba4ae7a33c4f8371c 100644 |
| --- a/chrome/browser/resources/print_preview/search/destination_list_item.js |
| +++ b/chrome/browser/resources/print_preview/search/destination_list_item.js |
| @@ -132,6 +132,32 @@ cr.define('print_preview', function() { |
| } |
| nameEl.title = textContent; |
| + if (this.destination_.isExtension) { |
| + var extensionNameEl = this.getChildElement('.extension-name'); |
| + var extensionName = this.destination_.extensionName; |
| + extensionNameEl.title = this.destination_.extensionName; |
| + if (this.query_) { |
| + extensionNameEl.textContent = ''; |
| + this.addTextWithHighlight_(extensionNameEl, extensionName); |
| + } else { |
| + extensionNameEl.textContent = this.destination_.extensionName; |
| + } |
| + |
| + var extensionIconEl = this.getChildElement('.extension-icon'); |
| + extensionIconEl.style.backgroundImage = |
| + this.destination_.extensionIconImageStyle; |
| + extensionIconEl.title = loadTimeData.getStringF( |
| + 'extensionDestinationIconTooltip', |
| + this.destination_.extensionName); |
| + var extensionId = this.destination_.extensionId; |
|
Aleksey Shlyapnikov
2015/03/06 00:27:39
What do you need this var for?
tbarzic
2015/03/06 03:16:11
removed
|
| + extensionIconEl.onclick = this.onExtensionIconClicked_.bind(this); |
| + extensionIconEl.onkeydown = this.onExtensionIconKeyDown_.bind(this); |
| + } |
| + |
| + var extensionIndicatorEl = |
| + this.getChildElement('.extension-controlled-indicator'); |
| + setIsVisible(extensionIndicatorEl, this.destination_.isExtension); |
| + |
| // Initialize the element which renders the destination's offline status. |
| this.getElement().classList.toggle('stale', this.destination_.isOffline); |
| var offlineStatusEl = this.getChildElement('.offline-status'); |
| @@ -232,6 +258,32 @@ cr.define('print_preview', function() { |
| DestinationListItem.EventType.REGISTER_PROMO_CLICKED); |
| promoClickedEvent.destination = this.destination_; |
| this.eventTarget_.dispatchEvent(promoClickedEvent); |
| + }, |
| + |
| + /** |
| + * Handles click and 'Enter' key down events for the extension icon element. |
| + * It opens extensions page with the extension associated with the |
| + * destination highlighted. |
| + * @param {MouseEvent|KeyboardEvent} e The event to handle. |
| + * @private |
| + */ |
| + onExtensionIconClicked_: function(e) { |
| + e.stopPropagation(); |
| + window.open('chrome://extensions?id=' + this.destination_.extensionId); |
| + }, |
| + |
| + /** |
| + * Handles key down event for the extensin icon element. Keys different than |
| + * 'Enter' are ignored. |
| + * @param {KeyboardEvent} e The event to handle. |
| + * @private |
| + */ |
| + onExtensionIconKeyDown_: function(e) { |
| + if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) |
| + return; |
| + if (e.keyCode != 13 /* Enter */) |
| + return; |
| + this.onExtensionIconClicked_(event); |
| } |
| }; |