| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <script> |
| 3 // The Page Action ID. |
| 4 var pageActionId = "RssPageAction"; |
| 5 |
| 6 // The window this Page Action is associated with. |
| 7 var windowId = -1; |
| 8 |
| 9 // The TabId this Page Action is associated with. |
| 10 var tabId = -1; |
| 11 |
| 12 // The URL of the page that contains the feed. |
| 13 var pageUrl = ""; |
| 14 |
| 15 // The feed URL found on the page. |
| 16 var feedUrl = ""; |
| 17 |
| 18 chrome.self.onConnect.addListener(function(port) { |
| 19 windowId = port.tab.windowId; |
| 20 tabId = port.tab.id; |
| 21 pageUrl = port.tab.url; |
| 22 |
| 23 // This will get called from the content script using PostMessage. |
| 24 // |feedUrls| is a list of URL feeds found on the page. We only need 1 to |
| 25 // enable the PageAction icon in the Omnibox. |
| 26 port.onMessage.addListener(function(feedUrls) { |
| 27 feedUrl = feedUrls[0]; |
| 28 // Let Chrome know that the PageAction needs to be enabled for this tabId |
| 29 // and for the url of this page. |
| 30 if (feedUrl) { |
| 31 chrome.pageActions.enableForTab(pageActionId, |
| 32 {tabId: tabId, url: pageUrl}); |
| 33 } |
| 34 }); |
| 35 }); |
| 36 |
| 37 // Chrome will call into us when the user clicks on the icon in the OmniBox. |
| 38 chrome.pageActions.onExecute.addListener(function(reply) { |
| 39 chrome.windows.getCurrent(function(window) { |
| 40 chrome.tabs.get(reply.data.tabId, function(tab) { |
| 41 if (window.focused) { |
| 42 // We need to know if we are the active window, because the tab may |
| 43 // have moved to another window and we don't want to execute this |
| 44 // action multiple times. |
| 45 if (reply.pageActionId == pageActionId && |
| 46 reply.data.tabUrl == pageUrl) { |
| 47 // Create a new tab showing the subscription page with the right |
| 48 // feed URL. |
| 49 var url = "http://www.google.com/reader/view/feed/" + feedUrl; |
| 50 chrome.tabs.create({url: "subscribe.html?" + feedUrl, |
| 51 windowId: windowId}); |
| 52 } |
| 53 } |
| 54 }); |
| 55 }); |
| 56 }); |
| 57 </script> |
| 58 </html> |
| OLD | NEW |