b2g/chrome/content/desktop.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // Enable touch event shim on desktop that translates mouse events
michael@0 6 // into touch ones
michael@0 7 function enableTouch() {
michael@0 8 let require = Cu.import('resource://gre/modules/devtools/Loader.jsm', {})
michael@0 9 .devtools.require;
michael@0 10 let { TouchEventHandler } = require('devtools/touch-events');
michael@0 11 let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 12 .getInterface(Ci.nsIWebNavigation)
michael@0 13 .QueryInterface(Ci.nsIDocShell)
michael@0 14 .chromeEventHandler || window;
michael@0 15 let touchEventHandler = new TouchEventHandler(chromeEventHandler);
michael@0 16 touchEventHandler.start();
michael@0 17 }
michael@0 18
michael@0 19 function setupButtons() {
michael@0 20 let homeButton = document.getElementById('home-button');
michael@0 21 if (!homeButton) {
michael@0 22 // The toolbar only exists in b2g desktop build with
michael@0 23 // FXOS_SIMULATOR turned on.
michael@0 24 return;
michael@0 25 }
michael@0 26 // The touch event helper is enabled on shell.html document,
michael@0 27 // so that click events are delayed and it is better to
michael@0 28 // listen for touch events.
michael@0 29 homeButton.addEventListener('touchstart', function() {
michael@0 30 shell.sendChromeEvent({type: 'home-button-press'});
michael@0 31 homeButton.classList.add('active');
michael@0 32 });
michael@0 33 homeButton.addEventListener('touchend', function() {
michael@0 34 shell.sendChromeEvent({type: 'home-button-release'});
michael@0 35 homeButton.classList.remove('active');
michael@0 36 });
michael@0 37
michael@0 38 Cu.import("resource://gre/modules/GlobalSimulatorScreen.jsm");
michael@0 39 let rotateButton = document.getElementById('rotate-button');
michael@0 40 rotateButton.addEventListener('touchstart', function () {
michael@0 41 rotateButton.classList.add('active');
michael@0 42 });
michael@0 43 rotateButton.addEventListener('touchend', function() {
michael@0 44 GlobalSimulatorScreen.flipScreen();
michael@0 45 rotateButton.classList.remove('active');
michael@0 46 });
michael@0 47 }
michael@0 48
michael@0 49 function checkDebuggerPort() {
michael@0 50 // XXX: To be removed once bug 942756 lands.
michael@0 51 // We are hacking 'unix-domain-socket' pref by setting a tcp port (number).
michael@0 52 // DebuggerServer.openListener detects that it isn't a file path (string),
michael@0 53 // and starts listening on the tcp port given here as command line argument.
michael@0 54
michael@0 55 if (!window.arguments) {
michael@0 56 return;
michael@0 57 }
michael@0 58
michael@0 59 // Get the command line arguments that were passed to the b2g client
michael@0 60 let args = window.arguments[0].QueryInterface(Ci.nsICommandLine);
michael@0 61
michael@0 62 let dbgport;
michael@0 63 try {
michael@0 64 dbgport = args.handleFlagWithParam('start-debugger-server', false);
michael@0 65 } catch(e) {}
michael@0 66
michael@0 67 if (dbgport) {
michael@0 68 dump('Opening debugger server on ' + dbgport + '\n');
michael@0 69 Services.prefs.setCharPref('devtools.debugger.unix-domain-socket', dbgport);
michael@0 70 navigator.mozSettings.createLock().set(
michael@0 71 {'debugger.remote-mode': 'adb-devtools'});
michael@0 72 }
michael@0 73 }
michael@0 74
michael@0 75 window.addEventListener('ContentStart', function() {
michael@0 76 enableTouch();
michael@0 77 setupButtons();
michael@0 78 checkDebuggerPort();
michael@0 79 });

mercurial