Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / extensions / docs / examples / api / cookies / background.js
blob0e42ddb5b2640194276a6adec430ad82048fcd0c
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
3 // found in the LICENSE file.
5 chrome.cookies.onChanged.addListener(function(info) {
6 console.log("onChanged" + JSON.stringify(info));
7 });
9 function focusOrCreateTab(url) {
10 chrome.windows.getAll({"populate":true}, function(windows) {
11 var existing_tab = null;
12 for (var i in windows) {
13 var tabs = windows[i].tabs;
14 for (var j in tabs) {
15 var tab = tabs[j];
16 if (tab.url == url) {
17 existing_tab = tab;
18 break;
22 if (existing_tab) {
23 chrome.tabs.update(existing_tab.id, {"selected":true});
24 } else {
25 chrome.tabs.create({"url":url, "selected":true});
27 });
30 chrome.browserAction.onClicked.addListener(function(tab) {
31 var manager_url = chrome.extension.getURL("manager.html");
32 focusOrCreateTab(manager_url);
33 });