| 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. |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 function setShouldPollCards(shouldPollCardsRequest, callback) { | 707 function setShouldPollCards(shouldPollCardsRequest, callback) { |
| 708 tasks.debugSetStepName( | 708 tasks.debugSetStepName( |
| 709 'setShouldRun-shouldRun-updateCardsAttemptsIsRunning'); | 709 'setShouldRun-shouldRun-updateCardsAttemptsIsRunning'); |
| 710 updateCardsAttempts.isRunning(function(currentValue) { | 710 updateCardsAttempts.isRunning(function(currentValue) { |
| 711 if (shouldPollCardsRequest != currentValue) { | 711 if (shouldPollCardsRequest != currentValue) { |
| 712 console.log('Action Taken setShouldPollCards=' + shouldPollCardsRequest); | 712 console.log('Action Taken setShouldPollCards=' + shouldPollCardsRequest); |
| 713 if (shouldPollCardsRequest) | 713 if (shouldPollCardsRequest) |
| 714 startPollingCards(); | 714 startPollingCards(); |
| 715 else | 715 else |
| 716 stopPollingCards(); | 716 stopPollingCards(); |
| 717 } else { |
| 718 console.log( |
| 719 'Action Ignored setShouldPollCards=' + shouldPollCardsRequest); |
| 717 } | 720 } |
| 718 callback(); | 721 callback(); |
| 719 }); | 722 }); |
| 720 } | 723 } |
| 721 | 724 |
| 722 /** | 725 /** |
| 723 * Shows or hides the toast. | 726 * Shows or hides the toast. |
| 724 * @param {boolean} visibleRequest true to show the toast and | 727 * @param {boolean} visibleRequest true to show the toast and |
| 725 * false to hide the toast. | 728 * false to hide the toast. |
| 726 * @param {function} callback Called on completion. | 729 * @param {function} callback Called on completion. |
| 727 */ | 730 */ |
| 728 function setToastVisible(visibleRequest, callback) { | 731 function setToastVisible(visibleRequest, callback) { |
| 729 tasks.debugSetStepName( | 732 tasks.debugSetStepName( |
| 730 'setToastVisible-shouldSetToastVisible-getAllNotifications'); | 733 'setToastVisible-shouldSetToastVisible-getAllNotifications'); |
| 731 chrome.notifications.getAll(function(notifications) { | 734 chrome.notifications.getAll(function(notifications) { |
| 732 // TODO(vadimt): Figure out what to do when notifications are disabled for | 735 // TODO(vadimt): Figure out what to do when notifications are disabled for |
| 733 // our extension. | 736 // our extension. |
| 734 notifications = notifications || {}; | 737 notifications = notifications || {}; |
| 735 | 738 |
| 736 if (visibleRequest != !!notifications[WELCOME_TOAST_NOTIFICATION_ID]) { | 739 if (visibleRequest != !!notifications[WELCOME_TOAST_NOTIFICATION_ID]) { |
| 737 console.log('Action Taken setToastVisible=' + visibleRequest); | 740 console.log('Action Taken setToastVisible=' + visibleRequest); |
| 738 if (visibleRequest) | 741 if (visibleRequest) |
| 739 showWelcomeToast(); | 742 showWelcomeToast(); |
| 740 else | 743 else |
| 741 hideWelcomeToast(); | 744 hideWelcomeToast(); |
| 745 } else { |
| 746 console.log('Action Ignored setToastVisible=' + visibleRequest); |
| 742 } | 747 } |
| 743 | 748 |
| 744 callback(); | 749 callback(); |
| 745 }); | 750 }); |
| 746 } | 751 } |
| 747 | 752 |
| 748 /** | 753 /** |
| 749 * Does the actual work of deciding what Google Now should do | 754 * Does the actual work of deciding what Google Now should do |
| 750 * based off of the current state of Chrome. | 755 * based off of the current state of Chrome. |
| 751 * @param {boolean} signedIn true if the user is signed in. | 756 * @param {boolean} signedIn true if the user is signed in. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 913 |
| 909 chrome.location.onLocationUpdate.addListener(function(position) { | 914 chrome.location.onLocationUpdate.addListener(function(position) { |
| 910 recordEvent(GoogleNowEvent.LOCATION_UPDATE); | 915 recordEvent(GoogleNowEvent.LOCATION_UPDATE); |
| 911 updateNotificationsCards(position); | 916 updateNotificationsCards(position); |
| 912 }); | 917 }); |
| 913 | 918 |
| 914 chrome.omnibox.onInputEntered.addListener(function(text) { | 919 chrome.omnibox.onInputEntered.addListener(function(text) { |
| 915 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; | 920 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; |
| 916 initialize(); | 921 initialize(); |
| 917 }); | 922 }); |
| OLD | NEW |