1
/* Chromium Unity integration extension
3
* Copyright 2012 Canonical Ltd.
5
* This program is free software: you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 3, as published
7
* by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
// this is meant to be removed once we settle on a common infrastructure for
19
// FF & chromium for implementation specific things (e.g. TLD, logs, imports, ...)
23
import: function (resource) {
24
if ( ! resource || ! typeof (resource) === 'string') {
28
var resourceQualifier = 'resource://';
30
if (resource.indexOf (resourceQualifier) == -1) {
34
// very hacky, we don't have the same structure as FF (should)
35
// so we dont consider paths
36
var idx = resource.lastIndexOf ('/');
41
var getResourceContent = function (resourcename) {
43
var xhr = new XMLHttpRequest();
45
xhr.onreadystatechange = function() {
46
if (xhr.readyState == 4) {
47
content = xhr.responseText;
51
xhr.open("GET", resourcename, false);
53
try { xhr.send(); } catch(e) { }
58
var content = getResourceContent (chrome.runtime.getURL (resource.slice (idx+1)));
61
&& typeof (content) === 'string'
62
&& 0 != content.length) {
66
eval.call (window, content);
70
console.log ('Components.utils.import: ' + String(e));
78
/*var consoleService = {
79
logStringMessage: function (msg) {
80
if (settings && settings.logging) {