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

Unified Diff: chrome/test/data/extensions/subscribe_page_action/background.js

Issue 12843037: Convert the RSS extension to event pages to avoid a dedicated background process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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
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
});

Powered by Google App Engine
This is Rietveld 408576698