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: Use consistent style for feature detection Created Aug. 15, 2017, 11:57 p.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 if ("setIcon" in chrome.browserAction)
Wladimir Palant 2017/08/16 10:52:07 Here and below, maybe add a comment explaining whi
Manish Jethani 2017/08/16 11:45:42 Done.
331 tabId: this._tabId, 331 {
332 path: { 332 chrome.browserAction.setIcon({
333 16: this._changes.iconPath.replace("$size", "16"), 333 tabId: this._tabId,
334 19: this._changes.iconPath.replace("$size", "19"), 334 path: {
335 20: this._changes.iconPath.replace("$size", "20"), 335 16: this._changes.iconPath.replace("$size", "16"),
336 32: this._changes.iconPath.replace("$size", "32"), 336 19: this._changes.iconPath.replace("$size", "19"),
337 38: this._changes.iconPath.replace("$size", "38"), 337 20: this._changes.iconPath.replace("$size", "20"),
338 40: this._changes.iconPath.replace("$size", "40") 338 32: this._changes.iconPath.replace("$size", "32"),
339 } 339 38: this._changes.iconPath.replace("$size", "38"),
340 }); 340 40: this._changes.iconPath.replace("$size", "40")
341 }
342 });
343 }
341 } 344 }
342 345
343 if ("badgeText" in this._changes) 346 if ("badgeText" in this._changes)
344 { 347 {
345 chrome.browserAction.setBadgeText({ 348 if ("setBadgeText" in chrome.browserAction)
346 tabId: this._tabId, 349 {
347 text: this._changes.badgeText 350 chrome.browserAction.setBadgeText({
348 }); 351 tabId: this._tabId,
352 text: this._changes.badgeText
353 });
354 }
349 } 355 }
350 356
351 if ("badgeColor" in this._changes) 357 if ("badgeColor" in this._changes)
352 { 358 {
353 chrome.browserAction.setBadgeBackgroundColor({ 359 if ("setBadgeBackgroundColor" in chrome.browserAction)
354 tabId: this._tabId, 360 {
355 color: this._changes.badgeColor 361 chrome.browserAction.setBadgeBackgroundColor({
356 }); 362 tabId: this._tabId,
363 color: this._changes.badgeColor
364 });
365 }
357 } 366 }
358 367
359 this._changes = null; 368 this._changes = null;
360 }, 369 },
361 _queueChanges() 370 _queueChanges()
362 { 371 {
363 chrome.tabs.get(this._tabId, () => 372 chrome.tabs.get(this._tabId, () =>
364 { 373 {
365 // If the tab is prerendered, chrome.tabs.get() sets 374 // If the tab is prerendered, chrome.tabs.get() sets
366 // chrome.runtime.lastError and we have to delay our changes 375 // 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 = { 748 ext.windows = {
740 create(createData, callback) 749 create(createData, callback)
741 { 750 {
742 chrome.windows.create(createData, createdWindow => 751 chrome.windows.create(createData, createdWindow =>
743 { 752 {
744 afterTabLoaded(callback)(createdWindow.tabs[0]); 753 afterTabLoaded(callback)(createdWindow.tabs[0]);
745 }); 754 });
746 } 755 }
747 }; 756 };
748 }()); 757 }());
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