| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 /** | 5 /** |
| 6 * @fileoverview The section of the history page that shows tabs from sessions | 6 * @fileoverview The section of the history page that shows tabs from sessions |
| 7 on other devices. | 7 on other devices. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /////////////////////////////////////////////////////////////////////////////// | 10 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 DeviceContextMenuController.prototype.initialize = function() { | 60 DeviceContextMenuController.prototype.initialize = function() { |
| 61 var menu = new cr.ui.Menu; | 61 var menu = new cr.ui.Menu; |
| 62 cr.ui.decorate(menu, cr.ui.Menu); | 62 cr.ui.decorate(menu, cr.ui.Menu); |
| 63 this.menu = menu; | 63 this.menu = menu; |
| 64 this.collapseItem_ = this.appendMenuItem_('collapseSessionMenuItemText'); | 64 this.collapseItem_ = this.appendMenuItem_('collapseSessionMenuItemText'); |
| 65 this.collapseItem_.addEventListener('activate', | 65 this.collapseItem_.addEventListener('activate', |
| 66 this.onCollapseOrExpand_.bind(this)); | 66 this.onCollapseOrExpand_.bind(this)); |
| 67 this.expandItem_ = this.appendMenuItem_('expandSessionMenuItemText'); | 67 this.expandItem_ = this.appendMenuItem_('expandSessionMenuItemText'); |
| 68 this.expandItem_.addEventListener('activate', | 68 this.expandItem_.addEventListener('activate', |
| 69 this.onCollapseOrExpand_.bind(this)); | 69 this.onCollapseOrExpand_.bind(this)); |
| 70 this.openAllItem_ = this.appendMenuItem_('restoreSessionMenuItemText'); | 70 var openAllItem = this.appendMenuItem_('restoreSessionMenuItemText'); |
| 71 this.openAllItem_.addEventListener('activate', | 71 openAllItem.addEventListener('activate', this.onOpenAll_.bind(this)); |
| 72 this.onOpenAll_.bind(this)); | 72 var deleteItem = this.appendMenuItem_('deleteSessionMenuItemText'); |
| 73 deleteItem.addEventListener('activate', this.onDeleteSession_.bind(this)); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 /** | 76 /** |
| 76 * Set the session data for the session the context menu was invoked on. | 77 * Set the session data for the session the context menu was invoked on. |
| 77 * This should never be called when the menu is visible. | 78 * This should never be called when the menu is visible. |
| 78 * @param {Object} session The model object for the session. | 79 * @param {Object} session The model object for the session. |
| 79 */ | 80 */ |
| 80 DeviceContextMenuController.prototype.setSession = function(session) { | 81 DeviceContextMenuController.prototype.setSession = function(session) { |
| 81 this.session_ = session; | 82 this.session_ = session; |
| 82 this.updateMenuItems_(); | 83 this.updateMenuItems_(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 * Handler for the 'Open all' menu item. | 121 * Handler for the 'Open all' menu item. |
| 121 * @param {Event} e The activation event. | 122 * @param {Event} e The activation event. |
| 122 * @private | 123 * @private |
| 123 */ | 124 */ |
| 124 DeviceContextMenuController.prototype.onOpenAll_ = function(e) { | 125 DeviceContextMenuController.prototype.onOpenAll_ = function(e) { |
| 125 chrome.send('openForeignSession', [this.session_.tag]); | 126 chrome.send('openForeignSession', [this.session_.tag]); |
| 126 recordUmaEvent_(HISTOGRAM_EVENT.OPEN_ALL); | 127 recordUmaEvent_(HISTOGRAM_EVENT.OPEN_ALL); |
| 127 }; | 128 }; |
| 128 | 129 |
| 129 /** | 130 /** |
| 131 * Handler for the 'Hide for now' menu item. |
| 132 * @param {Event} e The activation event. |
| 133 * @private |
| 134 */ |
| 135 DeviceContextMenuController.prototype.onDeleteSession_ = function(e) { |
| 136 chrome.send('deleteForeignSession', [this.session_.tag]); |
| 137 recordUmaEvent_(HISTOGRAM_EVENT.HIDE_FOR_NOW); |
| 138 }; |
| 139 |
| 140 /** |
| 130 * Set the visibility of the Expand/Collapse menu items based on the state | 141 * Set the visibility of the Expand/Collapse menu items based on the state |
| 131 * of the session that this menu is currently associated with. | 142 * of the session that this menu is currently associated with. |
| 132 * @private | 143 * @private |
| 133 */ | 144 */ |
| 134 DeviceContextMenuController.prototype.updateMenuItems_ = function() { | 145 DeviceContextMenuController.prototype.updateMenuItems_ = function() { |
| 135 this.collapseItem_.hidden = this.session_.collapsed; | 146 this.collapseItem_.hidden = this.session_.collapsed; |
| 136 this.expandItem_.hidden = !this.session_.collapsed; | 147 this.expandItem_.hidden = !this.session_.collapsed; |
| 137 this.menu.selectedItem = this.menu.querySelector(':not([hidden])'); | 148 this.menu.selectedItem = this.menu.querySelector(':not([hidden])'); |
| 138 }; | 149 }; |
| 139 | 150 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 devicesView.setSearchText($('search-field').value); | 578 devicesView.setSearchText($('search-field').value); |
| 568 }; | 579 }; |
| 569 $('search-field').addEventListener('search', doSearch); | 580 $('search-field').addEventListener('search', doSearch); |
| 570 $('search-button').addEventListener('click', doSearch); | 581 $('search-button').addEventListener('click', doSearch); |
| 571 | 582 |
| 572 chrome.send('otherDevicesInitialized'); | 583 chrome.send('otherDevicesInitialized'); |
| 573 } | 584 } |
| 574 | 585 |
| 575 // Add handlers to HTML elements. | 586 // Add handlers to HTML elements. |
| 576 document.addEventListener('DOMContentLoaded', load); | 587 document.addEventListener('DOMContentLoaded', load); |
| OLD | NEW |