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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 var googleGeolocationAccessEnabledPref = | 117 var googleGeolocationAccessEnabledPref = |
118 chrome.preferencesPrivate.googleGeolocationAccessEnabled; | 118 chrome.preferencesPrivate.googleGeolocationAccessEnabled; |
119 | 119 |
120 var tasks = buildTaskManager(areTasksConflicting); | 120 var tasks = buildTaskManager(areTasksConflicting); |
121 | 121 |
122 // Add error processing to API calls. | 122 // Add error processing to API calls. |
123 tasks.instrumentApiFunction(chrome.location.onLocationUpdate, 'addListener', 0); | 123 tasks.instrumentApiFunction(chrome.location.onLocationUpdate, 'addListener', 0); |
124 tasks.instrumentApiFunction(chrome.metricsPrivate, 'getVariationParams', 1); | |
robliao
2013/08/09 22:01:54
Sync to the latest for updating to instrumentChrom
vadimt
2013/08/09 22:08:59
Will do before submittinng to CQ.
| |
124 tasks.instrumentApiFunction(chrome.notifications, 'create', 2); | 125 tasks.instrumentApiFunction(chrome.notifications, 'create', 2); |
125 tasks.instrumentApiFunction(chrome.notifications, 'update', 2); | 126 tasks.instrumentApiFunction(chrome.notifications, 'update', 2); |
126 tasks.instrumentApiFunction(chrome.notifications, 'getAll', 0); | 127 tasks.instrumentApiFunction(chrome.notifications, 'getAll', 0); |
127 tasks.instrumentApiFunction( | 128 tasks.instrumentApiFunction( |
128 chrome.notifications.onButtonClicked, 'addListener', 0); | 129 chrome.notifications.onButtonClicked, 'addListener', 0); |
129 tasks.instrumentApiFunction(chrome.notifications.onClicked, 'addListener', 0); | 130 tasks.instrumentApiFunction(chrome.notifications.onClicked, 'addListener', 0); |
130 tasks.instrumentApiFunction(chrome.notifications.onClosed, 'addListener', 0); | 131 tasks.instrumentApiFunction(chrome.notifications.onClosed, 'addListener', 0); |
131 tasks.instrumentApiFunction(chrome.omnibox.onInputEntered, 'addListener', 0); | 132 tasks.instrumentApiFunction(chrome.omnibox.onInputEntered, 'addListener', 0); |
132 tasks.instrumentApiFunction( | 133 tasks.instrumentApiFunction( |
133 googleGeolocationAccessEnabledPref, | 134 googleGeolocationAccessEnabledPref, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 } | 395 } |
395 }); | 396 }); |
396 } | 397 } |
397 | 398 |
398 /** | 399 /** |
399 * Starts getting location for a cards update. | 400 * Starts getting location for a cards update. |
400 */ | 401 */ |
401 function requestLocation() { | 402 function requestLocation() { |
402 console.log('requestLocation'); | 403 console.log('requestLocation'); |
403 recordEvent(GoogleNowEvent.LOCATION_REQUEST); | 404 recordEvent(GoogleNowEvent.LOCATION_REQUEST); |
404 // TODO(vadimt): Figure out location request options. Use experiments | 405 // TODO(vadimt): Figure out location request options. |
405 // framework to enable setting these parameters remotely. | 406 chrome.metricsPrivate.getVariationParams('GoogleNow', function(params) { |
406 chrome.location.watchLocation(LOCATION_WATCH_NAME, { | 407 var minDistanceInMeters = |
407 minDistanceInMeters: 100, | 408 parseInt(params && params.minDistanceInMeters) || |
arv (Not doing code reviews)
2013/08/09 23:13:16
don't use parseInt without radix
vadimt
2013/08/10 01:16:07
Done.
| |
408 minTimeInMilliseconds: 180000 // 3 minutes. | 409 100; |
410 var minTimeInMilliseconds = | |
411 parseInt(params && params.minTimeInMilliseconds) || | |
412 180000; // 3 minutes. | |
413 | |
414 chrome.location.watchLocation(LOCATION_WATCH_NAME, { | |
415 minDistanceInMeters: minDistanceInMeters, | |
416 minTimeInMilliseconds: minTimeInMilliseconds | |
417 }); | |
409 }); | 418 }); |
410 } | 419 } |
411 | 420 |
412 /** | 421 /** |
413 * Stops getting the location. | 422 * Stops getting the location. |
414 */ | 423 */ |
415 function stopRequestLocation() { | 424 function stopRequestLocation() { |
416 console.log('stopRequestLocation'); | 425 console.log('stopRequestLocation'); |
417 chrome.location.clearWatch(LOCATION_WATCH_NAME); | 426 chrome.location.clearWatch(LOCATION_WATCH_NAME); |
418 } | 427 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 | 917 |
909 chrome.location.onLocationUpdate.addListener(function(position) { | 918 chrome.location.onLocationUpdate.addListener(function(position) { |
910 recordEvent(GoogleNowEvent.LOCATION_UPDATE); | 919 recordEvent(GoogleNowEvent.LOCATION_UPDATE); |
911 updateNotificationsCards(position); | 920 updateNotificationsCards(position); |
912 }); | 921 }); |
913 | 922 |
914 chrome.omnibox.onInputEntered.addListener(function(text) { | 923 chrome.omnibox.onInputEntered.addListener(function(text) { |
915 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; | 924 localStorage['server_url'] = NOTIFICATION_CARDS_URL = text; |
916 initialize(); | 925 initialize(); |
917 }); | 926 }); |
OLD | NEW |