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

Delta Between Two Patch Sets: ext/background.js

Issue 29509573: Issue 5347 - Check for browserAction API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Created Aug. 8, 2017, 11:38 a.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 if (chrome.browserAction.setIcon) 330 // Firefox for Android displays the browser action not as an icon but
331 // as a menu item. There is no icon, but such an option may be added in
332 // the future.
333 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
334 if ("setIcon" in chrome.browserAction)
331 { 335 {
332 chrome.browserAction.setIcon({ 336 chrome.browserAction.setIcon({
333 tabId: this._tabId, 337 tabId: this._tabId,
334 path: { 338 path: {
335 16: this._changes.iconPath.replace("$size", "16"), 339 16: this._changes.iconPath.replace("$size", "16"),
336 19: this._changes.iconPath.replace("$size", "19"), 340 19: this._changes.iconPath.replace("$size", "19"),
337 20: this._changes.iconPath.replace("$size", "20"), 341 20: this._changes.iconPath.replace("$size", "20"),
338 32: this._changes.iconPath.replace("$size", "32"), 342 32: this._changes.iconPath.replace("$size", "32"),
339 38: this._changes.iconPath.replace("$size", "38"), 343 38: this._changes.iconPath.replace("$size", "38"),
340 40: this._changes.iconPath.replace("$size", "40") 344 40: this._changes.iconPath.replace("$size", "40")
341 } 345 }
342 }); 346 });
343 } 347 }
344 } 348 }
345 349
346 if ("badgeText" in this._changes) 350 if ("badgeText" in this._changes)
347 { 351 {
348 if (chrome.browserAction.setBadgeText) 352 // There is no badge on Firefox for Android; the browser action is
353 // simply a menu item.
354 if ("setBadgeText" in chrome.browserAction)
349 { 355 {
350 chrome.browserAction.setBadgeText({ 356 chrome.browserAction.setBadgeText({
351 tabId: this._tabId, 357 tabId: this._tabId,
352 text: this._changes.badgeText 358 text: this._changes.badgeText
353 }); 359 });
354 } 360 }
355 } 361 }
356 362
357 if ("badgeColor" in this._changes) 363 if ("badgeColor" in this._changes)
358 { 364 {
359 if (chrome.browserAction.setBadgeBackgroundColor) 365 // There is no badge on Firefox for Android; the browser action is
366 // simply a menu item.
367 if ("setBadgeBackgroundColor" in chrome.browserAction)
360 { 368 {
361 chrome.browserAction.setBadgeBackgroundColor({ 369 chrome.browserAction.setBadgeBackgroundColor({
362 tabId: this._tabId, 370 tabId: this._tabId,
363 color: this._changes.badgeColor 371 color: this._changes.badgeColor
364 }); 372 });
365 } 373 }
366 } 374 }
367 375
368 this._changes = null; 376 this._changes = null;
369 }, 377 },
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 ext.windows = { 756 ext.windows = {
749 create(createData, callback) 757 create(createData, callback)
750 { 758 {
751 chrome.windows.create(createData, createdWindow => 759 chrome.windows.create(createData, createdWindow =>
752 { 760 {
753 afterTabLoaded(callback)(createdWindow.tabs[0]); 761 afterTabLoaded(callback)(createdWindow.tabs[0]);
754 }); 762 });
755 } 763 }
756 }; 764 };
757 }()); 765 }());
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld