| 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. |
| 11 * The service performs periodic updating of Google Now cards. | 11 * The service performs periodic updating of Google Now cards. |
| 12 * Each updating of the cards includes 3 steps: | 12 * Each updating of the cards includes 3 steps: |
| 13 * 1. Obtaining the location of the machine; | 13 * 1. Obtaining the location of the machine; |
| 14 * 2. Making a server request based on that location; | 14 * 2. Making a server request based on that location; |
| 15 * 3. Showing the received cards as notifications. | 15 * 3. Showing the received cards as notifications. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 // TODO(vadimt): Use background permission to show notifications even when all | 18 // TODO(vadimt): Use background permission to show notifications even when all |
| 19 // browser windows are closed. | 19 // browser windows are closed. |
| 20 // TODO(vadimt): Remove the C++ implementation. | 20 // TODO(vadimt): Remove the C++ implementation. |
| 21 // TODO(vadimt): Decide what to do in incognito mode. | 21 // TODO(vadimt): Decide what to do in incognito mode. |
| 22 // TODO(vadimt): Gather UMAs. | 22 // TODO(vadimt): Gather UMAs. |
| 23 // TODO(vadimt): Honor the flag the enables Google Now integration. | 23 // TODO(vadimt): Honor the flag the enables Google Now integration. |
| 24 // TODO(vadimt): Figure out the final values of the constants. | 24 // TODO(vadimt): Figure out the final values of the constants. |
| 25 // TODO(vadimt): Report internal and server errors. Collect UMAs on errors where | 25 // TODO(vadimt): Report internal and server errors. Collect UMAs on errors where |
| 26 // appropriate. Also consider logging errors or throwing exceptions. | 26 // appropriate. Also consider logging errors or throwing exceptions. |
| 27 | 27 |
| 28 // TODO(vadimt): Consider processing errors for all storage.set calls. |
| 28 // TODO(vadimt): Figure out the server name. Use it in the manifest and for | 29 // TODO(vadimt): Figure out the server name. Use it in the manifest and for |
| 29 // TODO(vadimt): Consider processing errors for all storage.set calls. | |
| 30 // NOTIFICATION_CARDS_URL. Meanwhile, to use the feature, you need to manually | 30 // NOTIFICATION_CARDS_URL. Meanwhile, to use the feature, you need to manually |
| 31 // edit NOTIFICATION_CARDS_URL before building Chrome. | 31 // set the server name via local storage. |
| 32 /** | 32 /** |
| 33 * URL to retrieve notification cards. | 33 * URL to retrieve notification cards. |
| 34 */ | 34 */ |
| 35 var NOTIFICATION_CARDS_URL = ''; | 35 var NOTIFICATION_CARDS_URL = localStorage['server_url']; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Standard response code for successful HTTP requests. This is the only success | 38 * Standard response code for successful HTTP requests. This is the only success |
| 39 * code the server will send. | 39 * code the server will send. |
| 40 */ | 40 */ |
| 41 var HTTP_OK = 200; | 41 var HTTP_OK = 200; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Initial period for polling for Google Now Notifications cards to use when the | 44 * Initial period for polling for Google Now Notifications cards to use when the |
| 45 * period from the server is not available. | 45 * period from the server is not available. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 function(notificationId, buttonIndex) { | 300 function(notificationId, buttonIndex) { |
| 301 onNotificationClicked(notificationId, function(actionUrls) { | 301 onNotificationClicked(notificationId, function(actionUrls) { |
| 302 if (!Array.isArray(actionUrls.buttonUrls)) | 302 if (!Array.isArray(actionUrls.buttonUrls)) |
| 303 return undefined; | 303 return undefined; |
| 304 | 304 |
| 305 return actionUrls.buttonUrls[buttonIndex]; | 305 return actionUrls.buttonUrls[buttonIndex]; |
| 306 }); | 306 }); |
| 307 }); | 307 }); |
| 308 | 308 |
| 309 chrome.notifications.onClosed.addListener(onNotificationClosed); | 309 chrome.notifications.onClosed.addListener(onNotificationClosed); |
| OLD | NEW |