mirror of
https://github.com/tlsnotary/PageSigner.git
synced 2026-01-10 07:07:57 -05:00
generate chrome popup dynamically. Show how to enable file access
This commit is contained in:
@@ -4,6 +4,7 @@ var appId = "oclohfdjoojomkfddjclanpogcnjhemd"; //id of the helper app
|
||||
var is_chrome = true;
|
||||
var fsRootPath; //path to local storage root, e.g. filesystem:chrome-extension://abcdabcd/persistent
|
||||
var manager_path; //manager.html which was copied into Downloads/ dir
|
||||
var notarization_in_progress = false;
|
||||
|
||||
function getPref(pref, type){
|
||||
return new Promise(function(resolve, reject) {
|
||||
@@ -128,13 +129,13 @@ function getHeaders(){
|
||||
|
||||
function loadBusyIcon(){
|
||||
chrome.browserAction.setIcon({path:"content/icon_spin.gif"});
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup_pleasewait.html"});
|
||||
notarization_in_progress = true;
|
||||
}
|
||||
|
||||
|
||||
function loadNormalIcon(){
|
||||
chrome.browserAction.setIcon({path:"icon.png"});
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup.html"});
|
||||
notarization_in_progress = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,25 +245,45 @@ function browser_specific_init(){
|
||||
else if (data.message === 'openInstallLink'){
|
||||
chrome.tabs.create({url:'https://chrome.google.com/webstore/detail/pagesigner-helper-app/oclohfdjoojomkfddjclanpogcnjhemd'});
|
||||
}
|
||||
});
|
||||
chrome.management.get(appId, function(a){
|
||||
if (typeof(a) === "undefined"){
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup_installapp.html"});
|
||||
else if (data.message === 'openChromeExtensions'){
|
||||
chrome.tabs.query({url:'chrome://extensions/*'}, function(tabs){
|
||||
if (tabs.length === 0){
|
||||
chrome.tabs.create({url:'chrome://extensions'});
|
||||
return;
|
||||
}
|
||||
chrome.tabs.update(tabs[0].id, {active:true});
|
||||
});
|
||||
}
|
||||
else {
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup.html"});
|
||||
else if (data.message === 'popup active'){
|
||||
if (notarization_in_progress){
|
||||
chrome.runtime.sendMessage({'destination':'popup',
|
||||
'message':'notarization_in_progress'});
|
||||
return;
|
||||
}
|
||||
chrome.extension.isAllowedFileSchemeAccess(function(bool){
|
||||
if (bool === false){
|
||||
chrome.runtime.sendMessage({'destination':'popup',
|
||||
'message':'file_access_disabled'});
|
||||
return;
|
||||
}
|
||||
chrome.management.get(appId, function(info){
|
||||
if (! info){
|
||||
chrome.runtime.sendMessage({'destination':'popup',
|
||||
'message':'app_not_installed'});
|
||||
return;
|
||||
}
|
||||
if (info.enabled === false){
|
||||
chrome.runtime.sendMessage({'destination':'popup',
|
||||
'message':'app_disabled'});
|
||||
return;
|
||||
}
|
||||
chrome.runtime.sendMessage({'destination':'popup',
|
||||
'message':'show_menu'});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chrome.management.onEnabled.addListener(function(app){
|
||||
if (app.id !== appId) return;
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup.html"});
|
||||
});
|
||||
chrome.management.onDisabled.addListener(function(app){
|
||||
if (app.id !== appId) return;
|
||||
chrome.browserAction.setPopup({popup:"content/chrome/popup_installapp.html"});
|
||||
});
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ td{
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
img {
|
||||
.menu_img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding-right: 8px;
|
||||
@@ -44,22 +44,30 @@ img {
|
||||
|
||||
<body>
|
||||
|
||||
<table style="width:100%">
|
||||
<table style="width:100%" id='menu' hidden>
|
||||
<tr class="border_bottom">
|
||||
<td id="notarize"><img src="../../icon.png"></img>Notarize this page</td>
|
||||
<td id="notarize"><img class='menu_img' src="../../icon.png"></img>Notarize this page</td>
|
||||
</tr>
|
||||
<tr class="border_bottom">
|
||||
<td id="manage"><img src="../manage.png"></img>Manage files</td>
|
||||
<td id="manage"><img class='menu_img' src="../manage.png"></img>Manage files</td>
|
||||
</tr>
|
||||
<tr class="border_bottom">
|
||||
<td id="import"><img src="../verify.png"></img>Import .pgsg file</td>
|
||||
<td id="import"><img class='menu_img' src="../verify.png"></img>Import .pgsg file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="about"><img src="../../icon.png"></img>About</td>
|
||||
<td id="about"><img class='menu_img' src="../../icon.png"></img>About</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a href="https://chrome.google.com/webstore/detail/pagesigner-helper-app/oclohfdjoojomkfddjclanpogcnjhemd" id="app_not_installed" hidden><h1>Click here to install the helper app needed for PageSigner to work</h1></a>
|
||||
|
||||
<a href="chrome://extensions" id="app_disabled" hidden><h1>Click here and then enable PageSigner helper app</h1></a>
|
||||
|
||||
<div id='enable_file_access' hidden>
|
||||
<img src="../enable_file_access.png"><a href="chrome://extensions"><h1>Click here and then enable the checkbox marked in the image above</h1></a></img>
|
||||
</div>
|
||||
|
||||
<h1 id='notarization_in_progress' hidden>Notarization in progress. Please wait...</h1>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
chrome.runtime.sendMessage({'destination':'extension',
|
||||
'message':'popup active'});
|
||||
|
||||
chrome.runtime.onMessage.addListener(function(data){
|
||||
if (data.destination !== 'popup') return;
|
||||
if (data.message === 'file_access_disabled'){
|
||||
document.getElementById("enable_file_access").removeAttribute('hidden');
|
||||
document.body.style.width = '100%';
|
||||
}
|
||||
else if (data.message === 'app_not_installed'){
|
||||
document.getElementById("app_not_installed").removeAttribute('hidden');
|
||||
}
|
||||
else if (data.message === 'app_disabled'){
|
||||
document.getElementById("app_disabled").removeAttribute('hidden');
|
||||
}
|
||||
else if (data.message === 'show_menu'){
|
||||
document.getElementById("menu").removeAttribute('hidden');
|
||||
}
|
||||
else if (data.message === 'notarization_in_progress'){
|
||||
document.getElementById("notarization_in_progress").removeAttribute('hidden');
|
||||
}
|
||||
else {
|
||||
console.log('popup received unexpected message ' + data.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("notarize").addEventListener("click",
|
||||
function(){
|
||||
window.close();
|
||||
@@ -31,6 +58,28 @@ document.getElementById("about").addEventListener("click",
|
||||
window.close();
|
||||
});
|
||||
|
||||
var app_not_installed = document.getElementById("app_not_installed");
|
||||
app_not_installed.addEventListener("click", function(evt){
|
||||
chrome.runtime.sendMessage({'destination':'extension',
|
||||
'message':'openInstallLink'});
|
||||
window.close();
|
||||
});
|
||||
|
||||
var app_disabled = document.getElementById("app_disabled");
|
||||
app_disabled.addEventListener("click", function(evt){
|
||||
chrome.runtime.sendMessage({'destination':'extension',
|
||||
'message':'openChromeExtensions'});
|
||||
window.close();
|
||||
});
|
||||
|
||||
var enable_file_access = document.getElementById("enable_file_access");
|
||||
enable_file_access.addEventListener("click", function(evt){
|
||||
chrome.runtime.sendMessage({'destination':'extension',
|
||||
'message':'openChromeExtensions'});
|
||||
window.close();
|
||||
});
|
||||
|
||||
|
||||
//if this file is opened in a tab during testing, it will have a hash appended to the URL
|
||||
setTimeout(function(){
|
||||
var hash = window.location.hash;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<body>
|
||||
<a href="https://chrome.google.com/webstore/detail/pagesigner-helper-app/oclohfdjoojomkfddjclanpogcnjhemd" id="link">Click here to install the helper app needed for PageSigner to work</a><
|
||||
|
||||
<script src="popup_installapp.js"></script>
|
||||
|
||||
</body>
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
var link = document.getElementById("link");
|
||||
link.addEventListener("click", function(evt){
|
||||
chrome.runtime.sendMessage({'destination':'extension',
|
||||
'message':'openInstallLink'});
|
||||
window.close();
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
<body>
|
||||
Notarization in progress. Please wait...
|
||||
</body>
|
||||
BIN
content/enable_file_access.png
Normal file
BIN
content/enable_file_access.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
Reference in New Issue
Block a user