Bug 532173 - Don't sync tabs of some pages (weave firstrun, about:blank)

Ignore certain filtered urls when creating a list of tabs for remote machines.
This commit is contained in:
Edward Lee 2009-12-02 14:46:02 -08:00
Родитель 0a30c91bc0
Коммит eab5c8f980
1 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -49,6 +49,8 @@ Cu.import("resource://weave/trackers.js");
Cu.import("resource://weave/type_records/tabs.js"); Cu.import("resource://weave/type_records/tabs.js");
Cu.import("resource://weave/engines/clientData.js"); Cu.import("resource://weave/engines/clientData.js");
const filteredUrls = /^(about:blank|chrome:\/\/weave\/.*)$/i;
function TabEngine() { function TabEngine() {
this._init(); this._init();
} }
@ -128,7 +130,8 @@ TabStore.prototype = {
return id == Clients.clientID; return id == Clients.clientID;
}, },
getAllTabs: function getAllTabs() {
getAllTabs: function getAllTabs(filter) {
// Iterate through each tab of each window // Iterate through each tab of each window
let allTabs = []; let allTabs = [];
let wins = Svc.WinMediator.getEnumerator("navigator:browser"); let wins = Svc.WinMediator.getEnumerator("navigator:browser");
@ -141,9 +144,15 @@ TabStore.prototype = {
// Extract various pieces of tab data // Extract various pieces of tab data
Array.forEach(tabs, function(tab) { Array.forEach(tabs, function(tab) {
let browser = tab.linkedBrowser || tab.browser; let browser = tab.linkedBrowser || tab.browser;
let url = browser.currentURI.spec;
// Filter out some urls if necessary
if (filter && filteredUrls.test(url))
return;
allTabs.push({ allTabs.push({
title: browser.contentTitle || "", title: browser.contentTitle || "",
urlHistory: [browser.currentURI.spec], urlHistory: [url],
icon: browser.mIconURL || "", icon: browser.mIconURL || "",
lastUsed: tab.lastUsed || 0 lastUsed: tab.lastUsed || 0
}); });
@ -158,7 +167,7 @@ TabStore.prototype = {
record.clientName = Clients.clientName; record.clientName = Clients.clientName;
// Sort tabs in descending-used order to grab the most recently used // Sort tabs in descending-used order to grab the most recently used
record.tabs = this.getAllTabs().sort(function(a, b) { record.tabs = this.getAllTabs(true).sort(function(a, b) {
return b.lastUsed - a.lastUsed; return b.lastUsed - a.lastUsed;
}).slice(0, 25); }).slice(0, 25);
record.tabs.forEach(function(tab) { record.tabs.forEach(function(tab) {