From 300e84b6650e61c3ad44711794d26eda4ba049f1 Mon Sep 17 00:00:00 2001 From: "finnur@chromium.org" Date: Wed, 9 Dec 2009 23:48:06 +0000 Subject: Add support for multiple feeds on a page by listing all the feeds in a dropdown from the page action icon when you click on the icon. If the page has only one feed, the dropdown does not appear and the extension works as before. BUG=None TEST=Test this on a page with multiple feeds and make sure a dropdown appears when you click on the RSS icon and that clicking each feed name takes you to the extension 'subscribe?' page. Review URL: http://codereview.chromium.org/475007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34202 0039d316-1c4b-4281-b951-d872f2087c98 --- .../subscribe_page_action/background.html | 31 ++------ .../subscribe_page_action/feed_finder.js | 2 +- .../extensions/subscribe_page_action/manifest.json | 9 ++- .../extensions/subscribe_page_action/popup.html | 89 ++++++++++++++++++++++ 4 files changed, 100 insertions(+), 31 deletions(-) create mode 100644 chrome/test/data/extensions/subscribe_page_action/popup.html (limited to 'chrome/test') diff --git a/chrome/test/data/extensions/subscribe_page_action/background.html b/chrome/test/data/extensions/subscribe_page_action/background.html index a5d6772..6d0bfc1 100644 --- a/chrome/test/data/extensions/subscribe_page_action/background.html +++ b/chrome/test/data/extensions/subscribe_page_action/background.html @@ -9,39 +9,18 @@ var tab = port.sender.tab; // This will get called from the content script using PostMessage. - // |feedUrls| is a list of URL feeds found on the page. We only need 1 to - // enable the PageAction icon in the Omnibox. + // |feedUrls| is a list of URL feeds found on the page. port.onMessage.addListener(function(feedUrls) { - feedUrl = feedUrls[0]; - // Let Chrome know that the PageAction needs to be enabled for this tabId - // and for the url of this page. - if (feedUrl) { - feedData[tab.id] = { pageUrl: tab.url, - feedUrl: feedUrl }; - + feedData[tab.id] = feedUrls; + if (feedUrls.length > 0) { chrome.pageAction.setTitle({ tabId: tab.id, - title: "Click to subscribe..." }); + title: "Click to subscribe..." + }); chrome.pageAction.show(tab.id); } }); }); - // Chrome will call into us when the user clicks on the icon in the OmniBox. - chrome.pageAction.onClicked.addListener(function(tab) { - chrome.windows.get(tab.windowId, function(window) { - // We need to know if we are the active window, because the tab may - // have moved to another window and we don't want to execute this - // action multiple times. - if (window.focused) { - // Create a new tab showing the subscription page with the right - // feed URL. - var url = "subscribe.html?" + - encodeURIComponent(feedData[tab.id].feedUrl); - chrome.tabs.create({url: url, windowId: window.id}); - } - }); - }); - chrome.tabs.onRemoved.addListener(function(reply) { feedData[reply.tabId] = null; }); diff --git a/chrome/test/data/extensions/subscribe_page_action/feed_finder.js b/chrome/test/data/extensions/subscribe_page_action/feed_finder.js index 5261264..6d9c590 100644 --- a/chrome/test/data/extensions/subscribe_page_action/feed_finder.js +++ b/chrome/test/data/extensions/subscribe_page_action/feed_finder.js @@ -15,7 +15,7 @@ function findFeeds() { var feeds = []; var item; while (item = result.iterateNext()) - feeds.push(item.href); + feeds.push({"href": item.href, "title": item.title}); // Notify the extension of the feed URLs we found. chrome.extension.connect().postMessage(feeds); diff --git a/chrome/test/data/extensions/subscribe_page_action/manifest.json b/chrome/test/data/extensions/subscribe_page_action/manifest.json index 20886c1..3b79832 100644 --- a/chrome/test/data/extensions/subscribe_page_action/manifest.json +++ b/chrome/test/data/extensions/subscribe_page_action/manifest.json @@ -1,7 +1,7 @@ { - "name": "RSS Subscription Extension", - "description": "Adds one-click subscription to your toolbar", - "version": "1.6.6", + "name": "RSS Subscription Extension (by Google)", + "description": "Adds one-click subscription to your toolbar.", + "version": "1.7", "permissions": [ "tabs", "http://*/*" @@ -16,6 +16,7 @@ "icons": { "128": "feed-icon-128x128.png" }, "page_action": { "default_title": "Subscribe to this feed", - "default_icon": "feed-icon-16x16.png" + "default_icon": "feed-icon-16x16.png", + "popup": "popup.html" } } diff --git a/chrome/test/data/extensions/subscribe_page_action/popup.html b/chrome/test/data/extensions/subscribe_page_action/popup.html new file mode 100644 index 0000000..67b9339 --- /dev/null +++ b/chrome/test/data/extensions/subscribe_page_action/popup.html @@ -0,0 +1,89 @@ + + + + + + +
+ Loading... +
+ + -- cgit v1.1