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

Side by Side Diff: chrome/browser/resources/history/other_devices.js

Issue 1140813003: NTP Zombie Code Slayer III, The Saga Continues: Foreign Sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@suggestions-page
Patch Set: estade@ review Created 5 years, 7 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/resources/ntp4/compiled_resources.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 550
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 // TODO(dbeam): why is the ntp.* namespace being used from the history page?
Evan Stade 2015/05/18 18:28:59 doesn't the old comment answer that question for y
Dan Beam 2015/05/18 18:38:15 i disagree with the original comment. nothing abo
Evan Stade 2015/05/18 18:49:07 It doesn't have to make sense to answer the questi
Dan Beam 2015/05/18 20:00:34 Done.
566 // and login.
567 cr.define('ntp', function() { 561 cr.define('ntp', function() {
568 return { 562 return {
569 setForeignSessions: setForeignSessions,
570 updateLogin: updateLogin 563 updateLogin: updateLogin
571 }; 564 };
572 }); 565 });
573 566
574 devicesView = new DevicesView(); 567 devicesView = new DevicesView();
575 568
576 // Create the context menu that appears when the user right clicks 569 // 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 570 // on a device name or hit click on the button besides the device name
578 document.body.appendChild(DeviceContextMenuController.getInstance().menu); 571 document.body.appendChild(DeviceContextMenuController.getInstance().menu);
579 572
580 var doSearch = function(e) { 573 var doSearch = function(e) {
581 devicesView.setSearchText($('search-field').value); 574 devicesView.setSearchText($('search-field').value);
582 }; 575 };
583 $('search-field').addEventListener('search', doSearch); 576 $('search-field').addEventListener('search', doSearch);
584 $('search-button').addEventListener('click', doSearch); 577 $('search-button').addEventListener('click', doSearch);
585 } 578 }
586 579
587 // Add handlers to HTML elements. 580 // Add handlers to HTML elements.
588 document.addEventListener('DOMContentLoaded', load); 581 document.addEventListener('DOMContentLoaded', load);
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/resources/ntp4/compiled_resources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698