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

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/mappy/background.html

Issue 8311007: Adding `content_security_policy` to the "Mappy" sample. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebasing. Created 9 years, 2 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
OLDNEW
1 <script> 1 <!doctype html>
2 // Global accessor that the popup uses. 2 <html>
3 var addresses = {}; 3 <head>
4 var selectedAddress = null; 4 <title>Background Page</title>
5 var selectedId = null; 5 <script src="background.js"></script>
6 6 </head>
7 function updateAddress(tabId) { 7 <body>
8 chrome.tabs.sendRequest(tabId, {}, function(address) { 8 </body>
9 addresses[tabId] = address; 9 </html>
10 if (!address) {
11 chrome.pageAction.hide(tabId);
12 } else {
13 chrome.pageAction.show(tabId);
14 if (selectedId == tabId) {
15 updateSelected(tabId);
16 }
17 }
18 });
19 }
20
21 function updateSelected(tabId) {
22 selectedAddress = addresses[tabId];
23 if (selectedAddress)
24 chrome.pageAction.setTitle({tabId:tabId, title:selectedAddress});
25 }
26
27 chrome.tabs.onUpdated.addListener(function(tabId, change, tab) {
28 if (change.status == "complete") {
29 updateAddress(tabId);
30 }
31 });
32
33 chrome.tabs.onSelectionChanged.addListener(function(tabId, info) {
34 selectedId = tabId;
35 updateSelected(tabId);
36 });
37
38 // Ensure the current selected tab is set up.
39 chrome.tabs.getSelected(null, function(tab) {
40 updateAddress(tab.id);
41 });
42 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698