[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Add a WebExtUI the makes use of the new assests



commit e7f3ade06827f6501333f986661ed7aa4277946e
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Tue May 7 15:44:01 2019 -0400

    Add a WebExtUI the makes use of the new assests
    
    The browser icon shows the on/off state.
---
 proxy/init.coffee           | 2 ++
 proxy/shims.coffee          | 4 +++-
 proxy/ui.coffee             | 9 +++++++++
 proxy/webext/manifest.json  | 6 +++---
 proxy/webext/snowflake.html | 5 +----
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/proxy/init.coffee b/proxy/init.coffee
index 031f7c5..22d4315 100644
--- a/proxy/init.coffee
+++ b/proxy/init.coffee
@@ -58,6 +58,8 @@ init = () ->
     ui = new BadgeUI()
   else if (document.getElementById('status') != null)
     ui = new DebugUI()
+  else if (document.getElementById('webext') != null)
+    ui = new WebExtUI()
   else
     ui = new UI()
 
diff --git a/proxy/shims.coffee b/proxy/shims.coffee
index 1aeaf3d..5c4bae0 100644
--- a/proxy/shims.coffee
+++ b/proxy/shims.coffee
@@ -5,7 +5,8 @@ WebRTC shims for multiple browsers.
 if module?.exports
   window = {}
   document =
-    getElementById: () -> null,
+    getElementById: () -> null
+  chrome = {}
   location = ''
 
   if not TESTING? or not TESTING
@@ -23,6 +24,7 @@ if module?.exports
 else
   window = this
   document = window.document
+  chrome = window.chrome
   location = window.location.search.substr(1)
 
   PeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection ||
diff --git a/proxy/ui.coffee b/proxy/ui.coffee
index d887dbd..d4d647a 100644
--- a/proxy/ui.coffee
+++ b/proxy/ui.coffee
@@ -42,3 +42,12 @@ class DebugUI extends UI
     # Scroll to latest
     @$msglog.value += msg + '\n'
     @$msglog.scrollTop = @$msglog.scrollHeight
+
+
+class WebExtUI extends UI
+  setActive: (connected) =>
+    chrome.browserAction.setIcon {
+      "path": {
+        "32": "icons/status-" + (if connected then "on" else "off") + ".png"
+      }
+    }
diff --git a/proxy/webext/manifest.json b/proxy/webext/manifest.json
index 83a3358..f0f671d 100644
--- a/proxy/webext/manifest.json
+++ b/proxy/webext/manifest.json
@@ -9,8 +9,8 @@
 	},
 	"browser_action": {
 		"default_icon": {
-			"16": "icons/status-off.png",
-			"32": "icons/status-off@xxxxxx"
-		}
+			"32": "icons/status-off.png"
+		},
+		"default_title": "Snowflake"
 	}
 }
diff --git a/proxy/webext/snowflake.html b/proxy/webext/snowflake.html
index 6a5eca0..6d28fe6 100644
--- a/proxy/webext/snowflake.html
+++ b/proxy/webext/snowflake.html
@@ -8,9 +8,6 @@
 	</head>
 	<body>
 		<!-- FIXME: Refactor snowflake.js to eliminate the need for this -->
-		<div>
-			<div id="status"></div>
-			<textarea id="msglog" readonly></textarea>
-		</div>
+		<div id="webext" />
 	</body>
 </html>

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits