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

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

Issue 8526017: Append parameters to webstore URL to indicate launch source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fixes Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // This hack is here so that appContents.contextMenu will be the same as 232 // This hack is here so that appContents.contextMenu will be the same as
233 // this.contextMenu. 233 // this.contextMenu.
234 var self = this; 234 var self = this;
235 this.appContents_.__defineGetter__('contextMenu', function() { 235 this.appContents_.__defineGetter__('contextMenu', function() {
236 return self.contextMenu; 236 return self.contextMenu;
237 }); 237 });
238 this.appContents_.addEventListener('contextmenu', 238 this.appContents_.addEventListener('contextmenu',
239 cr.ui.contextMenuHandler); 239 cr.ui.contextMenuHandler);
240 240
241 this.isStore_ = this.appData_.is_webstore; 241 if (this.appData_.is_webstore)
242 if (this.isStore_)
243 this.createAppsPromoExtras_(); 242 this.createAppsPromoExtras_();
244 243
245 this.addEventListener('mousedown', this.onMousedown_, true); 244 this.addEventListener('mousedown', this.onMousedown_, true);
246 this.addEventListener('keydown', this.onKeydown_); 245 this.addEventListener('keydown', this.onKeydown_);
247 this.addEventListener('blur', this.onBlur_, true); 246 this.addEventListener('blur', this.onBlur_, true);
248 }, 247 },
249 248
250 /** 249 /**
251 * Sets the color of the favicon dominant color bar. 250 * Sets the color of the favicon dominant color bar.
252 * @param {string} color The css-parsable value for the color. 251 * @param {string} color The css-parsable value for the color.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 this.style.right = x + 'px'; 427 this.style.right = x + 'px';
429 this.style.top = y + 'px'; 428 this.style.top = y + 'px';
430 }, 429 },
431 430
432 /** 431 /**
433 * Invoked when an app is clicked. 432 * Invoked when an app is clicked.
434 * @param {Event} e The click event. 433 * @param {Event} e The click event.
435 * @private 434 * @private
436 */ 435 */
437 onClick_: function(e) { 436 onClick_: function(e) {
437 var is_promo = this.appsPromoExtras_ &&
438 window.getComputedStyle(this.appsPromoExtras_).display != 'none';
439 var url = !this.appData_.is_webstore ? '' :
440 is_promo ? appendParam(this.appsPromoLink_.href,
441 'utm_source',
442 'chrome-ntp-promo') :
443 appendParam(this.appData_.url,
444 'utm_source',
445 'chrome-ntp-icon');
446
438 chrome.send('launchApp', 447 chrome.send('launchApp',
439 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, 448 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, url,
440 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, e.button]); 449 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, e.button]);
441 450
442 // Don't allow the click to trigger a link or anything 451 // Don't allow the click to trigger a link or anything
443 e.preventDefault(); 452 e.preventDefault();
444 }, 453 },
445 454
446 /** 455 /**
447 * Invoked when the user presses a key while the app is focused. 456 * Invoked when the user presses a key while the app is focused.
448 * @param {Event} e The key event. 457 * @param {Event} e The key event.
449 * @private 458 * @private
450 */ 459 */
451 onKeydown_: function(e) { 460 onKeydown_: function(e) {
452 if (e.keyIdentifier == 'Enter') { 461 if (e.keyIdentifier == 'Enter') {
453 chrome.send('launchApp', 462 chrome.send('launchApp',
454 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, 463 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, '',
455 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, 0]); 464 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, 0]);
456 e.preventDefault(); 465 e.preventDefault();
457 e.stopPropagation(); 466 e.stopPropagation();
458 } 467 }
459 }, 468 },
460 469
461 /** 470 /**
462 * Adds a node to the list of targets that will launch the app. This list 471 * Adds a node to the list of targets that will launch the app. This list
463 * is also used in onMousedown to determine whether the app contents should 472 * is also used in onMousedown to determine whether the app contents should
464 * be shown as active (if we don't do this, then clicking anywhere in 473 * be shown as active (if we don't do this, then clicking anywhere in
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 appNotificationChanged: appNotificationChanged, 801 appNotificationChanged: appNotificationChanged,
793 AppsPage: AppsPage, 802 AppsPage: AppsPage,
794 launchAppAfterEnable: launchAppAfterEnable, 803 launchAppAfterEnable: launchAppAfterEnable,
795 }; 804 };
796 }); 805 });
797 806
798 // TODO(estade): update the content handlers to use ntp namespace instead of 807 // TODO(estade): update the content handlers to use ntp namespace instead of
799 // making these global. 808 // making these global.
800 var appNotificationChanged = ntp4.appNotificationChanged; 809 var appNotificationChanged = ntp4.appNotificationChanged;
801 var launchAppAfterEnable = ntp4.launchAppAfterEnable; 810 var launchAppAfterEnable = ntp4.launchAppAfterEnable;
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_omnibox_api.cc ('k') | chrome/browser/resources/shared/js/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698