Skip to content

Commit

Permalink
separate getter into 2 functions to avoid race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guo-wei Shieh committed Sep 29, 2015
1 parent ced65d4 commit a4e8536
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/content/extensions/multipleroutes/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,17 @@ function restoreRadios(multiRoutes, nonProxiedUdp) {
}

// Restores checkbox states.
function restoreOptions() {
function restoreMultiRoutesOption() {
var multiRoutes = true;
var nonProxiedUdp = true;
chrome.privacy.network.webRTCMultipleRoutesEnabled.get({},
function(details) {
multiRoutes = details.value;
restoreRadios(multiRoutes, nonProxiedUdp);
restoreRadios(multiRoutes, true);
restoreNonProxiedUdpOption(multiRoutes);
});
}

function restoreNonProxiedUdpOption(multiRoutes) {
try {
chrome.privacy.network.webRTCNonProxiedUdpEnabled.get({},
function(details) {
Expand All @@ -66,6 +69,7 @@ function restoreOptions() {
document.getElementById('for_multirouteOffUdpOff_notSupported').innerHTML =
'';
} catch (err) {
console.log(err);
document.getElementById('multirouteOffUdpOff').disabled = true;
document.getElementById('multirouteOffUdpOff_Section').style.color = 'gray';
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
Expand All @@ -74,7 +78,7 @@ function restoreOptions() {
}
}

document.addEventListener('DOMContentLoaded', restoreOptions);
document.addEventListener('DOMContentLoaded', restoreMultiRoutesOption);
document.getElementById('multirouteOnUdpOn').addEventListener('click',
saveOptions);
document.getElementById('multirouteOffUdpOn').addEventListener('click',
Expand Down

0 comments on commit a4e8536

Please sign in to comment.