OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var animationFrames = 36; | 5 var animationFrames = 36; |
6 var animationSpeed = 10; // ms | 6 var animationSpeed = 10; // ms |
7 var canvas = document.getElementById('canvas'); | 7 var canvas = document.getElementById('canvas'); |
8 var loggedInImage = document.getElementById('logged_in'); | 8 var loggedInImage = document.getElementById('logged_in'); |
9 var canvasContext = canvas.getContext('2d'); | 9 var canvasContext = canvas.getContext('2d'); |
10 var pollIntervalMin = 5; // 5 minutes | 10 var pollIntervalMin = 5; // 5 minutes |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 chrome.runtime.onInstalled.addListener(onInit); | 317 chrome.runtime.onInstalled.addListener(onInit); |
318 chrome.alarms.onAlarm.addListener(onAlarm); | 318 chrome.alarms.onAlarm.addListener(onAlarm); |
319 } | 319 } |
320 | 320 |
321 var filters = { | 321 var filters = { |
322 // TODO(aa): Cannot use urlPrefix because all the url fields lack the protocol | 322 // TODO(aa): Cannot use urlPrefix because all the url fields lack the protocol |
323 // part. See crbug.com/140238. | 323 // part. See crbug.com/140238. |
324 url: [{urlContains: getGmailUrl().replace(/^https?\:\/\//, '')}] | 324 url: [{urlContains: getGmailUrl().replace(/^https?\:\/\//, '')}] |
325 }; | 325 }; |
326 | 326 |
327 chrome.webNavigation.onDOMContentLoaded.addListener(function(changeInfo) { | 327 function onNavigate(details) { |
328 if (changeInfo.url && isGmailUrl(changeInfo.url)) { | 328 if (details.url && isGmailUrl(details.url)) { |
329 console.log('Recognized Gmail navigation to: ' + changeInfo.url + '.' + | 329 console.log('Recognized Gmail navigation to: ' + details.url + '.' + |
330 'Refreshing count...'); | 330 'Refreshing count...'); |
331 startRequest({scheduleRequest:false, showLoadingAnimation:false}); | 331 startRequest({scheduleRequest:false, showLoadingAnimation:false}); |
332 } | 332 } |
333 }, filters); | 333 } |
334 chrome.webNavigation.onDOMContentLoaded.addListener(onNavigate, filters); | |
335 chrome.webNavigation.onReferenceFragmentUpdated.addListener( | |
Aaron Boodman
2012/09/25 21:38:14
This doesn't exist on Chrome 21, so it's going to
Matt Perry
2012/09/25 21:57:40
It exists, even on stable: http://developer.chrome
Matt Perry
2012/09/25 22:09:08
I added a feature detect anyway, just to be parano
| |
336 onNavigate, filters); | |
334 | 337 |
335 chrome.browserAction.onClicked.addListener(goToInbox); | 338 chrome.browserAction.onClicked.addListener(goToInbox); |
336 | 339 |
337 // This hack is needed because Chrome 22 does not persist browserAction icon | 340 // This hack is needed because Chrome 22 does not persist browserAction icon |
338 // state, and also doesn't expose onStartup. So the icon always starts out in | 341 // state, and also doesn't expose onStartup. So the icon always starts out in |
339 // wrong state. We don't actually need onStartup, we just use it as a clue | 342 // wrong state. We don't actually need onStartup, we just use it as a clue |
340 // that we're in a version of Chrome that has this problem. | 343 // that we're in a version of Chrome that has this problem. |
341 if (chrome.runtime && !chrome.runtime.onStartup) { | 344 if (chrome.runtime && !chrome.runtime.onStartup) { |
342 chrome.windows.onCreated.addListener(function() { | 345 chrome.windows.onCreated.addListener(function() { |
343 console.log('Window created... updating icon.'); | 346 console.log('Window created... updating icon.'); |
344 updateIcon(); | 347 updateIcon(); |
345 }); | 348 }); |
346 } | 349 } |
OLD | NEW |