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

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/gmail/background.js

Issue 10984030: Fix Gmail Checker to update on reference fragment navigations, so the unread (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix.onUpdated Created 8 years, 2 months 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/extensions/gmail/manifest.json » ('j') | 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) 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
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 if (chrome.webNavigation && chrome.webNavigation.onDOMContentLoaded &&
335 chrome.webNavigation.onReferenceFragmentUpdated) {
336 chrome.webNavigation.onDOMContentLoaded.addListener(onNavigate, filters);
337 chrome.webNavigation.onReferenceFragmentUpdated.addListener(
338 onNavigate, filters);
339 } else {
340 chrome.tabs.onUpdated.addListener(function(_, details) {
341 onNavigate(details);
342 });
343 }
334 344
335 chrome.browserAction.onClicked.addListener(goToInbox); 345 chrome.browserAction.onClicked.addListener(goToInbox);
336 346
337 // This hack is needed because Chrome 22 does not persist browserAction icon 347 // 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 348 // 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 349 // 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. 350 // that we're in a version of Chrome that has this problem.
341 if (chrome.runtime && !chrome.runtime.onStartup) { 351 if (chrome.runtime && !chrome.runtime.onStartup) {
342 chrome.windows.onCreated.addListener(function() { 352 chrome.windows.onCreated.addListener(function() {
343 console.log('Window created... updating icon.'); 353 console.log('Window created... updating icon.');
344 updateIcon(); 354 updateIcon();
345 }); 355 });
346 } 356 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/extensions/gmail/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698