Skip to content

Commit

Permalink
Change how quickly icon is displayed in URL bar
Browse files Browse the repository at this point in the history
  • Loading branch information
april committed Aug 2, 2018
1 parent 25a5170 commit edd7dbb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/background/consumer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as icon from './icon';
import * as state from './state';

// state can only be downgraded, not upgraded
Expand Down Expand Up @@ -42,12 +43,17 @@ export const consume = async details => {
// tabState[tid].si = securityInfo;
state.set(tid, securityInfo);
}

return;
}

// update document state depending on various conditions
if (documentUrl.protocol === 'https:' && url.protocol === 'http:') { // mixed content
state.set(tid, getWorseState(tid, 'broken'));
} else if (url.protocol === 'http:') { // plain HTTP
state.set(tid, getWorseState(tid, 'http'));
icon.update(tid, state.set(tid, getWorseState(tid, 'broken')));
}

// this isn't needed for now, simply because the manifest hides the extension from HTTP only pages
// else if (url.protocol === 'http:') { // plain HTTP
// icon.update(tid, state.set(tid, getWorseState(tid, 'http')));
// }
};
6 changes: 2 additions & 4 deletions src/background/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ browser.runtime.onInstalled.addListener(async () => {
// update the icon when a navigation is complete
browser.webNavigation.onCompleted.addListener(
details => {
if (details.parentFrameId === -1) {
icon.update(details.tabId, state.get(details.tabId).state);
}
icon.update(details.tabId, state.get(details.tabId).state);
},
{ url: [{ schemes: ['http', 'https'] }] }
{ url: [{ schemes: ['https'] }] }
);

// open the certificate viewer
Expand Down
2 changes: 2 additions & 0 deletions src/background/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ export const update = async (tid, state) => {
});

browser.pageAction.show(tid);
} else {
browser.pageAction.hide(tid);
}
};
2 changes: 2 additions & 0 deletions src/background/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ export const set = (tid, state) => {
} else if (typeof state === 'object') { // setting security info
_state[tid] = state;
}

return state;
};
5 changes: 3 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Certainly Something (Certificate Viewer)",
"short_name": "Certainly Something",
"version": "1.0.2",
"version": "1.0.3",

"description": "Certainly Something is an advanced digital certificate viewer with an easy to use interface.",
"homepage_url": "https://github.com/april/certainly-something",
Expand Down Expand Up @@ -32,7 +32,8 @@
"page_action": {
"browser_style": true,
"default_icon": "icons/secure.svg",
"default_title": "Certainly Something (Certificate Viewer)"
"default_title": "Certainly Something (Certificate Viewer)",
"show_matches": ["https://*/*"]
},

"permissions": [
Expand Down

0 comments on commit edd7dbb

Please sign in to comment.