Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/resources/google_now/utility.js

Issue 107033002: Combining cards instead of merging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rgistafson's verbal comment Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/google_now/cards_unittest.gtestjs ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 /** 200 /**
201 * Factory for wrapper plugins. If specified, it's used to generate an 201 * Factory for wrapper plugins. If specified, it's used to generate an
202 * instance of WrapperPlugin each time we wrap a callback (which corresponds 202 * instance of WrapperPlugin each time we wrap a callback (which corresponds
203 * to addListener call for Chrome events, and to every API call that specifies 203 * to addListener call for Chrome events, and to every API call that specifies
204 * a callback). WrapperPlugin's lifetime ends when the callback for which it 204 * a callback). WrapperPlugin's lifetime ends when the callback for which it
205 * was generated, exits. It's possible to have several instances of 205 * was generated, exits. It's possible to have several instances of
206 * WrapperPlugin at the same time. 206 * WrapperPlugin at the same time.
207 * An instance of WrapperPlugin can have state that can be shared by its 207 * An instance of WrapperPlugin can have state that can be shared by its
208 * constructor, prologue() and epilogue(). Also WrapperPlugins can change 208 * constructor, prologue() and epilogue(). Also WrapperPlugins can change
209 * state of other objects, for example, to do refcounting. 209 * state of other objects, for example, to do refcounting.
210 * @type {function(): WrapperPlugin} 210 * @type {?function(): WrapperPlugin}
211 */ 211 */
212 var wrapperPluginFactory = null; 212 var wrapperPluginFactory = null;
213 213
214 /** 214 /**
215 * Registers a wrapper plugin factory. 215 * Registers a wrapper plugin factory.
216 * @param {function(): WrapperPlugin} factory Wrapper plugin factory. 216 * @param {function(): WrapperPlugin} factory Wrapper plugin factory.
217 */ 217 */
218 function registerWrapperPluginFactory(factory) { 218 function registerWrapperPluginFactory(factory) {
219 if (wrapperPluginFactory) { 219 if (wrapperPluginFactory) {
220 reportError(buildErrorWithMessageForServer( 220 reportError(buildErrorWithMessageForServer(
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 */ 705 */
706 function isSignedIn(callback) { 706 function isSignedIn(callback) {
707 instrumented.webstorePrivate.getBrowserLogin(function(accountInfo) { 707 instrumented.webstorePrivate.getBrowserLogin(function(accountInfo) {
708 callback(!!accountInfo.login); 708 callback(!!accountInfo.login);
709 }); 709 });
710 } 710 }
711 711
712 /** 712 /**
713 * Removes the specified cached token. 713 * Removes the specified cached token.
714 * @param {string} token Authentication Token to remove from the cache. 714 * @param {string} token Authentication Token to remove from the cache.
715 * @param {function} callback Called on completion. 715 * @param {function()} callback Called on completion.
716 */ 716 */
717 function removeToken(token, callback) { 717 function removeToken(token, callback) {
718 instrumented.identity.removeCachedAuthToken({token: token}, function() { 718 instrumented.identity.removeCachedAuthToken({token: token}, function() {
719 // Let Chrome now about a possible problem with the token. 719 // Let Chrome now about a possible problem with the token.
720 getAuthToken(function() {}); 720 getAuthToken(function() {});
721 callback(); 721 callback();
722 }); 722 });
723 } 723 }
724 724
725 var listeners = []; 725 var listeners = [];
726 726
727 /** 727 /**
728 * Registers a listener that gets called back when the signed in state 728 * Registers a listener that gets called back when the signed in state
729 * is found to be changed. 729 * is found to be changed.
730 * @param {function} callback Called when the answer to isSignedIn changes. 730 * @param {function()} callback Called when the answer to isSignedIn changes.
731 */ 731 */
732 function addListener(callback) { 732 function addListener(callback) {
733 listeners.push(callback); 733 listeners.push(callback);
734 } 734 }
735 735
736 /** 736 /**
737 * Checks if the last signed in state matches the current one. 737 * Checks if the last signed in state matches the current one.
738 * If it doesn't, it notifies the listeners of the change. 738 * If it doesn't, it notifies the listeners of the change.
739 */ 739 */
740 function checkAndNotifyListeners() { 740 function checkAndNotifyListeners() {
(...skipping 24 matching lines...) Expand all
765 // One hour is just an arbitrary amount of time chosen. 765 // One hour is just an arbitrary amount of time chosen.
766 chrome.alarms.create(alarmName, {periodInMinutes: 60}); 766 chrome.alarms.create(alarmName, {periodInMinutes: 60});
767 767
768 return { 768 return {
769 addListener: addListener, 769 addListener: addListener,
770 getAuthToken: getAuthToken, 770 getAuthToken: getAuthToken,
771 isSignedIn: isSignedIn, 771 isSignedIn: isSignedIn,
772 removeToken: removeToken 772 removeToken: removeToken
773 }; 773 };
774 } 774 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/google_now/cards_unittest.gtestjs ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698