title: How to get all tabs details from current browser in chrome extension?
body: <p>I have opened multiple browser windows in google chrome. I want to find all the tab details in the current window browser. ie., no tab details from another browser. </p>
  
  <p>So in my chrome extension, I am getting all the tab details in multiple browser windows.</p>
  
  <p>When I tried, I got the extension window details (ie., popup.html)</p>
  
  <p>Can anyone help me.?</p>
  
  <p>To find all tab details  : - </p>
  
  <pre><code>chrome.windows.getAll({ populate: true }, function (windows) {
          for (var i = 0; i &lt; windows.length; ++i) {
              var w = windows[i];
              for (var j = 0; j &lt; w.tabs.length; ++j) {
                  var t = w.tabs[j];
                  if (isValidTab(t)) {
                      tabs.push(t);
                  }
              }
  
          }
          sendResponse({ tabs: tabs });
      });
  </code></pre>
  
  <p>I tried :</p>
  
  <pre><code>chrome.tabs.query({ currentWindow: true }, function (tabs) {
          tabs.forEach(function (tab) {
              console.log('Tab ID: ', tab.id);
          });
      });
  </code></pre>
  
  <hr>
  
  <h2>content.js</h2>
  
  <pre><code>$(document).on("click", "#search_button", function () {
  chrome.extension.sendRequest({ type: 'popup' });  
  GetAllAvailableTabs(GenerateListOfTabNames);
  });
  
  function GetAllAvailableTabs(Callback) {
       chrome.extension.sendRequest({ type: 'get_all_tabs' }, function (response) {
          Callback(response.tabs);
      });
  }
  </code></pre>
  
  <h2>background.js</h2>
  
  <pre><code>chrome.extension.onRequest.addListener(
      function (request, sender, sendResponse) {
  
          switch (request.type) {
              case 'get_all_tabs':
  
                  GetAllAvailableTabs(sendResponse, sender.tab.windowId);
                  break;
          case 'popup':
  
              SelectedTabs = [];
              OpenPopupWindow();
              break;
              // code block
          }
  
      });
  
  var w = null;
  function OpenPopupWindow() {
      w = window.open(
          chrome.extension.getURL("html/popup.html"),
          'xxx',
          "width="700",height="700");
  }
  
  function GetAllAvailableTabs(sendResponse, windowid) {
      var tabs = [];
  
      chrome.windows.getAll({ populate: true }, function (windows) {
          for (var i = 0; i &lt; windows.length; ++i) {
              var w = windows[i];
              for (var j = 0; j &lt; w.tabs.length; ++j) {
                  var t = w.tabs[j];
                  if (isValidTab(t)) {
                      tabs.push(t);
                  }
              }
  
          }
          sendResponse({ tabs: tabs });
      });
  
  }
  </code></pre>