aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer
diff options
context:
space:
mode:
Diffstat (limited to 'tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer')
-rw-r--r--tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/bootstrap.js52
-rw-r--r--tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/install.rdf30
2 files changed, 82 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/bootstrap.js b/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/bootstrap.js
new file mode 100644
index 0000000..8b26ab0
--- /dev/null
+++ b/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/bootstrap.js
@@ -0,0 +1,52 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+function startup(data, reason) {
+ // Activate stderr/stdout redirection to logcat.
+ //
+ // This is a really basic approach. A proper implementation will be done by
+ // the bug 689777.
+ try {
+ Cu.import("resource://gre/modules/ctypes.jsm");
+
+ ctypes.open("libdvm.so")
+ .declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t)();
+ } catch(e) {
+ Cu.reportError("Mobile Killer: Unable to execute jsctype hack: " + e);
+ }
+
+ let Watcher = {
+ window: null,
+ onOpenWindow: function(window) {
+ window = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ window.addEventListener("keydown", this, true);
+ },
+ onWindowTitleChange: function () {},
+ handleEvent: function(event) {
+ // This event is dispatched via: abd shell input keycode 19
+ // KEYCODE_DPAD_UP=19, UP can't be fired by virtual keyboard,
+ // so it should be safe to take this event as a kill signal.
+ if (event.keyCode == 38 && event.which == 38) {
+ Cu.reportError("Mobile killer triggered!");
+ let appStartup = Cc['@mozilla.org/toolkit/app-startup;1'].
+ getService(Ci.nsIAppStartup);
+ appStartup.quit(Ci.nsIAppStartup.eForceQuit);
+ }
+ }
+ };
+ Services.wm.addListener(Watcher);
+ Cu.reportError("Mobile killer ready to kill firefox.");
+}
+
+function install() {}
+function shutdown() {}
diff --git a/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/install.rdf b/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/install.rdf
new file mode 100644
index 0000000..8ae4e7a
--- /dev/null
+++ b/tools/addon-sdk-1.5/python-lib/cuddlefish/mobile-killer/install.rdf
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>mobile-killer@mozilla.com</em:id>
+ <em:version>1.0</em:version>
+ <em:type>2</em:type>
+ <em:bootstrap>true</em:bootstrap>
+
+ <!-- Fennec -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
+ <em:minVersion>1</em:minVersion>
+ <em:maxVersion>*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <!-- Front End MetaData -->
+ <em:name>Mobile killer</em:name>
+ <em:description>Allow cfx to automatically kill firefox.</em:description>
+ <em:creator>Mozilla Corporation</em:creator>
+
+ </Description>
+</RDF>