Skip to content

Instantly share code, notes, and snippets.

@schien
Created November 6, 2015 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schien/c2607b6e4a68d76f51a8 to your computer and use it in GitHub Desktop.
Save schien/c2607b6e4a68d76f51a8 to your computer and use it in GitHub Desktop.
# HG changeset patch
# User Shih-Chiang Chien <schien@mozilla.com>
# Parent cc48981c026c50fdf80d47b040ae1fb8fe99ad07
diff --git a/b2g/chrome/content/remote_control.js b/b2g/chrome/content/remote_control.js
new file mode 100644
--- /dev/null
+++ b/b2g/chrome/content/remote_control.js
@@ -0,0 +1,35 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+/* 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";
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+const kPrefRemoteControlEnable = "remotecontrol.service.enabled";
+
+(function setupRemoteControlSettings() {
+ // To keep RemoteContorlService in the scope to prevent import again
+ var remoteControlScope = {};
+
+ function importRemoteControlService() {
+ if (!("RemoteControlService" in remoteControlScope)) {
+ Cu.import("resource://gre/modules/RemoteControlService.jsm", remoteControlScope);
+ }
+ }
+
+ function setupRemoteContol() {
+ if (Services.prefs.getBoolPref(kPrefRemoteControlEnable)) {
+ importRemoteControlService();
+ remoteControlScope.RemoteControlService.start();
+ } else {
+ remoteControlScope.RemoteControlService.stop();
+ }
+ }
+
+ Services.prefs.addObserver(kPrefRemoteControlEnable, setupRemoteControl, false);
+
+ setupRemoteContol();
+})();
diff --git a/b2g/chrome/content/settings.js b/b2g/chrome/content/settings.js
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -675,16 +675,24 @@ var settingsToObserve = {
// Restart required
'layers.async-pan-zoom.enabled': false,
#endif
'layout.display-list.dump': false,
'mms.debugging.enabled': false,
'network.debugging.enabled': false,
'privacy.donottrackheader.enabled': false,
'privacy.trackingprotection.enabled': false,
+ 'remote-control.enabled': {
+ prefName: 'remotecontrol.service.enabled',
+ resetToPref: true
+ },
+ 'remote-control.pairing-required': {
+ prefName: 'remotecontrol.service.pairing_required',
+ resetToPref: true
+ },
'ril.debugging.enabled': false,
'ril.radio.disabled': false,
'ril.mms.requestReadReport.enabled': {
prefName: 'dom.mms.requestReadReport',
defaultValue: true
},
'ril.mms.requestStatusReport.enabled': {
prefName: 'dom.mms.requestStatusReport',
diff --git a/b2g/chrome/content/shell.html b/b2g/chrome/content/shell.html
--- a/b2g/chrome/content/shell.html
+++ b/b2g/chrome/content/shell.html
@@ -45,16 +45,20 @@
#else
<!-- this file is only loaded on Gonk to manage ADB state -->
<script type="application/javascript;version=1.8"
src="chrome://b2g/content/devtools/adb.js"> </script>
#endif
<!-- manages DevTools server state -->
<script type="application/javascript;version=1.8"
src="chrome://b2g/content/devtools/debugger.js"> </script>
+
+ <!-- this script handles remote control service -->
+ <script type="application/javascript;version=1.8"
+ src="chrome://b2g/content/remote_control.js"> </script>
</head>
<body id="container">
#ifdef FXOS_SIMULATOR
#ifndef MOZ_MULET
<!--
Some additional buttons are displayed on desktop to fake hardware buttons.
-->
<footer id="controls">
diff --git a/b2g/chrome/jar.mn b/b2g/chrome/jar.mn
--- a/b2g/chrome/jar.mn
+++ b/b2g/chrome/jar.mn
@@ -33,16 +33,18 @@ chrome.jar:
content/screen.js (content/screen.js)
content/runapp.js (content/runapp.js)
#endif
* content/content.css (content/content.css)
content/touchcontrols.css (content/touchcontrols.css)
content/identity.js (content/identity.js)
+ content/remote_control.js (content/remote_control.js)
+
#ifndef MOZ_GRAPHENE
% override chrome://global/skin/media/videocontrols.css chrome://b2g/content/touchcontrols.css
#endif
% override chrome://global/content/aboutCertError.xhtml chrome://b2g/content/aboutCertError.xhtml
% override chrome://global/skin/netError.css chrome://b2g/content/netError.css
content/ErrorPage.js (content/ErrorPage.js)
content/aboutCertError.xhtml (content/aboutCertError.xhtml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment