mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 760402 - Map debugger preference to mozSettings. r=fabrice
--HG-- extra : rebase_source : 61783ea299853396eea461b79dd5766da5e39217
This commit is contained in:
parent
3f61927d18
commit
3fccc2d637
93
b2g/chrome/content/settings.js
Normal file
93
b2g/chrome/content/settings.js
Normal file
@ -0,0 +1,93 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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;"
|
||||
|
||||
// Once Bug 731746 - Allow chrome JS object to implement nsIDOMEventTarget
|
||||
// is resolved this helper could be removed.
|
||||
var SettingsListener = {
|
||||
_callbacks: {},
|
||||
|
||||
init: function sl_init() {
|
||||
if ('mozSettings' in navigator && navigator.mozSettings) {
|
||||
navigator.mozSettings.onsettingchange = this.onchange.bind(this);
|
||||
}
|
||||
},
|
||||
|
||||
onchange: function sl_onchange(evt) {
|
||||
var callback = this._callbacks[evt.settingName];
|
||||
if (callback) {
|
||||
callback(evt.settingValue);
|
||||
}
|
||||
},
|
||||
|
||||
observe: function sl_observe(name, defaultValue, callback) {
|
||||
var settings = window.navigator.mozSettings;
|
||||
if (!settings) {
|
||||
window.setTimeout(function() { callback(defaultValue); });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!callback || typeof callback !== 'function') {
|
||||
throw new Error('Callback is not a function');
|
||||
}
|
||||
|
||||
var req = settings.getLock().get(name);
|
||||
req.addEventListener('success', (function onsuccess() {
|
||||
callback(typeof(req.result[name]) != 'undefined' ?
|
||||
req.result[name] : defaultValue);
|
||||
}));
|
||||
|
||||
this._callbacks[name] = callback;
|
||||
}
|
||||
};
|
||||
|
||||
SettingsListener.init();
|
||||
|
||||
|
||||
// =================== Languages ====================
|
||||
SettingsListener.observe('language.current', 'en-US', function(value) {
|
||||
Services.prefs.setCharPref('intl.accept_languages', value);
|
||||
});
|
||||
|
||||
|
||||
// =================== RIL ====================
|
||||
(function RILSettingsToPrefs() {
|
||||
['ril.data.enabled', 'ril.data.roaming.enabled'].forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setBoolPref(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
let strPrefs = ['ril.data.apn', 'ril.data.user', 'ril.data.passwd',
|
||||
'ril.data.mmsc', 'ril.data.mmsproxy'];
|
||||
strPrefs.forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setCharPref(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
['ril.data.mmsport'].forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setIntPref(key, value);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
// =================== Debugger ====================
|
||||
SettingsListener.observe('devtools.debugger.enabled', false, function(enabled) {
|
||||
Services.prefs.setBoolPref('devtools.debugger.enabled', value);
|
||||
});
|
||||
|
||||
SettingsListener.observe('devtools.debugger.log', false, function(value) {
|
||||
Services.prefs.setBoolPref('devtools.debugger.log', value);
|
||||
});
|
||||
|
||||
SettingsListener.observe('devtools.debugger.port', 6000, function(value) {
|
||||
Services.prefs.setIntPref('devtools.debugger.port', value);
|
||||
});
|
||||
|
@ -528,52 +528,6 @@ window.addEventListener('ContentStart', function(evt) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Once Bug 731746 - Allow chrome JS object to implement nsIDOMEventTarget
|
||||
// is resolved this helper could be removed.
|
||||
var SettingsListener = {
|
||||
_callbacks: {},
|
||||
|
||||
init: function sl_init() {
|
||||
if ('mozSettings' in navigator && navigator.mozSettings)
|
||||
navigator.mozSettings.onsettingchange = this.onchange.bind(this);
|
||||
},
|
||||
|
||||
onchange: function sl_onchange(evt) {
|
||||
var callback = this._callbacks[evt.settingName];
|
||||
if (callback) {
|
||||
callback(evt.settingValue);
|
||||
}
|
||||
},
|
||||
|
||||
observe: function sl_observe(name, defaultValue, callback) {
|
||||
var settings = window.navigator.mozSettings;
|
||||
if (!settings) {
|
||||
window.setTimeout(function() { callback(defaultValue); });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!callback || typeof callback !== 'function') {
|
||||
throw new Error('Callback is not a function');
|
||||
}
|
||||
|
||||
var req = settings.getLock().get(name);
|
||||
req.addEventListener('success', (function onsuccess() {
|
||||
callback(typeof(req.result[name]) != 'undefined' ?
|
||||
req.result[name] : defaultValue);
|
||||
}));
|
||||
|
||||
this._callbacks[name] = callback;
|
||||
}
|
||||
};
|
||||
|
||||
SettingsListener.init();
|
||||
|
||||
SettingsListener.observe('language.current', 'en-US', function(value) {
|
||||
Services.prefs.setCharPref('intl.accept_languages', value);
|
||||
});
|
||||
|
||||
|
||||
(function PowerManager() {
|
||||
// This will eventually be moved to content, so use content API as
|
||||
// much as possible here. TODO: Bug 738530
|
||||
@ -644,26 +598,3 @@ SettingsListener.observe('language.current', 'en-US', function(value) {
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
(function RILSettingsToPrefs() {
|
||||
['ril.data.enabled', 'ril.data.roaming.enabled'].forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setBoolPref(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
let strPrefs = ['ril.data.apn', 'ril.data.user', 'ril.data.passwd',
|
||||
'ril.data.mmsc', 'ril.data.mmsproxy'];
|
||||
strPrefs.forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setCharPref(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
['ril.data.mmsport'].forEach(function(key) {
|
||||
SettingsListener.observe(key, false, function(value) {
|
||||
Services.prefs.setIntPref(key, value);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
onload="shell.start();"
|
||||
onunload="shell.stop();">
|
||||
|
||||
<script type="application/javascript" src="chrome://browser/content/settings.js"/>
|
||||
<script type="application/javascript" src="chrome://browser/content/shell.js"/>
|
||||
|
||||
#ifndef ANDROID
|
||||
<!-- this script handles the screen argument for desktop builds -->
|
||||
<script type="application/javascript" src="chrome://browser/content/screen.js"/>
|
||||
|
@ -9,6 +9,7 @@ chrome.jar:
|
||||
% content browser %content/
|
||||
|
||||
content/dbg-browser-actors.js (content/dbg-browser-actors.js)
|
||||
content/settings.js (content/settings.js)
|
||||
* content/shell.xul (content/shell.xul)
|
||||
* content/shell.js (content/shell.js)
|
||||
#ifndef ANDROID
|
||||
|
Loading…
Reference in New Issue
Block a user