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

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: off by 2 error 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
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/most_visited_page.js » ('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) 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.recordAppLaunchedFromIndex_();
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.recordAppLaunchedFromIndex_();
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 * Records the index of an app when launched.
505 * @private
506 */
507 recordAppLaunchedFromIndex_: function() {
508 var page = this.tile.tilePage;
509 var wide = page.layoutValues.numRowTiles == page.gridValues.maxColCount;
510 chrome.send('recordAppLaunchedFromIndex', [this.tile.index, wide]);
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 appNotificationChanged: appNotificationChanged, 906 appNotificationChanged: appNotificationChanged,
895 AppsPage: AppsPage, 907 AppsPage: AppsPage,
896 launchAppAfterEnable: launchAppAfterEnable, 908 launchAppAfterEnable: launchAppAfterEnable,
897 }; 909 };
898 }); 910 });
899 911
900 // TODO(estade): update the content handlers to use ntp namespace instead of 912 // TODO(estade): update the content handlers to use ntp namespace instead of
901 // making these global. 913 // making these global.
902 var appNotificationChanged = ntp4.appNotificationChanged; 914 var appNotificationChanged = ntp4.appNotificationChanged;
903 var launchAppAfterEnable = ntp4.launchAppAfterEnable; 915 var launchAppAfterEnable = ntp4.launchAppAfterEnable;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/most_visited_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698