| 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);
|
| +});
|
|
|