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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Called when a message is passed. We assume that the content script 5 // Update the declarative rules on install or upgrade.
6 // wants to show the page action. 6 chrome.runtime.onInstalled.addListener(function() {
7 function onRequest(request, sender, sendResponse) { 7 chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
8 // Show the page action for the tab that the sender (content script) 8 chrome.declarativeContent.onPageChanged.addRules([{
9 // was on. 9 conditions: [
10 chrome.pageAction.show(sender.tab.id); 10 // When a page contains a <video> tag...
11 11 new chrome.declarativeContent.PageStateMatcher({
12 // Return nothing to let the connection be cleaned up. 12 css: ["video"]
13 sendResponse({}); 13 })
14 }; 14 ],
15 15 // ... show the page action.
16 // Listen for the content script to send a message to the background page. 16 actions: [new chrome.declarativeContent.ShowPageAction() ]
17 chrome.extension.onRequest.addListener(onRequest); 17 }]);
18 });
19 });
OLDNEW
« 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