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

Unified Diff: chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html

Issue 115536: Add the RSS page action extension.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/samples/subscribe_page_action/subscribe.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html
===================================================================
--- chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html (revision 0)
+++ chrome/test/data/extensions/samples/subscribe_page_action/toolstrip.html (revision 0)
@@ -0,0 +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>
« no previous file with comments | « chrome/test/data/extensions/samples/subscribe_page_action/subscribe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698