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

Unified Diff: chrome/background.js

Issue 29317001: Relocated icon and redesigned icon popup (Closed)
Patch Set: Merged setBadgeNumber and setBadgeBackgroundColor Created Dec. 13, 2013, 10:36 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 | « background.js ('k') | iconAnimation.js » ('j') | lib/stats.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/background.js
===================================================================
--- a/chrome/background.js
+++ b/chrome/background.js
@@ -196,26 +196,53 @@
var sendMessage = chrome.tabs.sendMessage || chrome.tabs.sendRequest;
- var PageAction = function(tabId)
+ var BrowserAction = function(tabId)
{
this._tabId = tabId;
};
- PageAction.prototype = {
+ BrowserAction.prototype = {
setIcon: function(path)
{
- chrome.pageAction.setIcon({tabId: this._tabId, path: path});
+ chrome.browserAction.setIcon({tabId: this._tabId, path: path});
},
setTitle: function(title)
{
- chrome.pageAction.setTitle({tabId: this._tabId, title: title});
+ chrome.browserAction.setTitle({tabId: this._tabId, title: title});
},
hide: function()
{
- chrome.pageAction.hide(this._tabId);
+ chrome.browserAction.hide(this._tabId);
},
show: function()
{
- chrome.pageAction.show(this._tabId);
+ chrome.browserAction.show(this._tabId);
+ },
+ setBadge: function(badge)
+ {
+ if (!badge)
+ {
+ chrome.browserAction.setBadgeText({
+ tabId: this._tabId,
+ text: ""
+ });
+ return;
+ }
+
+ if ("color" in badge)
+ {
+ chrome.browserAction.setBadgeBackgroundColor({
+ tabId: this._tabId,
+ color: badge.color
+ });
+ }
+
+ if ("number" in badge)
+ {
+ chrome.browserAction.setBadgeText({
+ tabId: this._tabId,
+ text: badge.number.toString()
+ });
+ }
}
};
@@ -224,7 +251,7 @@
this._id = tab.id;
this.url = tab.url;
- this.pageAction = new PageAction(tab.id);
+ this.browserAction = new BrowserAction(tab.id);
this.onLoading = ext.tabs.onLoading._bindToTab(this);
this.onCompleted = ext.tabs.onCompleted._bindToTab(this);
« no previous file with comments | « background.js ('k') | iconAnimation.js » ('j') | lib/stats.js » ('J')

Powered by Google App Engine
This is Rietveld