diff options
author | vadimt@chromium.org <vadimt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-03 23:13:34 +0000 |
---|---|---|
committer | vadimt@chromium.org <vadimt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-03 23:13:34 +0000 |
commit | 8314ddfd609038ed6237b9a72fd51f4f61dc5f50 (patch) | |
tree | a39f93a4c79b27180a9b3f702e091c1223546158 | |
parent | b3afec75dd6aa58b1734968f43341fcf7f0f2590 (diff) | |
download | chromium_src-8314ddfd609038ed6237b9a72fd51f4f61dc5f50.zip chromium_src-8314ddfd609038ed6237b9a72fd51f4f61dc5f50.tar.gz chromium_src-8314ddfd609038ed6237b9a72fd51f4f61dc5f50.tar.bz2 |
Sending dismissal age to the server. This will help the server to determine when to end the dismissal period for the card.
BUG=164227
TEST=Suppose, the card should normally stay dismissed for X hours. Get cards, unplug the network cable (or otherwise break the connection to the server), dismiss the card and wait for 5 hours. Then plug the cable back. Check that the card reappears in X hours after the dismissal, not restoring the network connection.
Also try to sit w/o connection for more than X hours. In this case, the card should reappear as soon as the connection is restored, at the first cards update after this happens.
Review URL: https://chromiumcodereview.appspot.com/14731004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198228 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/google_now/background.js | 21 | ||||
-rw-r--r-- | chrome/browser/resources/google_now/manifest.json | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js index 6b91c5d..f22a54a 100644 --- a/chrome/browser/resources/google_now/background.js +++ b/chrome/browser/resources/google_now/background.js @@ -385,15 +385,19 @@ function updateNotificationsCards(position) { /** * Sends a server request to dismiss a card. * @param {string} notificationId Unique identifier of the card. + * @param {number} dismissalTimeMs Time of the user's dismissal of the card in + * milliseconds since epoch. * @param {function(boolean)} callbackBoolean Completion callback with 'success' * parameter. */ -function requestCardDismissal(notificationId, callbackBoolean) { +function requestCardDismissal( + notificationId, dismissalTimeMs, callbackBoolean) { console.log('requestDismissingCard ' + notificationId + ' from ' + NOTIFICATION_CARDS_URL); recordEvent(DiagnosticEvent.DISMISS_REQUEST_TOTAL); // Send a dismiss request to the server. - var requestParameters = 'id=' + notificationId; + var requestParameters = 'id=' + notificationId + + '&dismissalAge=' + (Date.now() - dismissalTimeMs); var request = new XMLHttpRequest(); request.responseType = 'text'; request.onloadend = function(event) { @@ -444,12 +448,13 @@ function processPendingDismissals(callbackBoolean) { // Send dismissal for the first card, and if successful, repeat // recursively with the rest. - var notificationId = items.pendingDismissals[0]; - requestCardDismissal(notificationId, function(success) { + var dismissal = items.pendingDismissals[0]; + requestCardDismissal( + dismissal.notificationId, dismissal.time, function(success) { if (success) { dismissalsChanged = true; items.pendingDismissals.splice(0, 1); - items.recentDismissals[notificationId] = Date.now(); + items.recentDismissals[dismissal.notificationId] = Date.now(); doProcessDismissals(); } else { onFinish(false); @@ -532,7 +537,11 @@ function onNotificationClosed(notificationId, byUser) { tasks.debugSetStepName('onNotificationClosed-get-pendingDismissals'); storage.get('pendingDismissals', function(items) { - items.pendingDismissals.push(notificationId); + var dismissal = { + notificationId: notificationId, + time: Date.now() + }; + items.pendingDismissals.push(dismissal); storage.set({pendingDismissals: items.pendingDismissals}); processPendingDismissals(function(success) { callback(); }); }); diff --git a/chrome/browser/resources/google_now/manifest.json b/chrome/browser/resources/google_now/manifest.json index 0137aae..fb7aecc 100644 --- a/chrome/browser/resources/google_now/manifest.json +++ b/chrome/browser/resources/google_now/manifest.json @@ -1,7 +1,7 @@ { //chrome-extension://pmofbkohncoogjjhahejjfbppikbjigm "name": "Google Now", - "version": "1.1", + "version": "1.2", "description": "Integrates Google Now into Chrome.", "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDh/njCc/GTuP7uYix39uinhkX+7RyEoMaOQyoc065gsQ5b9cLpZToK78xgpsc9ThrpLVDOwqz6cGeLgIk+kPeRMQe07T+/mh3U5klegDx9pfr9T3aiRNQnJYJv8niVs9aJ/sBSqxtHt2LlhEt9ajFXue7Q3LkzyTlXpxoEFH1keQIDAQAB", "permissions": [ |