1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Global accessor that the popup uses.
7 var selectedAddress = null;
10 function updateAddress(tabId) {
11 chrome.tabs.sendRequest(tabId, {}, function(address) {
12 addresses[tabId] = address;
14 chrome.pageAction.hide(tabId);
16 chrome.pageAction.show(tabId);
17 if (selectedId == tabId) {
18 updateSelected(tabId);
24 function updateSelected(tabId) {
25 selectedAddress = addresses[tabId];
27 chrome.pageAction.setTitle({tabId:tabId, title:selectedAddress});
30 chrome.tabs.onUpdated.addListener(function(tabId, change, tab) {
31 if (change.status == "complete") {
36 chrome.tabs.onSelectionChanged.addListener(function(tabId, info) {
38 updateSelected(tabId);
41 // Ensure the current selected tab is set up.
42 chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
43 updateAddress(tabs[0].id);