aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Crosby2012-08-19 09:58:57 -0700
committerPhil Crosby2012-08-19 09:58:57 -0700
commit3001bdc53c160c3606ef6903d71db675f4ffcb9a (patch)
treee2937f83b7a928a3bd0914f9e43e15c7304b9344
parent486ba68a42e2ba7b96a7a14b0ae34aca7ac7e780 (diff)
parent038ae30e4275aa5b59d84833f2cdca38a40bfc71 (diff)
downloadvimium-3001bdc53c160c3606ef6903d71db675f4ffcb9a.tar.bz2
Merge pull request #618 from dmacdougall/browser_action_icon
Re-enable browser action icon
-rw-r--r--background_scripts/main.js11
-rw-r--r--icons/browser_action_disabled.pngbin0 -> 32025 bytes
-rw-r--r--icons/browser_action_enabled.pngbin0 -> 37455 bytes
-rw-r--r--manifest.json6
-rw-r--r--popup.html141
-rw-r--r--popup.js20
6 files changed, 91 insertions, 87 deletions
diff --git a/background_scripts/main.js b/background_scripts/main.js
index 287af48e..5f5df508 100644
--- a/background_scripts/main.js
+++ b/background_scripts/main.js
@@ -359,16 +359,13 @@ function updateOpenTabs(tab) {
* 3. Active tab is enabled but should be disabled -> disable icon and disable vimium
*/
function updateActiveState(tabId) {
- // TODO(philc): Re-enable once we've restyled the browser action icon.
- return;
- var enabledIcon = "icons/icon48.png";
- var disabledIcon = "icons/icon48disabled.png";
+ var enabledIcon = "icons/browser_action_enabled.png";
+ var disabledIcon = "icons/browser_action_disabled.png";
chrome.tabs.get(tabId, function(tab) {
// Default to disabled state in case we can't connect to Vimium, primarily for the "New Tab" page.
- // TODO(philc): Re-enable once we've restyled the browser action icon.
- // chrome.browserAction.setIcon({ path: disabledIcon });
+ chrome.browserAction.setIcon({ path: disabledIcon });
chrome.tabs.sendRequest(tabId, { name: "getActiveState" }, function(response) {
- var isCurrentlyEnabled = response.enabled;
+ var isCurrentlyEnabled = response !== undefined && response.enabled;
var shouldBeEnabled = isEnabledForUrl({url: tab.url}).isEnabledForUrl;
if (isCurrentlyEnabled) {
diff --git a/icons/browser_action_disabled.png b/icons/browser_action_disabled.png
new file mode 100644
index 00000000..458ffe72
--- /dev/null
+++ b/icons/browser_action_disabled.png
Binary files differ
diff --git a/icons/browser_action_enabled.png b/icons/browser_action_enabled.png
new file mode 100644
index 00000000..fe4c36bb
--- /dev/null
+++ b/icons/browser_action_enabled.png
Binary files differ
diff --git a/manifest.json b/manifest.json
index 4c3f3199..2e8dac72 100644
--- a/manifest.json
+++ b/manifest.json
@@ -39,5 +39,9 @@
"run_at": "document_start",
"all_frames": true
}
- ]
+ ],
+ "browser_action": {
+ "default_icon": "icons/browser_action_disabled.png",
+ "default_popup": "popup.html"
+ }
}
diff --git a/popup.html b/popup.html
index 7fb9b646..c5944992 100644
--- a/popup.html
+++ b/popup.html
@@ -1,79 +1,62 @@
-<style>
- * {
- margin: 0px;
- padding: 0px;
- }
-
- #vimiumPopup { width: 300px; }
-
- #excludeControls {
- padding: 10px;
- }
-
- #popupInput {
- width: 160px;
- }
-
- #excludeConfirm {
- display: inline-block;
- width: 18px;
- height: 13px;
- background: url(icons/check.png) 3px 2px no-repeat;
- display: none;
- }
-
- #popupButton { margin-left: 10px; }
-
- #popupMenu ul {
- list-style: none;
- }
-
- #popupMenu a, #popupMenu a:active, #popupMenu a:visited {
- color: #3F6EC2;
- display: block;
- border-top: 1px solid #DDDDDD;
- padding: 3px;
- padding-left: 10px;
- }
-
- #popupMenu a:hover {
- background: #EEEEEE;
- }
-</style>
-
-<div id="vimiumPopup">
- <div id="excludeControls">
- <input id="popupInput" type="text" />
- <input id="popupButton" type="button" value="Exclude URL" />
- <span id="excludeConfirm"></span>
- </div>
-
- <div id="popupMenu">
- <ul>
- <li><a id="optionsLink" target="_blank">Options</a></li>
- </ul>
- </div>
-</div>
-
-
-<script type="text/javascript">
- function onLoad() {
- document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html"));
- chrome.tabs.getSelected(null, function(tab) {
- // The common use case is to disable Vimium at the domain level.
- // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html".
- var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url;
- document.getElementById("popupInput").value = domain + "*";
- });
- }
-
- function onExcludeUrl(e) {
- var url = document.getElementById("popupInput").value;
- chrome.extension.getBackgroundPage().addExcludedUrl(url);
- document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block");
- }
-
- window.addEventListener("load", onLoad, false);
- document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false);
-</script>
-
+<html>
+ <head>
+ <style>
+ * {
+ margin: 0px;
+ padding: 0px;
+ }
+
+ #vimiumPopup { width: 300px; }
+
+ #excludeControls {
+ padding: 10px;
+ }
+
+ #popupInput {
+ width: 160px;
+ }
+
+ #excludeConfirm {
+ display: inline-block;
+ width: 18px;
+ height: 13px;
+ background: url(icons/check.png) 3px 2px no-repeat;
+ display: none;
+ }
+
+ #popupButton { margin-left: 10px; }
+
+ #popupMenu ul {
+ list-style: none;
+ }
+
+ #popupMenu a, #popupMenu a:active, #popupMenu a:visited {
+ color: #3F6EC2;
+ display: block;
+ border-top: 1px solid #DDDDDD;
+ padding: 3px;
+ padding-left: 10px;
+ }
+
+ #popupMenu a:hover {
+ background: #EEEEEE;
+ }
+ </style>
+ <script src="popup.js"></script>
+ </head>
+ <body>
+ <div id="vimiumPopup">
+ <div id="excludeControls">
+ <input id="popupInput" type="text" />
+ <input id="popupButton" type="button" value="Exclude URL" />
+ <span id="excludeConfirm"></span>
+ </div>
+
+ <div id="popupMenu">
+ <ul>
+ <li><a id="optionsLink" target="_blank">Options</a></li>
+ </ul>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/popup.js b/popup.js
new file mode 100644
index 00000000..859f30f3
--- /dev/null
+++ b/popup.js
@@ -0,0 +1,20 @@
+function onLoad() {
+ document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html"));
+ chrome.tabs.getSelected(null, function(tab) {
+ // The common use case is to disable Vimium at the domain level.
+ // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html".
+ var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url;
+ document.getElementById("popupInput").value = domain + "*";
+ });
+}
+
+function onExcludeUrl(e) {
+ var url = document.getElementById("popupInput").value;
+ chrome.extension.getBackgroundPage().addExcludedUrl(url);
+ document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block");
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false);
+ onLoad();
+});