summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 20:31:07 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 20:31:07 +0000
commitae5e8a47d6ce8b13b47834b1032ff7b46a5e9d76 (patch)
tree386e35887231e7f7cba72d83d9e907da3d0cfb77 /chrome/common/extensions
parent6d5ae6c307f2a98a71be9a0b3759d8f5f638159d (diff)
downloadchromium_src-ae5e8a47d6ce8b13b47834b1032ff7b46a5e9d76.zip
chromium_src-ae5e8a47d6ce8b13b47834b1032ff7b46a5e9d76.tar.gz
chromium_src-ae5e8a47d6ce8b13b47834b1032ff7b46a5e9d76.tar.bz2
Few minor fixups to Gmail checker extension:
* Scale back poll rate. * Focus existing gmail tab instead of creating a new one. * Prefer https over http Review URL: http://codereview.chromium.org/449049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/docs/examples/extensions/gmail/background.html19
-rw-r--r--chrome/common/extensions/docs/examples/extensions/gmail/manifest.json2
2 files changed, 15 insertions, 6 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/gmail/background.html b/chrome/common/extensions/docs/examples/extensions/gmail/background.html
index eea77b6..d40e926 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.
diff --git a/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json b/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json
index 3dc942f..a72daf3 100644
--- a/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json
+++ b/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json
@@ -1,7 +1,7 @@
{
"name": "Google Mail Checker",
"description": "This extension adds a Google Mail button to the toolbar which displays the number of unread messages in your inbox. You can also click the button to open your inbox.",
- "version": "1.0",
+ "version": "1.1",
"background_page": "background.html",
"permissions": [
"tabs", "http://*.google.com/", "https://*.google.com/"