|
1 |
|
2 var Cc = Components.classes; |
|
3 var Ci = Components.interfaces; |
|
4 var Cu = Components.utils; |
|
5 |
|
6 Cu.import("resource://gre/modules/Services.jsm"); |
|
7 |
|
8 function loadIntoWindow(window) {} |
|
9 function unloadFromWindow(window) {} |
|
10 |
|
11 function _sendMessageToJava (aMsg) { |
|
12 return Services.androidBridge.handleGeckoMessage(aMsg); |
|
13 }; |
|
14 |
|
15 /* |
|
16 bootstrap.js API |
|
17 */ |
|
18 var windowListener = { |
|
19 onOpenWindow: function(aWindow) { |
|
20 // Wait for the window to finish loading |
|
21 let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow); |
|
22 domWindow.addEventListener("load", function() { |
|
23 domWindow.removeEventListener("load", arguments.callee, false); |
|
24 if (domWindow) { |
|
25 domWindow.addEventListener("scroll", function(e) { |
|
26 let message = { |
|
27 type: 'robocop:scroll', |
|
28 y: XPCNativeWrapper.unwrap(e.target).documentElement.scrollTop, |
|
29 height: XPCNativeWrapper.unwrap(e.target).documentElement.scrollHeight, |
|
30 cheight: XPCNativeWrapper.unwrap(e.target).documentElement.clientHeight, |
|
31 }; |
|
32 let retVal = _sendMessageToJava(message); |
|
33 }); |
|
34 } |
|
35 }, false); |
|
36 }, |
|
37 onCloseWindow: function(aWindow) { }, |
|
38 onWindowTitleChange: function(aWindow, aTitle) { } |
|
39 }; |
|
40 |
|
41 function startup(aData, aReason) { |
|
42 let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); |
|
43 |
|
44 // Load into any new windows |
|
45 wm.addListener(windowListener); |
|
46 Services.obs.addObserver(function observe(aSubject, aTopic, aData) { |
|
47 dump("Robocop:Quit received -- requesting quit"); |
|
48 let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); |
|
49 appStartup.quit(Ci.nsIAppStartup.eForceQuit); |
|
50 }, "Robocop:Quit", false); |
|
51 } |
|
52 |
|
53 function shutdown(aData, aReason) { |
|
54 // When the application is shutting down we normally don't have to clean up any UI changes |
|
55 if (aReason == APP_SHUTDOWN) return; |
|
56 |
|
57 let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); |
|
58 |
|
59 // Stop watching for new windows |
|
60 wm.removeListener(windowListener); |
|
61 } |
|
62 |
|
63 function install(aData, aReason) { } |
|
64 function uninstall(aData, aReason) { } |
|
65 |