Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 var tasks = buildTaskManager(areTasksConflicting); | 117 var tasks = buildTaskManager(areTasksConflicting); |
| 118 | 118 |
| 119 // Add error processing to API calls. | 119 // Add error processing to API calls. |
| 120 tasks.instrumentChromeApiFunction('location.onLocationUpdate.addListener', 0); | 120 tasks.instrumentChromeApiFunction('location.onLocationUpdate.addListener', 0); |
| 121 tasks.instrumentChromeApiFunction('metricsPrivate.getFieldTrial', 1); | |
| 122 tasks.instrumentChromeApiFunction('metricsPrivate.getVariationParams', 1); | 121 tasks.instrumentChromeApiFunction('metricsPrivate.getVariationParams', 1); |
| 123 tasks.instrumentChromeApiFunction('notifications.create', 2); | 122 tasks.instrumentChromeApiFunction('notifications.create', 2); |
| 124 tasks.instrumentChromeApiFunction('notifications.update', 2); | 123 tasks.instrumentChromeApiFunction('notifications.update', 2); |
| 125 tasks.instrumentChromeApiFunction('notifications.getAll', 0); | 124 tasks.instrumentChromeApiFunction('notifications.getAll', 0); |
| 126 tasks.instrumentChromeApiFunction( | 125 tasks.instrumentChromeApiFunction( |
| 127 'notifications.onButtonClicked.addListener', 0); | 126 'notifications.onButtonClicked.addListener', 0); |
| 128 tasks.instrumentChromeApiFunction('notifications.onClicked.addListener', 0); | 127 tasks.instrumentChromeApiFunction('notifications.onClicked.addListener', 0); |
| 129 tasks.instrumentChromeApiFunction('notifications.onClosed.addListener', 0); | 128 tasks.instrumentChromeApiFunction('notifications.onClosed.addListener', 0); |
| 130 tasks.instrumentChromeApiFunction('omnibox.onInputEntered.addListener', 0); | 129 tasks.instrumentChromeApiFunction('omnibox.onInputEntered.addListener', 0); |
| 131 tasks.instrumentChromeApiFunction( | 130 tasks.instrumentChromeApiFunction( |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 | 860 |
| 862 /** | 861 /** |
| 863 * Coordinates the behavior of Google Now for Chrome depending on | 862 * Coordinates the behavior of Google Now for Chrome depending on |
| 864 * Chrome and extension state. | 863 * Chrome and extension state. |
| 865 */ | 864 */ |
| 866 function onStateChange() { | 865 function onStateChange() { |
| 867 tasks.add(STATE_CHANGED_TASK_NAME, function(callback) { | 866 tasks.add(STATE_CHANGED_TASK_NAME, function(callback) { |
| 868 tasks.debugSetStepName('onStateChange-isSignedIn'); | 867 tasks.debugSetStepName('onStateChange-isSignedIn'); |
| 869 authenticationManager.isSignedIn(function(token) { | 868 authenticationManager.isSignedIn(function(token) { |
| 870 var signedIn = !!token && !!NOTIFICATION_CARDS_URL; | 869 var signedIn = !!token && !!NOTIFICATION_CARDS_URL; |
| 871 instrumented.metricsPrivate.getFieldTrial( | 870 instrumented.metricsPrivate.getVariationParams( |
| 872 'GoogleNow', | 871 'GoogleNow', |
| 873 function(response) { | 872 function(response) { |
| 874 console.log('Experiment Status: ' + response); | 873 var enableBackground = |
| 875 var enableBackground = (response != 'EnableWithoutBackground'); | 874 (response && (response.enableBackground != 'false')); |
|
vadimt
2013/08/13 21:05:15
!response || response.enableBackground != 'false'.
robliao
2013/08/13 21:09:15
That's a bit more permissive than I was expecting.
vadimt
2013/08/13 21:17:10
Background is a "normal" behavior, and the absence
robliao
2013/08/13 21:30:32
Done.
| |
| 876 tasks.debugSetStepName( | 875 tasks.debugSetStepName( |
| 877 'onStateChange-get-googleGeolocationAccessEnabledPref'); | 876 'onStateChange-get-googleGeolocationAccessEnabledPref'); |
| 878 instrumented. | 877 instrumented. |
| 879 preferencesPrivate. | 878 preferencesPrivate. |
| 880 googleGeolocationAccessEnabled. | 879 googleGeolocationAccessEnabled. |
| 881 get({}, function(prefValue) { | 880 get({}, function(prefValue) { |
| 882 var geolocationEnabled = !!prefValue.value; | 881 var geolocationEnabled = !!prefValue.value; |
| 883 tasks.debugSetStepName( | 882 tasks.debugSetStepName( |
| 884 'onStateChange-get-userRespondedToToast'); | 883 'onStateChange-get-userRespondedToToast'); |
| 885 instrumented.storage.local.get( | 884 instrumented.storage.local.get( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 | 984 |
| 986 instrumented.location.onLocationUpdate.addListener(function(position) { | 985 instrumented.location.onLocationUpdate.addListener(function(position) { |
| 987 recordEvent(GoogleNowEvent.LOCATION_UPDATE); | 986 recordEvent(GoogleNowEvent.LOCATION_UPDATE); |
| 988 updateNotificationsCards(position); | 987 updateNotificationsCards(position); |
| 989 }); | 988 }); |
| 990 | 989 |
| 991 instrumented.omnibox.onInputEntered.addListener(function(text) { | 990 instrumented.omnibox.onInputEntered.addListener(function(text) { |
| 992 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; | 991 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; |
| 993 initialize(); | 992 initialize(); |
| 994 }); | 993 }); |
| OLD | NEW |