diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 18:45:48 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 18:45:48 +0000 |
commit | 7112138830105a8eae1e4a2247cee18e9ce66fbf (patch) | |
tree | 2b681cda1a5d3074a91062c6d164dacea0759531 | |
parent | 0e8e5ef1364fec7f7b9452ac5bb9b87f86e3e2cd (diff) | |
download | chromium_src-7112138830105a8eae1e4a2247cee18e9ce66fbf.zip chromium_src-7112138830105a8eae1e4a2247cee18e9ce66fbf.tar.gz chromium_src-7112138830105a8eae1e4a2247cee18e9ce66fbf.tar.bz2 |
Converting the RSS subscription page to use a background page, as opposed to a toolstrip (since it has no toolstrip UI).
BUG=None
TEST=The RSS page action should work as before and should not take up any real estate in the toolstrip.
Review URL: http://codereview.chromium.org/126143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18412 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/extensions/samples/subscribe_page_action/background.html (renamed from chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html) | 116 | ||||
-rw-r--r-- | chrome/test/data/extensions/samples/subscribe_page_action/manifest.json | 48 |
2 files changed, 81 insertions, 83 deletions
diff --git a/chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html b/chrome/test/data/extensions/samples/subscribe_page_action/background.html index 10185b1..e85e5a6 100644 --- a/chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html +++ b/chrome/test/data/extensions/samples/subscribe_page_action/background.html @@ -1,58 +1,58 @@ -<html>
-<script>
- // The Page Action ID.
- var pageActionId = "RssPageAction";
-
- // The window this Page Action is associated with.
- var windowId = -1;
-
- // The TabId this Page Action is associated with.
- var tabId = -1;
-
- // The URL of the page that contains the feed.
- var pageUrl = "";
-
- // The feed URL found on the page.
- var feedUrl = "";
-
- chrome.self.onConnect.addListener(function(port) {
- windowId = port.tab.windowId;
- tabId = port.tab.id;
- pageUrl = port.tab.url;
-
- // 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.
- 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) {
- chrome.pageActions.enableForTab(pageActionId,
- {tabId: tabId, url: pageUrl});
- }
- });
- });
-
- // Chrome will call into us when the user clicks on the icon in the OmniBox.
- chrome.pageActions.onExecute.addListener(function(reply) {
- chrome.windows.getCurrent(function(window) {
- chrome.tabs.get(reply.data.tabId, function(tab) {
- if (window.focused) {
- // 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 (reply.pageActionId == pageActionId &&
- reply.data.tabUrl == pageUrl) {
- // Create a new tab showing the subscription page with the right
- // feed URL.
- var url = "http://www.google.com/reader/view/feed/" + feedUrl;
- chrome.tabs.create({url: "subscribe.html?" + feedUrl,
- windowId: windowId});
- }
- }
- });
- });
- });
-</script>
-</html>
+<html> +<script> + // The Page Action ID. + var pageActionId = "RssPageAction"; + + // The window this Page Action is associated with. + var windowId = -1; + + // The TabId this Page Action is associated with. + var tabId = -1; + + // The URL of the page that contains the feed. + var pageUrl = ""; + + // The feed URL found on the page. + var feedUrl = ""; + + chrome.self.onConnect.addListener(function(port) { + windowId = port.tab.windowId; + tabId = port.tab.id; + pageUrl = port.tab.url; + + // 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. + 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) { + chrome.pageActions.enableForTab(pageActionId, + {tabId: tabId, url: pageUrl}); + } + }); + }); + + // Chrome will call into us when the user clicks on the icon in the OmniBox. + chrome.pageActions.onExecute.addListener(function(reply) { + chrome.windows.getCurrent(function(window) { + chrome.tabs.get(reply.data.tabId, function(tab) { + if (window.focused) { + // 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 (reply.pageActionId == pageActionId && + reply.data.tabUrl == pageUrl) { + // Create a new tab showing the subscription page with the right + // feed URL. + var url = "http://www.google.com/reader/view/feed/" + feedUrl; + chrome.tabs.create({url: "subscribe.html?" + feedUrl, + windowId: windowId}); + } + } + }); + }); + }); +</script> +</html> diff --git a/chrome/test/data/extensions/samples/subscribe_page_action/manifest.json b/chrome/test/data/extensions/samples/subscribe_page_action/manifest.json index 0121968..d32744c 100644 --- a/chrome/test/data/extensions/samples/subscribe_page_action/manifest.json +++ b/chrome/test/data/extensions/samples/subscribe_page_action/manifest.json @@ -1,26 +1,24 @@ -{
- "name": "RSS Subscription Extension",
- "description": "Adds one-click subscription to your toolbar",
- "version": "1.0",
- "permissions": [
- "http://*/*"
- ],
- "toolstrips": [
- "toolstrip.html"
- ],
- "content_scripts": [
- {
- "matches": ["http://*/*"],
- "js": ["feed_finder.js"]
- }
- ],
- "page_actions": [
- {
- "id": "RssPageAction",
- "name": "The PageAction for RSS subscriptions",
- "tooltip": "Click to subscribe to this feed",
- "icon": "feed-icon-16x16.png",
- "type": "tab"
- }
- ]
+{ + "name": "RSS Subscription Extension", + "description": "Adds one-click subscription to your toolbar", + "version": "1.0", + "permissions": [ + "http://*/*" + ], + "background_page": "background.html", + "content_scripts": [ + { + "matches": ["http://*/*"], + "js": ["feed_finder.js"] + } + ], + "page_actions": [ + { + "id": "RssPageAction", + "name": "The PageAction for RSS subscriptions", + "tooltip": "Click to subscribe to this feed", + "icon": "feed-icon-16x16.png", + "type": "tab" + } + ] }
\ No newline at end of file |