Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 hide: function() | 210 hide: function() |
211 { | 211 { |
212 chrome.pageAction.hide(this._tabId); | 212 chrome.pageAction.hide(this._tabId); |
213 }, | 213 }, |
214 show: function() | 214 show: function() |
215 { | 215 { |
216 chrome.pageAction.show(this._tabId); | 216 chrome.pageAction.show(this._tabId); |
217 } | 217 } |
218 }; | 218 }; |
219 | 219 |
220 Tab = function(tab) { | 220 Tab = function(tab) |
221 { | |
221 this._id = tab.id; | 222 this._id = tab.id; |
222 | 223 |
223 this.url = tab.url; | 224 this.url = tab.url; |
224 this.pageAction = new PageAction(tab.id); | 225 this.pageAction = new PageAction(tab.id); |
225 | 226 |
226 this.onBeforeNavigate = ext.tabs.onBeforeNavigate._bindToTab(this); | 227 this.onBeforeNavigate = ext.tabs.onBeforeNavigate._bindToTab(this); |
227 this.onCompleted = ext.tabs.onCompleted._bindToTab(this); | 228 this.onCompleted = ext.tabs.onCompleted._bindToTab(this); |
228 this.onActivated = ext.tabs.onActivated._bindToTab(this); | 229 this.onActivated = ext.tabs.onActivated._bindToTab(this); |
229 this.onRemoved = ext.tabs.onRemoved._bindToTab(this); | 230 this.onRemoved = ext.tabs.onRemoved._bindToTab(this); |
230 }; | 231 }; |
(...skipping 24 matching lines...) Expand all Loading... | |
255 }, | 256 }, |
256 set: function(tab, value) | 257 set: function(tab, value) |
257 { | 258 { |
258 if (!(tab._id in this._map)) | 259 if (!(tab._id in this._map)) |
259 tab.onRemoved.addListener(this.delete); | 260 tab.onRemoved.addListener(this.delete); |
260 | 261 |
261 this._map[tab._id] = {tab: tab, value: value}; | 262 this._map[tab._id] = {tab: tab, value: value}; |
262 }, | 263 }, |
263 has: function(tab) | 264 has: function(tab) |
264 { | 265 { |
265 return tab._id in this._map; | 266 return tab._id in this._map; |
Sebastian Noack
2013/11/10 14:40:08
I actually only do that when it is absolutely requ
| |
266 }, | 267 }, |
267 clear: function() | 268 clear: function() |
268 { | 269 { |
269 for (var id in this._map) | 270 for (var id in this._map) |
270 this.delete(this._map[id].tab); | 271 this.delete(this._map[id].tab); |
271 } | 272 } |
272 }; | 273 }; |
273 TabMap.prototype["delete"] = function(tab) { | 274 TabMap.prototype["delete"] = function(tab) |
275 { | |
274 delete this._map[tab._id]; | 276 delete this._map[tab._id]; |
275 tab.onRemoved.removeListener(this.delete); | 277 tab.onRemoved.removeListener(this.delete); |
276 }; | 278 }; |
277 | 279 |
278 | 280 |
279 /* Windows */ | 281 /* Windows */ |
280 | 282 |
281 Window = function(win) { | 283 Window = function(win) |
Felix Dahlke
2013/11/10 01:07:00
Opening brace should go on its own line.
| |
284 { | |
282 this._id = win.id; | 285 this._id = win.id; |
283 this.visible = win.status != "minimized"; | 286 this.visible = win.status != "minimized"; |
284 }; | 287 }; |
285 Window.prototype = { | 288 Window.prototype = { |
286 getAllTabs: function(callback) | 289 getAllTabs: function(callback) |
287 { | 290 { |
288 chrome.tabs.query({windowId: this._id}, function(tabs) | 291 chrome.tabs.query({windowId: this._id}, function(tabs) |
289 { | 292 { |
290 callback(tabs.map(function(tab) { return new Tab(tab); })); | 293 callback(tabs.map(function(tab) { return new Tab(tab); })); |
291 }); | 294 }); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 onCompleted: new CompletedTabEventTarget(), | 342 onCompleted: new CompletedTabEventTarget(), |
340 onActivated: new ActivatedTabEventTarget(), | 343 onActivated: new ActivatedTabEventTarget(), |
341 onRemoved: new RemovedTabEventTarget() | 344 onRemoved: new RemovedTabEventTarget() |
342 }; | 345 }; |
343 | 346 |
344 ext.webRequest = { | 347 ext.webRequest = { |
345 onBeforeRequest: new BeforeRequestEventTarget(), | 348 onBeforeRequest: new BeforeRequestEventTarget(), |
346 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged | 349 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged |
347 }; | 350 }; |
348 })(); | 351 })(); |
LEFT | RIGHT |