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

Unified Diff: chrome/common/extensions/docs/examples/extensions/mappy/background.js

Issue 8311007: Adding `content_security_policy` to the "Mappy" sample. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/extensions/mappy/background.js
diff --git a/chrome/common/extensions/docs/examples/extensions/mappy/background.html b/chrome/common/extensions/docs/examples/extensions/mappy/background.js
similarity index 85%
copy from chrome/common/extensions/docs/examples/extensions/mappy/background.html
copy to chrome/common/extensions/docs/examples/extensions/mappy/background.js
index ff6f7c9cfa16895446c8c1672d45c8003cfd92e5..7fbed30d87ec1f6ec27e2dcf8bb5d8251594dc4c 100644
--- a/chrome/common/extensions/docs/examples/extensions/mappy/background.html
+++ b/chrome/common/extensions/docs/examples/extensions/mappy/background.js
@@ -1,42 +1,44 @@
-<script>
-// Global accessor that the popup uses.
-var addresses = {};
-var selectedAddress = null;
-var selectedId = null;
-
-function updateAddress(tabId) {
- chrome.tabs.sendRequest(tabId, {}, function(address) {
- addresses[tabId] = address;
- if (!address) {
- chrome.pageAction.hide(tabId);
- } else {
- chrome.pageAction.show(tabId);
- if (selectedId == tabId) {
- updateSelected(tabId);
- }
- }
- });
-}
-
-function updateSelected(tabId) {
- selectedAddress = addresses[tabId];
- if (selectedAddress)
- chrome.pageAction.setTitle({tabId:tabId, title:selectedAddress});
-}
-
-chrome.tabs.onUpdated.addListener(function(tabId, change, tab) {
- if (change.status == "complete") {
- updateAddress(tabId);
- }
-});
-
-chrome.tabs.onSelectionChanged.addListener(function(tabId, info) {
- selectedId = tabId;
- updateSelected(tabId);
-});
-
-// Ensure the current selected tab is set up.
-chrome.tabs.getSelected(null, function(tab) {
- updateAddress(tab.id);
-});
-</script>
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Global accessor that the popup uses.
+var addresses = {};
+var selectedAddress = null;
+var selectedId = null;
+
+function updateAddress(tabId) {
+ chrome.tabs.sendRequest(tabId, {}, function(address) {
+ addresses[tabId] = address;
+ if (!address) {
+ chrome.pageAction.hide(tabId);
+ } else {
+ chrome.pageAction.show(tabId);
+ if (selectedId == tabId) {
+ updateSelected(tabId);
+ }
+ }
+ });
+}
+
+function updateSelected(tabId) {
+ selectedAddress = addresses[tabId];
+ if (selectedAddress)
+ chrome.pageAction.setTitle({tabId:tabId, title:selectedAddress});
+}
+
+chrome.tabs.onUpdated.addListener(function(tabId, change, tab) {
+ if (change.status == "complete") {
+ updateAddress(tabId);
+ }
+});
+
+chrome.tabs.onSelectionChanged.addListener(function(tabId, info) {
+ selectedId = tabId;
+ updateSelected(tabId);
+});
+
+// Ensure the current selected tab is set up.
+chrome.tabs.getSelected(null, function(tab) {
+ updateAddress(tab.id);
+});

Powered by Google App Engine
This is Rietveld 408576698