Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ext/background.js

Issue 29509573: Issue 5347 - Check for browserAction API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Add comments explaining why Firefox for Android does not support these APIs Created Aug. 16, 2017, 11:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 let BrowserAction = function(tabId) 320 let BrowserAction = function(tabId)
321 { 321 {
322 this._tabId = tabId; 322 this._tabId = tabId;
323 this._changes = null; 323 this._changes = null;
324 }; 324 };
325 BrowserAction.prototype = { 325 BrowserAction.prototype = {
326 _applyChanges() 326 _applyChanges()
327 { 327 {
328 if ("iconPath" in this._changes) 328 if ("iconPath" in this._changes)
329 { 329 {
330 chrome.browserAction.setIcon({ 330 // Firefox for Android displays the browser action not as an icon but
331 tabId: this._tabId, 331 // as a menu item. There is no icon, but such an option may be added in
332 path: { 332 // the future.
333 16: this._changes.iconPath.replace("$size", "16"), 333 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
334 19: this._changes.iconPath.replace("$size", "19"), 334 if ("setIcon" in chrome.browserAction)
335 20: this._changes.iconPath.replace("$size", "20"), 335 {
336 32: this._changes.iconPath.replace("$size", "32"), 336 chrome.browserAction.setIcon({
337 38: this._changes.iconPath.replace("$size", "38"), 337 tabId: this._tabId,
338 40: this._changes.iconPath.replace("$size", "40") 338 path: {
339 } 339 16: this._changes.iconPath.replace("$size", "16"),
340 }); 340 19: this._changes.iconPath.replace("$size", "19"),
341 20: this._changes.iconPath.replace("$size", "20"),
342 32: this._changes.iconPath.replace("$size", "32"),
343 38: this._changes.iconPath.replace("$size", "38"),
344 40: this._changes.iconPath.replace("$size", "40")
345 }
346 });
347 }
341 } 348 }
342 349
343 if ("badgeText" in this._changes) 350 if ("badgeText" in this._changes)
344 { 351 {
345 chrome.browserAction.setBadgeText({ 352 // There is no badge on Firefox for Android; the browser action is
346 tabId: this._tabId, 353 // simply a menu item.
347 text: this._changes.badgeText 354 if ("setBadgeText" in chrome.browserAction)
348 }); 355 {
356 chrome.browserAction.setBadgeText({
357 tabId: this._tabId,
358 text: this._changes.badgeText
359 });
360 }
349 } 361 }
350 362
351 if ("badgeColor" in this._changes) 363 if ("badgeColor" in this._changes)
352 { 364 {
353 chrome.browserAction.setBadgeBackgroundColor({ 365 // There is no badge on Firefox for Android; the browser action is
354 tabId: this._tabId, 366 // simply a menu item.
355 color: this._changes.badgeColor 367 if ("setBadgeBackgroundColor" in chrome.browserAction)
356 }); 368 {
369 chrome.browserAction.setBadgeBackgroundColor({
370 tabId: this._tabId,
371 color: this._changes.badgeColor
372 });
373 }
357 } 374 }
358 375
359 this._changes = null; 376 this._changes = null;
360 }, 377 },
361 _queueChanges() 378 _queueChanges()
362 { 379 {
363 chrome.tabs.get(this._tabId, () => 380 chrome.tabs.get(this._tabId, () =>
364 { 381 {
365 // If the tab is prerendered, chrome.tabs.get() sets 382 // If the tab is prerendered, chrome.tabs.get() sets
366 // chrome.runtime.lastError and we have to delay our changes 383 // chrome.runtime.lastError and we have to delay our changes
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 ext.windows = { 756 ext.windows = {
740 create(createData, callback) 757 create(createData, callback)
741 { 758 {
742 chrome.windows.create(createData, createdWindow => 759 chrome.windows.create(createData, createdWindow =>
743 { 760 {
744 afterTabLoaded(callback)(createdWindow.tabs[0]); 761 afterTabLoaded(callback)(createdWindow.tabs[0]);
745 }); 762 });
746 } 763 }
747 }; 764 };
748 }()); 765 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld