-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for backbone apps defined into iframes #24
- Loading branch information
Showing
14 changed files
with
212 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
// Receives messages from the inspected page and redirects them to the background, | ||
var frameURL = window.location.href; | ||
var isTopFrame = (window.parent == window); | ||
|
||
// Receives messages from the inspected page frame and redirects them to the background, | ||
// building up the first step towards the communication between the backbone agent and the panel. | ||
window.addEventListener("message", function(event) { | ||
// We only accept messages from ourselves | ||
// Only accept messages from same frame | ||
if (event.source != window) return; | ||
|
||
var message = event.data; | ||
|
||
// Only accept our messages | ||
if (typeof message != 'object' || message === null || message.target != 'page') return; | ||
|
||
message.frameURL = frameURL; | ||
chrome.extension.sendMessage(message); | ||
}, false); | ||
|
||
// Sends a message to the background when the DOM of the inspected page is ready | ||
// (typically used by the panel to check if the backbone agent is on the page). | ||
window.addEventListener('DOMContentLoaded', function() { | ||
chrome.extension.sendMessage({ | ||
target: 'page', | ||
name: 'ready' | ||
}); | ||
}, false); | ||
if (isTopFrame) { | ||
/* Code to be executed only if this is the top frame content script! */ | ||
|
||
// Sends a message to the background when the DOM of the inspected page is ready | ||
// (typically used by the panel to check if the backbone agent is on the page). | ||
window.addEventListener('DOMContentLoaded', function() { | ||
chrome.extension.sendMessage({ | ||
target: 'page', | ||
name: 'ready' | ||
}); | ||
}, false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.