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 /////////////////////////////////////////////////////////////////////////////// |
11 // Globals: | 11 // Globals: |
12 /** @const */ var MAX_NUM_COLUMNS = 3; | 12 /** @const */ var MAX_NUM_COLUMNS = 3; |
13 /** @const */ var NB_ENTRIES_FIRST_ROW_COLUMN = 6; | 13 /** @const */ var NB_ENTRIES_FIRST_ROW_COLUMN = 6; |
14 /** @const */ var NB_ENTRIES_OTHER_ROWS_COLUMN = 0; | 14 /** @const */ var NB_ENTRIES_OTHER_ROWS_COLUMN = 0; |
15 | 15 |
16 // Histogram buckets for UMA tracking of menu usage. | 16 // Histogram buckets for UMA tracking of menu usage. |
17 // Using the same values as the Other Devices button in the NTP. | |
18 /** @const */ var HISTOGRAM_EVENT = { | 17 /** @const */ var HISTOGRAM_EVENT = { |
19 INITIALIZED: 0, | 18 INITIALIZED: 0, |
20 SHOW_MENU: 1, | 19 SHOW_MENU: 1, |
21 LINK_CLICKED: 2, | 20 LINK_CLICKED: 2, |
22 LINK_RIGHT_CLICKED: 3, | 21 LINK_RIGHT_CLICKED: 3, |
23 SESSION_NAME_RIGHT_CLICKED: 4, | 22 SESSION_NAME_RIGHT_CLICKED: 4, |
24 SHOW_SESSION_MENU: 5, | 23 SHOW_SESSION_MENU: 5, |
25 COLLAPSE_SESSION: 6, | 24 COLLAPSE_SESSION: 6, |
26 EXPAND_SESSION: 7, | 25 EXPAND_SESSION: 7, |
27 OPEN_ALL: 8, | 26 OPEN_ALL: 8, |
28 LIMIT: 9 // Should always be the last one. | 27 LIMIT: 9 // Should always be the last one. |
29 }; | 28 }; |
30 | 29 |
31 /** | 30 /** |
32 * Record an event in the UMA histogram. | 31 * Record an event in the UMA histogram. |
33 * @param {number} eventId The id of the event to be recorded. | 32 * @param {number} eventId The id of the event to be recorded. |
34 * @private | 33 * @private |
35 */ | 34 */ |
36 function recordUmaEvent_(eventId) { | 35 function recordUmaEvent_(eventId) { |
37 chrome.send('metricsHandler:recordInHistogram', | 36 chrome.send('metricsHandler:recordInHistogram', |
38 ['HistoryPage.OtherDevicesMenu', eventId, HISTOGRAM_EVENT.LIMIT]); | 37 ['HistoryPage.OtherDevicesMenu', eventId, HISTOGRAM_EVENT.LIMIT]); |
39 } | 38 } |
40 | 39 |
41 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
42 // DeviceContextMenuController: | 41 // DeviceContextMenuController: |
43 | 42 |
44 /** | 43 /** |
45 * Controller for the context menu for device names in the list of sessions. | 44 * Controller for the context menu for device names in the list of sessions. |
46 * This class is designed to be used as a singleton. Also copied from existing | |
47 * other devices button in NTP. | |
48 * TODO(mad): Should we extract/reuse/share with ntp4/other_sessions.js? | |
49 * | |
50 * @constructor | 45 * @constructor |
51 */ | 46 */ |
52 function DeviceContextMenuController() { | 47 function DeviceContextMenuController() { |
53 this.__proto__ = DeviceContextMenuController.prototype; | 48 this.__proto__ = DeviceContextMenuController.prototype; |
54 this.initialize(); | 49 this.initialize(); |
55 } | 50 } |
56 cr.addSingletonGetter(DeviceContextMenuController); | 51 cr.addSingletonGetter(DeviceContextMenuController); |
57 | 52 |
58 // DeviceContextMenuController, Public: --------------------------------------- | 53 // DeviceContextMenuController, Public: --------------------------------------- |
59 | 54 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 /////////////////////////////////////////////////////////////////////////////// | 551 /////////////////////////////////////////////////////////////////////////////// |
557 // Document Functions: | 552 // Document Functions: |
558 /** | 553 /** |
559 * Window onload handler, sets up the other devices view. | 554 * Window onload handler, sets up the other devices view. |
560 */ | 555 */ |
561 function load() { | 556 function load() { |
562 if (!loadTimeData.getBoolean('isInstantExtendedApiEnabled')) | 557 if (!loadTimeData.getBoolean('isInstantExtendedApiEnabled')) |
563 return; | 558 return; |
564 | 559 |
565 // We must use this namespace to reuse the handler code for foreign session | 560 // We must use this namespace to reuse the handler code for foreign session |
566 // and login. | 561 // and login. TODO(estade): change the call site in ntp_login_handler.cc so |
| 562 // this hack isn't necessary. |
567 cr.define('ntp', function() { | 563 cr.define('ntp', function() { |
568 return { | 564 return { |
569 setForeignSessions: setForeignSessions, | |
570 updateLogin: updateLogin | 565 updateLogin: updateLogin |
571 }; | 566 }; |
572 }); | 567 }); |
573 | 568 |
574 devicesView = new DevicesView(); | 569 devicesView = new DevicesView(); |
575 | 570 |
576 // Create the context menu that appears when the user right clicks | 571 // Create the context menu that appears when the user right clicks |
577 // on a device name or hit click on the button besides the device name | 572 // on a device name or hit click on the button besides the device name |
578 document.body.appendChild(DeviceContextMenuController.getInstance().menu); | 573 document.body.appendChild(DeviceContextMenuController.getInstance().menu); |
579 | 574 |
580 var doSearch = function(e) { | 575 var doSearch = function(e) { |
581 devicesView.setSearchText($('search-field').value); | 576 devicesView.setSearchText($('search-field').value); |
582 }; | 577 }; |
583 $('search-field').addEventListener('search', doSearch); | 578 $('search-field').addEventListener('search', doSearch); |
584 $('search-button').addEventListener('click', doSearch); | 579 $('search-button').addEventListener('click', doSearch); |
585 } | 580 } |
586 | 581 |
587 // Add handlers to HTML elements. | 582 // Add handlers to HTML elements. |
588 document.addEventListener('DOMContentLoaded', load); | 583 document.addEventListener('DOMContentLoaded', load); |
OLD | NEW |