Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
59
assets/webapps/system.gaiamobile.org/js/browser_settings.js
Normal file
59
assets/webapps/system.gaiamobile.org/js/browser_settings.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* global Service, LazyLoader, IconsHelper */
|
||||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
function BrowserSettings() {
|
||||
}
|
||||
|
||||
// Use a setting in order to be "called" by settings app
|
||||
BrowserSettings.prototype.addRemoteRequestSetting =
|
||||
function(key, requestFunction) {
|
||||
function observer(setting) {
|
||||
var isRequested = setting.settingValue;
|
||||
if (!isRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
requestFunction();
|
||||
|
||||
// Reset the setting value to false
|
||||
var lock = navigator.mozSettings.createLock();
|
||||
var falseSetting = {};
|
||||
falseSetting[key] = false;
|
||||
lock.set(falseSetting);
|
||||
}
|
||||
|
||||
navigator.mozSettings.addObserver(key, observer);
|
||||
|
||||
var getRequest = navigator.mozSettings.createLock().get(key);
|
||||
getRequest.onsuccess = function() {
|
||||
observer({settingName: key, settingValue: getRequest.result[key]});
|
||||
};
|
||||
};
|
||||
|
||||
BrowserSettings.prototype.start = function() {
|
||||
this.addRemoteRequestSetting(
|
||||
'clear.browser.history',
|
||||
function clearHistory() {
|
||||
Service.request('Places:clearHistory');
|
||||
}
|
||||
);
|
||||
|
||||
this.addRemoteRequestSetting(
|
||||
'clear.browser.private-data',
|
||||
function clearPrivateData() {
|
||||
var request = navigator.mozApps.getSelf();
|
||||
request.onsuccess = function() {
|
||||
request.result.clearBrowserData();
|
||||
};
|
||||
|
||||
// Clear the icon dataStore.
|
||||
LazyLoader.load('shared/js/icons_helper.js').then(() => {
|
||||
IconsHelper.clear();
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.BrowserSettings = BrowserSettings;
|
||||
})(window);
|
||||
Loading…
Reference in a new issue