I'm writing a Chrome extension, and would like to be able to clean up given urls, so that I get their security origin. Using location.host seems to do the job, but it's not always usable - if I'd like to get the origin of an IFrame element, for instance, the call will be blocked.
Looking at WebKit's source, this seems like a far from trivial task. I can use either JavaScript, C++ or Chrome's API (using WebKit's code is an overkill, as it will drag another ton of files).