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

Side by Side Diff: ext/background.js

Issue 29995555: Issue 7253 - Pre-render icons for badge on Chromium (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rebase on Rietveld patch 29997602 Created Feb. 3, 2019, 8:55 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 | lib/icon.js » ('j') | 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 catch (e) 342 catch (e)
343 { 343 {
344 // Edge throws if passed icon sizes different than 19,20,38,40px. 344 // Edge throws if passed icon sizes different than 19,20,38,40px.
345 delete path[16]; 345 delete path[16];
346 delete path[32]; 346 delete path[32];
347 return browser.browserAction.setIcon({tabId: this._tabId, path}); 347 return browser.browserAction.setIcon({tabId: this._tabId, path});
348 } 348 }
349 } 349 }
350 350
351 if (change == "iconImageData" && "setIcon" in browser.browserAction)
352 {
353 return browser.browserAction.setIcon({
354 tabId: this._tabId,
355 imageData: this._changes.iconImageData
356 });
357 }
358
351 // There is no badge on Firefox for Android; the browser action is 359 // There is no badge on Firefox for Android; the browser action is
352 // simply a menu item. 360 // simply a menu item.
353 if (change == "badgeText" && "setBadgeText" in browser.browserAction) 361 if (change == "badgeText" && "setBadgeText" in browser.browserAction)
354 return browser.browserAction.setBadgeText({ 362 return browser.browserAction.setBadgeText({
355 tabId: this._tabId, 363 tabId: this._tabId,
356 text: this._changes.badgeText 364 text: this._changes.badgeText
357 }); 365 });
358 366
359 // There is no badge on Firefox for Android; the browser action is 367 // There is no badge on Firefox for Android; the browser action is
360 // simply a menu item. 368 // simply a menu item.
(...skipping 29 matching lines...) Expand all
390 this._changes = null; 398 this._changes = null;
391 }).catch(() => 399 }).catch(() =>
392 { 400 {
393 // If the tab is prerendered, browser.browserAction.set* fails 401 // If the tab is prerendered, browser.browserAction.set* fails
394 // and we have to delay our changes until the currently visible tab 402 // and we have to delay our changes until the currently visible tab
395 // is replaced with the prerendered tab. 403 // is replaced with the prerendered tab.
396 browser.tabs.onReplaced.addListener(onReplaced); 404 browser.tabs.onReplaced.addListener(onReplaced);
397 }); 405 });
398 } 406 }
399 }, 407 },
400 setIcon(path) 408 setIcon(path, imageData = null)
401 { 409 {
402 this._addChange("iconPath", path); 410 // Use ImageData if available.
411 if (imageData)
412 this._addChange("iconImageData", imageData);
413 else
414 this._addChange("iconPath", path);
403 }, 415 },
404 setBadge(badge) 416 setBadge(badge)
405 { 417 {
406 if (!badge) 418 if (!badge)
407 { 419 {
408 this._addChange("badgeText", ""); 420 this._addChange("badgeText", "");
409 } 421 }
410 else 422 else
411 { 423 {
412 if ("number" in badge) 424 if ("number" in badge)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return frames.get(0) || null; 529 return frames.get(0) || null;
518 } 530 }
519 }; 531 };
520 } 532 }
521 533
522 return ext.onMessage._dispatch( 534 return ext.onMessage._dispatch(
523 message, sender, sendResponse 535 message, sender, sendResponse
524 ).includes(true); 536 ).includes(true);
525 }); 537 });
526 } 538 }
OLDNEW
« no previous file with comments | « no previous file | lib/icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld