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

Side by Side Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 9254023: [NTP4] Track the position of each app that's launched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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('ntp4', function() { 5 cr.define('ntp4', function() {
6 'use strict'; 6 'use strict';
7 7
8 var localStrings = new LocalStrings; 8 var localStrings = new LocalStrings;
9 9
10 var APP_LAUNCH = { 10 var APP_LAUNCH = {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 */ 468 */
469 onClick_: function(e) { 469 onClick_: function(e) {
470 var is_promo = this.appsPromoExtras_ && 470 var is_promo = this.appsPromoExtras_ &&
471 window.getComputedStyle(this.appsPromoExtras_).display != 'none'; 471 window.getComputedStyle(this.appsPromoExtras_).display != 'none';
472 var url = !this.appData_.is_webstore ? '' : 472 var url = !this.appData_.is_webstore ? '' :
473 is_promo ? this.appsPromoLink_.href : 473 is_promo ? this.appsPromoLink_.href :
474 appendParam(this.appData_.url, 474 appendParam(this.appData_.url,
475 'utm_source', 475 'utm_source',
476 'chrome-ntp-icon'); 476 'chrome-ntp-icon');
477 477
478 this.recordAppClickIndex_(this.tile.index);
478 chrome.send('launchApp', 479 chrome.send('launchApp',
479 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, url, 480 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, url,
480 e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); 481 e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]);
481 482
482 // Don't allow the click to trigger a link or anything 483 // Don't allow the click to trigger a link or anything
483 e.preventDefault(); 484 e.preventDefault();
484 }, 485 },
485 486
486 /** 487 /**
487 * Invoked when the user presses a key while the app is focused. 488 * Invoked when the user presses a key while the app is focused.
488 * @param {Event} e The key event. 489 * @param {Event} e The key event.
489 * @private 490 * @private
490 */ 491 */
491 onKeydown_: function(e) { 492 onKeydown_: function(e) {
492 if (e.keyIdentifier == 'Enter') { 493 if (e.keyIdentifier == 'Enter') {
494 this.recordAppClickIndex_(this.tile.index);
493 chrome.send('launchApp', 495 chrome.send('launchApp',
494 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, '', 496 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, '',
495 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); 497 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]);
496 e.preventDefault(); 498 e.preventDefault();
497 e.stopPropagation(); 499 e.stopPropagation();
498 } 500 }
499 }, 501 },
500 502
501 /** 503 /**
504 * Record app position "clicked" (or when a user presses Enter on an app
kmadhusu 2012/01/19 18:29:03 nit: "Enter"
Dan Beam 2012/01/19 19:47:24 Why double quotes (from style guide: Use single qu
kmadhusu 2012/01/19 20:27:21 I thought it would be a good idea to emphasis on "
Dan Beam 2012/01/19 22:29:21 Done. (was just wondering why, :)
505 * using keyboard nav).
506 * @param {number} index The clicked index to record.
kmadhusu 2012/01/19 18:29:03 nit: @private
Dan Beam 2012/01/19 19:47:24 Done.
507 */
508 recordAppClickIndex_: function(index) {
509 chrome.send('metricsHandler:recordInHistogram',
510 ['NewTabPage.AppClickIndex', index + 1, 100]);
Dan Beam 2012/01/19 08:18:14 ^ I just put 100 as a semi-arbitrary number, thoug
kmadhusu 2012/01/19 18:29:03 Add this comment in the code for future references
kmadhusu 2012/01/19 18:29:03 Can you declare a constant for this magic number?
kmadhusu 2012/01/19 18:29:03 Why do you want to record the app clicked position
Dan Beam 2012/01/19 19:47:24 Done.
Dan Beam 2012/01/19 19:47:24 Done.
Dan Beam 2012/01/19 19:47:24 From the bug: Ideally segmented by position (simil
511 },
512
513 /**
502 * Adds a node to the list of targets that will launch the app. This list 514 * Adds a node to the list of targets that will launch the app. This list
503 * is also used in onMousedown to determine whether the app contents should 515 * is also used in onMousedown to determine whether the app contents should
504 * be shown as active (if we don't do this, then clicking anywhere in 516 * be shown as active (if we don't do this, then clicking anywhere in
505 * appContents, even a part that is outside the ideally clickable region, 517 * appContents, even a part that is outside the ideally clickable region,
506 * will cause the app icon to look active). 518 * will cause the app icon to look active).
507 * @param {HTMLElement} node The node that should be clickable. 519 * @param {HTMLElement} node The node that should be clickable.
508 */ 520 */
509 addLaunchClickTarget_: function(node) { 521 addLaunchClickTarget_: function(node) {
510 node.classList.add('launch-click-target'); 522 node.classList.add('launch-click-target');
511 node.addEventListener('click', this.onClick_.bind(this)); 523 node.addEventListener('click', this.onClick_.bind(this));
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 appNotificationChanged: appNotificationChanged, 890 appNotificationChanged: appNotificationChanged,
879 AppsPage: AppsPage, 891 AppsPage: AppsPage,
880 launchAppAfterEnable: launchAppAfterEnable, 892 launchAppAfterEnable: launchAppAfterEnable,
881 }; 893 };
882 }); 894 });
883 895
884 // TODO(estade): update the content handlers to use ntp namespace instead of 896 // TODO(estade): update the content handlers to use ntp namespace instead of
885 // making these global. 897 // making these global.
886 var appNotificationChanged = ntp4.appNotificationChanged; 898 var appNotificationChanged = ntp4.appNotificationChanged;
887 var launchAppAfterEnable = ntp4.launchAppAfterEnable; 899 var launchAppAfterEnable = ntp4.launchAppAfterEnable;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/most_visited_page.js » ('j') | chrome/browser/resources/ntp4/most_visited_page.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698