| 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 Utility objects and functions for Google Now extension. | 8 * @fileoverview Utility objects and functions for Google Now extension. |
| 9 * Most important entities here: | 9 * Most important entities here: |
| 10 * (1) 'wrapper' is a module used to add error handling and other services to | 10 * (1) 'wrapper' is a module used to add error handling and other services to |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 }; | 429 }; |
| 430 })(); | 430 })(); |
| 431 | 431 |
| 432 wrapper.instrumentChromeApiFunction('alarms.get', 1); | 432 wrapper.instrumentChromeApiFunction('alarms.get', 1); |
| 433 wrapper.instrumentChromeApiFunction('alarms.onAlarm.addListener', 0); | 433 wrapper.instrumentChromeApiFunction('alarms.onAlarm.addListener', 0); |
| 434 wrapper.instrumentChromeApiFunction('identity.getAuthToken', 1); | 434 wrapper.instrumentChromeApiFunction('identity.getAuthToken', 1); |
| 435 wrapper.instrumentChromeApiFunction('identity.onSignInChanged.addListener', 0); | 435 wrapper.instrumentChromeApiFunction('identity.onSignInChanged.addListener', 0); |
| 436 wrapper.instrumentChromeApiFunction('identity.removeCachedAuthToken', 1); | 436 wrapper.instrumentChromeApiFunction('identity.removeCachedAuthToken', 1); |
| 437 wrapper.instrumentChromeApiFunction('webstorePrivate.getBrowserLogin', 0); | 437 wrapper.instrumentChromeApiFunction('webstorePrivate.getBrowserLogin', 0); |
| 438 | 438 |
| 439 // Wrap Promise. |
| 440 Promise.prototype.then = function() { |
| 441 var originalThen = Promise.prototype.then; |
| 442 return function(callback) { |
| 443 originalThen.call(this, wrapper.wrapCallback(callback, false)); |
| 444 } |
| 445 }(); |
| 446 |
| 439 /** | 447 /** |
| 440 * Builds the object to manage tasks (mutually exclusive chains of events). | 448 * Builds the object to manage tasks (mutually exclusive chains of events). |
| 441 * @param {function(string, string): boolean} areConflicting Function that | 449 * @param {function(string, string): boolean} areConflicting Function that |
| 442 * checks if a new task can't be added to a task queue that contains an | 450 * checks if a new task can't be added to a task queue that contains an |
| 443 * existing task. | 451 * existing task. |
| 444 * @return {Object} Task manager interface. | 452 * @return {Object} Task manager interface. |
| 445 */ | 453 */ |
| 446 function buildTaskManager(areConflicting) { | 454 function buildTaskManager(areConflicting) { |
| 447 /** | 455 /** |
| 448 * Queue of scheduled tasks. The first element, if present, corresponds to the | 456 * Queue of scheduled tasks. The first element, if present, corresponds to the |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 // One hour is just an arbitrary amount of time chosen. | 799 // One hour is just an arbitrary amount of time chosen. |
| 792 chrome.alarms.create(alarmName, {periodInMinutes: 60}); | 800 chrome.alarms.create(alarmName, {periodInMinutes: 60}); |
| 793 | 801 |
| 794 return { | 802 return { |
| 795 addListener: addListener, | 803 addListener: addListener, |
| 796 getAuthToken: getAuthToken, | 804 getAuthToken: getAuthToken, |
| 797 isSignedIn: isSignedIn, | 805 isSignedIn: isSignedIn, |
| 798 removeToken: removeToken | 806 removeToken: removeToken |
| 799 }; | 807 }; |
| 800 } | 808 } |
| OLD | NEW |