Index: chrome/test/data/extensions/subscribe_page_action/background.js |
=================================================================== |
--- chrome/test/data/extensions/subscribe_page_action/background.js (revision 192298) |
+++ chrome/test/data/extensions/subscribe_page_action/background.js (working copy) |
@@ -2,11 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// A dictionary keyed off of tabId that keeps track of data per tab (for |
-// example what feedUrl was detected in the tab). |
-var feedData = {}; |
- |
-chrome.extension.onRequest.addListener(function(request, sender) { |
+chrome.extension.onMessage.addListener(function(request, sender) { |
if (request.msg == "feedIcon") { |
// First validate that all the URLs have the right schema. |
var input = []; |
@@ -25,13 +21,16 @@ |
return; // We've rejected all the input, so abort. |
// We have received a list of feed urls found on the page. |
- // Enable the page action icon. |
- feedData[sender.tab.id] = input; |
- chrome.pageAction.setTitle( |
- { tabId: sender.tab.id, |
- title: chrome.i18n.getMessage("rss_subscription_action_title") |
- }); |
- chrome.pageAction.show(sender.tab.id); |
+ var feeds = {}; |
+ feeds[sender.tab.id] = input; |
not at google - send to devlin
2013/04/08 04:39:55
initialize directly? var feeds = {...} (in fact yo
Finnur
2013/04/08 12:59:24
This is actually the only way I could get it to wo
not at google - send to devlin
2013/04/08 22:01:27
Doh. I've been writing too much python.
|
+ chrome.storage.local.set(feeds, function() { |
+ // Enable the page action icon. |
+ chrome.pageAction.setTitle( |
+ { tabId: sender.tab.id, |
+ title: chrome.i18n.getMessage("rss_subscription_action_title") |
+ }); |
+ chrome.pageAction.show(sender.tab.id); |
+ }); |
} else if (request.msg == "feedDocument") { |
// We received word from the content script that this document |
// is an RSS feed (not just a document linking to the feed). |
@@ -52,5 +51,5 @@ |
}); |
chrome.tabs.onRemoved.addListener(function(tabId) { |
- delete feedData[tabId]; |
+ chrome.storage.local.remove(tabId.toString()); |
not at google - send to devlin
2013/04/08 04:39:55
I think (hope) the toString() is unnecessary.
Finnur
2013/04/08 12:59:24
Nope, toString is needed. Otherwise I get:
Error
not at google - send to devlin
2013/04/08 22:01:27
Dang. Could you file bugs? I'm fixing the int key
|
}); |