Home | History | Annotate | Download | only in cookies
      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.
      4 
      5 chrome.cookies.onChanged.addListener(function(info) {
      6   console.log("onChanged" + JSON.stringify(info));
      7 });
      8 
      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;
     19         }
     20       }
     21     }
     22     if (existing_tab) {
     23       chrome.tabs.update(existing_tab.id, {"selected":true});
     24     } else {
     25       chrome.tabs.create({"url":url, "selected":true});
     26     }
     27   });
     28 }
     29 
     30 chrome.browserAction.onClicked.addListener(function(tab) {
     31   var manager_url = chrome.extension.getURL("manager.html");
     32   focusOrCreateTab(manager_url);
     33 });
     34