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

Unified Diff: chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js

Issue 124603003: Change the pageaction_by_content example to use declarativeContent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « no previous file | chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/contentscript.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js
diff --git a/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js b/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js
index e6651c8f4c81b86e0576be4eae7f570fdf88139c..30005dae7aff94b2e71999867931718495703c22 100644
--- a/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js
+++ b/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/background.js
@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Called when a message is passed. We assume that the content script
-// wants to show the page action.
-function onRequest(request, sender, sendResponse) {
- // Show the page action for the tab that the sender (content script)
- // was on.
- chrome.pageAction.show(sender.tab.id);
-
- // Return nothing to let the connection be cleaned up.
- sendResponse({});
-};
-
-// Listen for the content script to send a message to the background page.
-chrome.extension.onRequest.addListener(onRequest);
+// Update the declarative rules on install or upgrade.
+chrome.runtime.onInstalled.addListener(function() {
+ chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
+ chrome.declarativeContent.onPageChanged.addRules([{
+ conditions: [
+ // When a page contains a <video> tag...
+ new chrome.declarativeContent.PageStateMatcher({
+ css: ["video"]
+ })
+ ],
+ // ... show the page action.
+ actions: [new chrome.declarativeContent.ShowPageAction() ]
+ }]);
+ });
+});
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_content/contentscript.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698