mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1386786 - Fix Android browserAction.setTitle/getTitle behavior on switching and closing tab. r=mixedpuppy
MozReview-Commit-ID: LFxnySvBBOz --HG-- extra : rebase_source : 5af740eac118af0f3d61ca972e5b94210b979b24
This commit is contained in:
parent
2c32549a1d
commit
2ad28511d1
@ -37,15 +37,6 @@ class BrowserAction {
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name for the active tab. Used for testing only.
|
||||
* @returns {string} the name used for the active tab.
|
||||
*/
|
||||
get activeName() {
|
||||
let tab = tabTracker.activeTab;
|
||||
return this.tabContext.get(tab.id).name || this.defaults.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by the BrowserActions module. This event will get
|
||||
* called whenever the browser action is clicked on.
|
||||
@ -56,19 +47,19 @@ class BrowserAction {
|
||||
|
||||
/**
|
||||
* Updates the browser action whenever a tab is selected.
|
||||
* @param {Object} tab The tab to update.
|
||||
* @param {string} tabId The tab id to update.
|
||||
*/
|
||||
onTabSelected(tab) {
|
||||
let name = this.tabContext.get(tab.id).name || this.defaults.name;
|
||||
onTabSelected(tabId) {
|
||||
let name = this.tabContext.get(tabId).name || this.defaults.name;
|
||||
BrowserActions.update(this.uuid, {name});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the tab from the property map now that it is closed.
|
||||
* @param {Object} tab The tab which closed.
|
||||
* @param {string} tabId The tab id of the closed tab.
|
||||
*/
|
||||
onTabClosed(tab) {
|
||||
this.tabContext.clear(tab.id);
|
||||
onTabClosed(tabId) {
|
||||
this.tabContext.clear(tabId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +84,7 @@ class BrowserAction {
|
||||
}
|
||||
}
|
||||
|
||||
if (tab && tab.selected) {
|
||||
if (!tab || tab.selected) {
|
||||
BrowserActions.update(this.uuid, {[prop]: value});
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ this.EXPORTED_SYMBOLS = ["BrowserActions"];
|
||||
|
||||
var BrowserActions = {
|
||||
_browserActions: {},
|
||||
_browserActionTitles: {},
|
||||
|
||||
_initialized: false,
|
||||
|
||||
@ -73,6 +74,7 @@ var BrowserActions = {
|
||||
});
|
||||
|
||||
this._browserActions[browserAction.uuid] = browserAction;
|
||||
this._browserActionTitles[browserAction.uuid] = browserAction.defaults.name;
|
||||
|
||||
this._maybeRegisterListeners();
|
||||
},
|
||||
@ -89,6 +91,8 @@ var BrowserActions = {
|
||||
uuid,
|
||||
options,
|
||||
});
|
||||
|
||||
this._browserActionTitles[uuid] = options.name;
|
||||
}
|
||||
},
|
||||
|
||||
@ -99,7 +103,7 @@ var BrowserActions = {
|
||||
* @returns {string} the name currently used for the browser action.
|
||||
*/
|
||||
getNameForActiveTab(uuid) {
|
||||
return this._browserActions[uuid].activeName;
|
||||
return this._browserActionTitles[uuid];
|
||||
},
|
||||
|
||||
/**
|
||||
@ -137,6 +141,7 @@ var BrowserActions = {
|
||||
uuid,
|
||||
});
|
||||
delete this._browserActions[uuid];
|
||||
delete this._browserActionTitles[uuid];
|
||||
this._maybeUnregisterListeners();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user