Chromium Code Reviews| 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 'use strict'; | 5 'use strict'; | 
| 6 | 6 | 
| 7 /** | 7 /** | 
| 8 * @fileoverview The event page for Google Now for Chrome implementation. | 8 * @fileoverview The event page for Google Now for Chrome implementation. | 
| 9 * The Google Now event page gets Google Now cards from the server and shows | 9 * The Google Now event page gets Google Now cards from the server and shows | 
| 10 * them as Chrome notifications. | 10 * them as Chrome notifications. | 
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 | 431 | 
| 432 /** | 432 /** | 
| 433 * Callback for chrome.notifications.onClosed event. | 433 * Callback for chrome.notifications.onClosed event. | 
| 434 * @param {string} notificationId Unique identifier of the notification. | 434 * @param {string} notificationId Unique identifier of the notification. | 
| 435 * @param {boolean} byUser Whether the notification was closed by the user. | 435 * @param {boolean} byUser Whether the notification was closed by the user. | 
| 436 */ | 436 */ | 
| 437 function onNotificationClosed(notificationId, byUser) { | 437 function onNotificationClosed(notificationId, byUser) { | 
| 438 if (!byUser) | 438 if (!byUser) | 
| 439 return; | 439 return; | 
| 440 | 440 | 
| 441 chrome.metricsPrivate.recordUserAction('GoogleNow.Dismissed'); | |
| 442 | |
| 
 
rgustafson
2013/03/29 20:20:00
unnecessary new line
 
vadimt
2013/03/29 20:22:44
Yeah, I thought about this too. Given that it goes
 
 | |
| 441 tasks.add(DISMISS_CARD_TASK_NAME, function(callback) { | 443 tasks.add(DISMISS_CARD_TASK_NAME, function(callback) { | 
| 442 // Schedule retrying dismissing until all dismissals go through. | 444 // Schedule retrying dismissing until all dismissals go through. | 
| 443 // TODO(vadimt): Implement exponential backoff and unify it with getting | 445 // TODO(vadimt): Implement exponential backoff and unify it with getting | 
| 444 // cards. | 446 // cards. | 
| 445 var alarmInfo = { | 447 var alarmInfo = { | 
| 446 delayInMinutes: RETRY_DISMISS_PERIOD_SECONDS / 60, | 448 delayInMinutes: RETRY_DISMISS_PERIOD_SECONDS / 60, | 
| 447 periodInMinutes: RETRY_DISMISS_PERIOD_SECONDS / 60 | 449 periodInMinutes: RETRY_DISMISS_PERIOD_SECONDS / 60 | 
| 448 }; | 450 }; | 
| 449 | 451 | 
| 450 chrome.alarms.create(RETRY_DISMISS_ALARM_NAME, alarmInfo); | 452 chrome.alarms.create(RETRY_DISMISS_ALARM_NAME, alarmInfo); | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 | 511 | 
| 510 chrome.alarms.onAlarm.addListener(function(alarm) { | 512 chrome.alarms.onAlarm.addListener(function(alarm) { | 
| 511 if (alarm.name == UPDATE_NOTIFICATIONS_ALARM_NAME) | 513 if (alarm.name == UPDATE_NOTIFICATIONS_ALARM_NAME) | 
| 512 updateNotificationsCards(); | 514 updateNotificationsCards(); | 
| 513 else if (alarm.name == RETRY_DISMISS_ALARM_NAME) | 515 else if (alarm.name == RETRY_DISMISS_ALARM_NAME) | 
| 514 retryPendingDismissals(); | 516 retryPendingDismissals(); | 
| 515 }); | 517 }); | 
| 516 | 518 | 
| 517 chrome.notifications.onClicked.addListener( | 519 chrome.notifications.onClicked.addListener( | 
| 518 function(notificationId) { | 520 function(notificationId) { | 
| 521 chrome.metricsPrivate.recordUserAction('GoogleNow.MessageClicked'); | |
| 519 onNotificationClicked(notificationId, function(actionUrls) { | 522 onNotificationClicked(notificationId, function(actionUrls) { | 
| 520 return actionUrls.messageUrl; | 523 return actionUrls.messageUrl; | 
| 521 }); | 524 }); | 
| 522 }); | 525 }); | 
| 523 | 526 | 
| 524 chrome.notifications.onButtonClicked.addListener( | 527 chrome.notifications.onButtonClicked.addListener( | 
| 525 function(notificationId, buttonIndex) { | 528 function(notificationId, buttonIndex) { | 
| 529 chrome.metricsPrivate.recordUserAction( | |
| 530 'GoogleNow.ButtonClicked' + buttonIndex); | |
| 526 onNotificationClicked(notificationId, function(actionUrls) { | 531 onNotificationClicked(notificationId, function(actionUrls) { | 
| 527 if (!Array.isArray(actionUrls.buttonUrls)) | 532 if (!Array.isArray(actionUrls.buttonUrls)) | 
| 528 return undefined; | 533 return undefined; | 
| 529 | 534 | 
| 530 return actionUrls.buttonUrls[buttonIndex]; | 535 return actionUrls.buttonUrls[buttonIndex]; | 
| 531 }); | 536 }); | 
| 532 }); | 537 }); | 
| 533 | 538 | 
| 534 chrome.notifications.onClosed.addListener(onNotificationClosed); | 539 chrome.notifications.onClosed.addListener(onNotificationClosed); | 
| OLD | NEW |