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

Unified Diff: chrome/common/extensions/docs/examples/extensions/gmail/background.html

Issue 449049: Few minor fixups to Gmail checker extension: (Closed)
Patch Set: Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/extensions/gmail/background.html
diff --git a/chrome/common/extensions/docs/examples/extensions/gmail/background.html b/chrome/common/extensions/docs/examples/extensions/gmail/background.html
index eea77b67f8663960ed066523cb0238416aa1f1b5..d40e9268166f51da75bc5649a345b8521eac0062 100644
--- a/chrome/common/extensions/docs/examples/extensions/gmail/background.html
+++ b/chrome/common/extensions/docs/examples/extensions/gmail/background.html
@@ -5,10 +5,11 @@ var animationFrames = 36;
var animationSpeed = 10; // ms
var canvas;
var canvasContext;
-var gmail = "http://mail.google.com/";
-var gmailAtomRef = "http://mail.google.com/mail/feed/atom";
+var gmail = "https://mail.google.com/";
+var gmailAtomRef = "https://mail.google.com/mail/feed/atom";
+var gmailRe = /https?\:\/\/mail.google.com\/(?!a\/)/;
var loggedInImage;
-var pollInterval = 1000 * 10; // 10 seconds
+var pollInterval = 1000 * 60; // 1 minute
var requestTimeout = 1000 * 2; // 5 seconds
var rotation = 0;
var unreadCount = -1;
@@ -59,7 +60,7 @@ LoadingAnimation.prototype.stop = function() {
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
- if (changeInfo.url && changeInfo.url.indexOf(gmail) == 0) {
+ if (changeInfo.url && gmailRe.test(changeInfo.url)) {
console.log("saw gmail! updating...");
getInboxCount(function(count) {
updateUnreadCount(count);
@@ -217,7 +218,15 @@ function drawIconAtRotation() {
}
function goToInbox() {
- chrome.tabs.create({url: gmail});
+ chrome.tabs.getAllInWindow(undefined, function(tabs) {
+ for (var i = 0, tab; tab = tabs[i]; i++) {
+ if (tab.url && gmailRe.test(tab.url)) {
+ chrome.tabs.update(tab.id, {selected: true});
+ return;
+ }
+ }
+ chrome.tabs.create({url: gmail});
+ });
}
// Called when the user clicks on the browser action.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698