Skip to content

Commit

Permalink
Hide Incognito DIV on incompatibility
Browse files Browse the repository at this point in the history
Also only run chrome.extension.isAllowedIncognitoAccess() if compatibility check is passed.
  • Loading branch information
rentamob authored Jun 18, 2016
1 parent f3c124f commit 99dcff6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ function displayContent(){
var divNew = document.getElementById('new');
var divLegacy = document.getElementById('legacy');
var divFail = document.getElementById('fail');
var divIncognito = document.getElementById('incognito');
var divApply = document.getElementById('applyButton');

if(getMajorVerison() > 47){
divLegacy.style.display = 'none';
divFail.style.display = 'none';
chrome.extension.isAllowedIncognitoAccess();
}
else if(getMajorVerison() > 41 && getMajorVerison() < 48){
divNew.style.display = 'none';
divFail.style.display = 'none';
chrome.extension.isAllowedIncognitoAccess();
}
else{
divContent.style.display = 'none';
divIncognito.style.display = 'none';
divApply.style.display = 'none';
}
}
Expand All @@ -36,7 +40,7 @@ chrome.extension.isAllowedIncognitoAccess(function(isAllowedAccess){
}
});

function save_options(){
function saveOptions(){
if(getMajorVerison() > 47){
var policy = document.getElementById('policy').value;
chrome.storage.local.set({
Expand Down Expand Up @@ -82,7 +86,7 @@ function save_options(){
}
}

function restore_options(){
function restoreOptions(){
if(getMajorVerison() > 47){
chrome.storage.local.get({
rtcIPHandling: 'default_public_interface_only'
Expand All @@ -102,6 +106,5 @@ function restore_options(){
}

document.addEventListener('DOMContentLoaded', displayContent);
document.addEventListener('DOMContentLoaded', restore_options);
document.addEventListener('DOMContentLoaded', chrome.extension.isAllowedIncognitoAccess);
document.getElementById('save').addEventListener('click', save_options);
document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('save').addEventListener('click', saveOptions);

0 comments on commit 99dcff6

Please sign in to comment.