Chromium Code Reviews| Index: chrome/browser/resources/google_now/cards.js |
| diff --git a/chrome/browser/resources/google_now/cards.js b/chrome/browser/resources/google_now/cards.js |
| index 5e2481938e5a9cbbef943f5d6b9c6a1cd6be6f95..ea123192dd213c11e662fd55ebbba19d7fea3e4f 100644 |
| --- a/chrome/browser/resources/google_now/cards.js |
| +++ b/chrome/browser/resources/google_now/cards.js |
| @@ -40,46 +40,38 @@ function buildCardSet() { |
| JSON.stringify(cardCreateInfo)); |
| if (cardCreateInfo.previousVersion !== cardCreateInfo.version) { |
| - try { |
|
robliao
2013/08/22 00:01:56
We don't need to catch exceptions anymore?
vadimt
2013/08/22 01:24:28
It's better if our instrumentation catches this an
|
| - // Delete a notification with the specified id if it already exists, and |
| - // then create a notification. |
| - instrumented.notifications.create( |
| - cardId, |
| - cardCreateInfo.notification, |
| - function(newNotificationId) { |
| - if (!newNotificationId || chrome.runtime.lastError) { |
| - var errorMessage = chrome.runtime.lastError && |
| - chrome.runtime.lastError.message; |
| - console.error('notifications.create: ID=' + newNotificationId + |
| - ', ERROR=' + errorMessage); |
| - return; |
| - } |
| - |
| - scheduleHiding(cardId, cardCreateInfo.timeHide); |
| - }); |
| - } catch (error) { |
| - console.error('Error in notifications.create: ' + error); |
| - } |
| + // Delete a notification with the specified id if it already exists, and |
| + // then create a notification. |
| + instrumented.notifications.create( |
| + cardId, |
| + cardCreateInfo.notification, |
| + function(newNotificationId) { |
| + if (!newNotificationId || chrome.runtime.lastError) { |
| + var errorMessage = chrome.runtime.lastError && |
| + chrome.runtime.lastError.message; |
| + console.error('notifications.create: ID=' + newNotificationId + |
| + ', ERROR=' + errorMessage); |
| + return; |
| + } |
| + |
| + scheduleHiding(cardId, cardCreateInfo.timeHide); |
| + }); |
| } else { |
| - try { |
| - // Update existing notification. |
| - instrumented.notifications.update( |
| - cardId, |
| - cardCreateInfo.notification, |
| - function(wasUpdated) { |
| - if (!wasUpdated || chrome.runtime.lastError) { |
| - var errorMessage = chrome.runtime.lastError && |
| - chrome.runtime.lastError.message; |
| - console.error('notifications.update: UPDATED=' + wasUpdated + |
| - ', ERROR=' + errorMessage); |
| - return; |
| - } |
| - |
| - scheduleHiding(cardId, cardCreateInfo.timeHide); |
| - }); |
| - } catch (error) { |
| - console.error('Error in notifications.update: ' + error); |
| - } |
| + // Update existing notification. |
| + instrumented.notifications.update( |
| + cardId, |
| + cardCreateInfo.notification, |
| + function(wasUpdated) { |
| + if (!wasUpdated || chrome.runtime.lastError) { |
| + var errorMessage = chrome.runtime.lastError && |
| + chrome.runtime.lastError.message; |
| + console.error('notifications.update: UPDATED=' + wasUpdated + |
| + ', ERROR=' + errorMessage); |
| + return; |
| + } |
| + |
| + scheduleHiding(cardId, cardCreateInfo.timeHide); |
| + }); |
| } |
| } |
| @@ -154,8 +146,9 @@ function buildCardSet() { |
| // Alarm to show the card. |
| var cardId = alarm.name.substring(cardShowPrefix.length); |
| instrumented.storage.local.get('notificationsData', function(items) { |
| - items.notificationsData = items.notificationsData || {}; |
| console.log('cardManager.onAlarm.get ' + JSON.stringify(items)); |
| + if (!items || !items.notificationsData) |
| + return; |
| var notificationData = items.notificationsData[cardId]; |
| if (!notificationData) |
| return; |