1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-20 16:07:45 +01:00

collect for notification bar inside iframes

This commit is contained in:
Kyle Spearrin 2017-10-05 23:27:32 -04:00
parent e5140595e6
commit f852cbbfe3
2 changed files with 21 additions and 2 deletions

View File

@ -4,7 +4,8 @@
barType = null, barType = null,
pageHref = null, pageHref = null,
observer = null, observer = null,
domObservationCollectTimeout = null; domObservationCollectTimeout = null,
iframed = isIframed();
if (window.location.hostname.indexOf('bitwarden.com') === -1) { if (window.location.hostname.indexOf('bitwarden.com') === -1) {
chrome.storage.local.get('neverDomains', function (obj) { chrome.storage.local.get('neverDomains', function (obj) {
@ -23,16 +24,25 @@
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.command === 'openNotificationBar') { if (msg.command === 'openNotificationBar') {
if (iframed) {
return;
}
closeExistingAndOpenBar(msg.data.type, msg.data.typeData); closeExistingAndOpenBar(msg.data.type, msg.data.typeData);
sendResponse(); sendResponse();
return true; return true;
} }
else if (msg.command === 'closeNotificationBar') { else if (msg.command === 'closeNotificationBar') {
if (iframed) {
return;
}
closeBar(true); closeBar(true);
sendResponse(); sendResponse();
return true; return true;
} }
else if (msg.command === 'adjustNotificationBar') { else if (msg.command === 'adjustNotificationBar') {
if (iframed) {
return;
}
adjustBar(msg.data); adjustBar(msg.data);
sendResponse(); sendResponse();
return true; return true;
@ -45,6 +55,15 @@
} }
}); });
function isIframed() {
try {
return window.self !== window.top;
}
catch (e) {
return true;
}
}
function observeDom() { function observeDom() {
var bodies = document.querySelectorAll('body'); var bodies = document.querySelectorAll('body');
if (bodies.length > 0) { if (bodies.length > 0) {

View File

@ -40,7 +40,7 @@
"run_at": "document_start" "run_at": "document_start"
}, },
{ {
"all_frames": false, "all_frames": true,
"js": [ "js": [
"content/notificationBar.js" "content/notificationBar.js"
], ],