Working towards opt-in for continuous upload

This commit is contained in:
dethe 2013-04-16 17:25:48 -07:00
Родитель 116e9d5e4f
Коммит ad879fbc00
2 изменённых файлов: 54 добавлений и 4 удалений

Просмотреть файл

@ -85,10 +85,39 @@ document.querySelector('.reset-data').addEventListener('click', function(){
// FIXME: empty the data from current view too
});
document.querySelector('.upload').addEventListener('click', function(){
addon.emit('upload');
var uploadButton = document.querySelector('.upload');
if (localStorage.userHasOptedIntoSharing){
uploadButton.innerHTML = 'Stop Sharing';
}
uploadButton.addEventListener('click', function(){
if (localStorage.userHasOptedIntoSharing){
stopSharing();
}else{
startSharing();
}
});
function stopSharing(){
if (confirm('You are about to stop sharing data with the Mozilla Collusion server.\n\n' +
'By clicking Okay you will no longer be uploading data.')){
addon.emit('stopUpload');
uploadButton.innerHTML = 'Share Data';
localStorage.userHasOptedIntoSharing = false;
}
}
function startSharing(){
if (confirm('You are about to start uploading anonymized data to the Mozilla Collusion server. ' +
'Your data will continue to be uploaded periodically until you turn off sharing. ' +
'For more information about the data we upload, how it is anonymized, and what Mozilla\'s ' +
'privacy policies are, please visit http://ItsOurData.com/privacy/.\n\nBy clicking Okay ' +
'you are agreeing to share your data under those terms.')){
addon.emit('startUpload');
uploadButton.innerHTML = 'Stop Sharing';
localStorage.userHasOptedIntoSharing = true;
}
}
function getZoom(canvas){
// TODO: code cleanup if both cases use basically the same code
switch(canvas){
@ -258,7 +287,7 @@ document.querySelector(".settings").addEventListener("click", function(event){
document.querySelector(".list-breadcrumb").classList.toggle("hide");
document.querySelector(".list-header").classList.toggle("hide");
document.querySelector(".list-table").classList.toggle("hide");
}
var infoBarVisible = document.querySelector("#content").classList.contains("showinfo");
if ( infoBarVisible ){

Просмотреть файл

@ -6,6 +6,7 @@ var {
Cc, Ci, Cr
} = require('chrome');
const Request = require('sdk/request').Request;
var timers = require('sdk/timers');
var eTLDSvc = Cc["@mozilla.org/network/effective-tld-service;1"].
getService(Ci.nsIEffectiveTLDService);
@ -351,10 +352,30 @@ Connection.upload = function(){
}
});
request.post();
uploadTimer = timers.setTimeout(Connection.upload, 10 * 60 * 1000); // upload every 10 minutes
}
Connection.on('upload', Connection.upload);
var uploadTimer;
Connection.startUpload = function(){
storage.userHasOptedIntoSharing = true;
Connection.upload();
};
Connection.stopUpload = function(){
storage.userHasOptedIntoSharing = false;
if (uploadTimer){
timers.clearTimeout(uploadTimer);
uploadTimer = null;
}
};
Connection.on('startUpload', Connection.startUpload);
Connection.on('stopUpload', Connection.stopUpload);
Connection.on('reset', reset);
if (storage.userHasOptedIntoSharing){
Connection.startUpload();
}
function exportFormat(connections, lastSync){