| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 { | 189 { |
| 190 return [urls ? {urls: urls} : {}, ["blocking"]]; | 190 return [urls ? {urls: urls} : {}, ["blocking"]]; |
| 191 } | 191 } |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 | 194 |
| 195 /* Tabs */ | 195 /* Tabs */ |
| 196 | 196 |
| 197 var sendMessage = chrome.tabs.sendMessage || chrome.tabs.sendRequest; | 197 var sendMessage = chrome.tabs.sendMessage || chrome.tabs.sendRequest; |
| 198 | 198 |
| 199 var PageAction = function(tabId) | 199 var BrowserAction = function(tabId) |
| 200 { | 200 { |
| 201 this._tabId = tabId; | 201 this._tabId = tabId; |
| 202 }; | 202 }; |
| 203 PageAction.prototype = { | 203 BrowserAction.prototype = { |
| 204 setIcon: function(path) | 204 setIcon: function(path) |
| 205 { | 205 { |
| 206 chrome.pageAction.setIcon({tabId: this._tabId, path: path}); | 206 chrome.browserAction.setIcon({tabId: this._tabId, path: path}); |
| 207 }, | 207 }, |
| 208 setTitle: function(title) | 208 setTitle: function(title) |
| 209 { | 209 { |
| 210 chrome.pageAction.setTitle({tabId: this._tabId, title: title}); | 210 chrome.browserAction.setTitle({tabId: this._tabId, title: title}); |
| 211 }, | 211 }, |
| 212 hide: function() | 212 hide: function() |
| 213 { | 213 { |
| 214 chrome.pageAction.hide(this._tabId); | 214 chrome.browserAction.hide(this._tabId); |
| 215 }, | 215 }, |
| 216 show: function() | 216 show: function() |
| 217 { | 217 { |
| 218 chrome.pageAction.show(this._tabId); | 218 chrome.browserAction.show(this._tabId); |
| 219 }, | |
| 220 setBadgeBackgroundColor: function(color) | |
| 221 { | |
| 222 chrome.browserAction.setBadgeBackgroundColor({tabId: this._tabId, color: c olor}); | |
| 223 }, | |
| 224 setBadgeNumber: function(number) | |
| 225 { | |
| 226 chrome.browserAction.setBadgeText({ | |
| 227 tabId: this._tabId, | |
| 228 text: (number === null) ? "" : number.toString() | |
| 229 }); | |
| 219 } | 230 } |
|
Wladimir Palant
2013/12/03 12:55:43
This is a strange API - we require setting each pa
Sebastian Noack
2013/12/03 13:12:26
Safari only support numbers for the badge. That is
Wladimir Palant
2013/12/03 13:45:03
I see. I guess calling it badge.number rather than
Sebastian Noack
2013/12/03 15:03:33
I still see no advantage of a single function with
Thomas Greiner
2013/12/04 10:44:50
The reason is that in Chrome's API you can either
Sebastian Noack
2013/12/04 11:48:38
Or to set the background color only once, instead
Thomas Greiner
2013/12/10 10:09:29
The only reason is that it would be more confusing
Thomas Greiner
2013/12/11 13:15:24
Can we agree on using Wladimir's suggestion?
@Fel
Felix Dahlke
2013/12/11 13:23:02
I think it's nicer API-wise to have a single funct
Thomas Greiner
2013/12/13 10:37:40
Done.
| |
| 220 }; | 231 }; |
| 221 | 232 |
| 222 Tab = function(tab) | 233 Tab = function(tab) |
| 223 { | 234 { |
| 224 this._id = tab.id; | 235 this._id = tab.id; |
| 225 | 236 |
| 226 this.url = tab.url; | 237 this.url = tab.url; |
| 227 this.pageAction = new PageAction(tab.id); | 238 this.browserAction = new BrowserAction(tab.id); |
| 228 | 239 |
| 229 this.onLoading = ext.tabs.onLoading._bindToTab(this); | 240 this.onLoading = ext.tabs.onLoading._bindToTab(this); |
| 230 this.onCompleted = ext.tabs.onCompleted._bindToTab(this); | 241 this.onCompleted = ext.tabs.onCompleted._bindToTab(this); |
| 231 this.onActivated = ext.tabs.onActivated._bindToTab(this); | 242 this.onActivated = ext.tabs.onActivated._bindToTab(this); |
| 232 this.onRemoved = ext.tabs.onRemoved._bindToTab(this); | 243 this.onRemoved = ext.tabs.onRemoved._bindToTab(this); |
| 233 }; | 244 }; |
| 234 Tab.prototype = { | 245 Tab.prototype = { |
| 235 close: function() | 246 close: function() |
| 236 { | 247 { |
| 237 chrome.tabs.remove(this._id); | 248 chrome.tabs.remove(this._id); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 onCompleted: new CompletedTabEventTarget(), | 355 onCompleted: new CompletedTabEventTarget(), |
| 345 onActivated: new ActivatedTabEventTarget(), | 356 onActivated: new ActivatedTabEventTarget(), |
| 346 onRemoved: new RemovedTabEventTarget() | 357 onRemoved: new RemovedTabEventTarget() |
| 347 }; | 358 }; |
| 348 | 359 |
| 349 ext.webRequest = { | 360 ext.webRequest = { |
| 350 onBeforeRequest: new BeforeRequestEventTarget(), | 361 onBeforeRequest: new BeforeRequestEventTarget(), |
| 351 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged | 362 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged |
| 352 }; | 363 }; |
| 353 })(); | 364 })(); |
| OLD | NEW |