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

Unified Diff: chrome/ext/background.js

Issue 29317030: Issue 2689 - Logic problem in BrowserAction._addChange (Closed)
Patch Set: Created June 17, 2015, 11:11 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -149,17 +149,17 @@
chrome.tabs.onRemoved.addListener(forgetTab);
/* Browser actions */
var BrowserAction = function(tabId)
{
this._tabId = tabId;
- this._changes = null;
+ this._changes = {};
};
BrowserAction.prototype = {
_applyChanges: function()
{
if ("iconPath" in this._changes)
{
chrome.browserAction.setIcon({
tabId: this._tabId,
@@ -181,17 +181,17 @@
if ("badgeColor" in this._changes)
{
chrome.browserAction.setBadgeBackgroundColor({
tabId: this._tabId,
color: this._changes.badgeColor
});
}
- this._changes = null;
+ this._changes = {};
},
_queueChanges: function()
{
chrome.tabs.get(this._tabId, function()
{
// If the tab is prerendered, chrome.tabs.get() sets
// chrome.runtime.lastError and we have to delay our changes
// until the currently visible tab is replaced with the
@@ -211,23 +211,18 @@
else
{
this._applyChanges();
}
}.bind(this));
},
_addChange: function(name, value)
{
- if (!this._changes)
- {
- this._changes = {};
- this._queueChanges();
- }
-
this._changes[name] = value;
+ this._queueChanges();
Sebastian Noack 2015/06/23 09:46:36 This will call chrome.tabs.get() redundantly if mu
},
setIcon: function(path)
{
this._addChange("iconPath", path);
},
setBadge: function(badge)
{
if (!badge)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld