Bug 292789 (the chrome registry part), add a contentaccessible flag for packages and expose it on nsIXULChromeRegistry, r=dtownsend sr=jst a=beltzner
git-svn-id: svn://10.0.0.236/trunk@250056 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
87ed3dc8db
commit
e4307e4dde
@ -1136,6 +1136,40 @@ nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, PRBool *aResult)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::AllowContentToAccess(nsIURI *aURI, PRBool *aResult)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
*aResult = PR_FALSE;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
PRBool isChrome;
|
||||||
|
aURI->SchemeIs("chrome", &isChrome);
|
||||||
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowContentToAccess!");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||||
|
if (!url) {
|
||||||
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCAutoString package;
|
||||||
|
rv = url->GetHostPort(package);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
PackageEntry *entry =
|
||||||
|
static_cast<PackageEntry*>(PL_DHashTableOperate(&mPackagesHash,
|
||||||
|
& (nsACString&) package,
|
||||||
|
PL_DHASH_LOOKUP));
|
||||||
|
|
||||||
|
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
|
||||||
|
*aResult = !!(entry->flags & PackageEntry::CONTENT_ACCESSIBLE);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static PLDHashOperator
|
static PLDHashOperator
|
||||||
RemoveAll(PLDHashTable *table, PLDHashEntryHdr *entry, PRUint32 number, void *arg)
|
RemoveAll(PLDHashTable *table, PLDHashEntryHdr *entry, PRUint32 number, void *arg)
|
||||||
{
|
{
|
||||||
@ -2130,6 +2164,7 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length,
|
|||||||
|
|
||||||
NS_NAMED_LITERAL_STRING(kPlatform, "platform");
|
NS_NAMED_LITERAL_STRING(kPlatform, "platform");
|
||||||
NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
|
NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
|
||||||
|
NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
|
||||||
NS_NAMED_LITERAL_STRING(kApplication, "application");
|
NS_NAMED_LITERAL_STRING(kApplication, "application");
|
||||||
NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
|
NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
|
||||||
NS_NAMED_LITERAL_STRING(kOs, "os");
|
NS_NAMED_LITERAL_STRING(kOs, "os");
|
||||||
@ -2234,6 +2269,7 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length,
|
|||||||
|
|
||||||
PRBool platform = PR_FALSE;
|
PRBool platform = PR_FALSE;
|
||||||
PRBool xpcNativeWrappers = PR_TRUE;
|
PRBool xpcNativeWrappers = PR_TRUE;
|
||||||
|
PRBool contentAccessible = PR_FALSE;
|
||||||
TriState stAppVersion = eUnspecified;
|
TriState stAppVersion = eUnspecified;
|
||||||
TriState stApp = eUnspecified;
|
TriState stApp = eUnspecified;
|
||||||
TriState stOsVersion = eUnspecified;
|
TriState stOsVersion = eUnspecified;
|
||||||
@ -2248,6 +2284,7 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length,
|
|||||||
|
|
||||||
if (CheckFlag(kPlatform, wtoken, platform) ||
|
if (CheckFlag(kPlatform, wtoken, platform) ||
|
||||||
CheckFlag(kXPCNativeWrappers, wtoken, xpcNativeWrappers) ||
|
CheckFlag(kXPCNativeWrappers, wtoken, xpcNativeWrappers) ||
|
||||||
|
CheckFlag(kContentAccessible, wtoken, contentAccessible) ||
|
||||||
CheckStringFlag(kApplication, wtoken, appID, stApp) ||
|
CheckStringFlag(kApplication, wtoken, appID, stApp) ||
|
||||||
CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
|
CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
|
||||||
CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
|
CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
|
||||||
@ -2283,6 +2320,8 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length,
|
|||||||
entry->flags |= PackageEntry::PLATFORM_PACKAGE;
|
entry->flags |= PackageEntry::PLATFORM_PACKAGE;
|
||||||
if (xpcNativeWrappers)
|
if (xpcNativeWrappers)
|
||||||
entry->flags |= PackageEntry::XPCNATIVEWRAPPERS;
|
entry->flags |= PackageEntry::XPCNATIVEWRAPPERS;
|
||||||
|
if (contentAccessible)
|
||||||
|
entry->flags |= PackageEntry::CONTENT_ACCESSIBLE;
|
||||||
if (xpc) {
|
if (xpc) {
|
||||||
nsCAutoString urlp("chrome://");
|
nsCAutoString urlp("chrome://");
|
||||||
urlp.Append(package);
|
urlp.Append(package);
|
||||||
|
|||||||
@ -185,7 +185,10 @@ public:
|
|||||||
// This package should use the new XPCNativeWrappers to separate
|
// This package should use the new XPCNativeWrappers to separate
|
||||||
// content from chrome. This flag is currently unused (because we call
|
// content from chrome. This flag is currently unused (because we call
|
||||||
// into xpconnect at registration time).
|
// into xpconnect at registration time).
|
||||||
XPCNATIVEWRAPPERS = 1 << 1
|
XPCNATIVEWRAPPERS = 1 << 1,
|
||||||
|
|
||||||
|
// Content script may access files in this package
|
||||||
|
CONTENT_ACCESSIBLE = 1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
nsCString package;
|
nsCString package;
|
||||||
|
|||||||
4
mozilla/chrome/test/unit/data/test_bug292789.manifest
Normal file
4
mozilla/chrome/test/unit/data/test_bug292789.manifest
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
content test1 test/
|
||||||
|
content test2 test/ contentaccessible=yes
|
||||||
|
content test3 test/ contentaccessible=no
|
||||||
|
content test4 test/ contentaccessible
|
||||||
69
mozilla/chrome/test/unit/head_crtestutils.js
Normal file
69
mozilla/chrome/test/unit/head_crtestutils.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
||||||
|
const XULAPPINFO_CID = Components.ID("{48a4e946-1f9f-4224-b4b0-9a54183cb81e}");
|
||||||
|
|
||||||
|
const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
|
||||||
|
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
const Cr = Components.results;
|
||||||
|
|
||||||
|
function ArrayEnumerator(array)
|
||||||
|
{
|
||||||
|
this.array = array;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayEnumerator.prototype = {
|
||||||
|
pos: 0,
|
||||||
|
|
||||||
|
hasMoreElements: function() {
|
||||||
|
return this.pos < this.array.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
getNext: function() {
|
||||||
|
if (this.pos < this.array.length)
|
||||||
|
return this.array[this.pos++];
|
||||||
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
|
},
|
||||||
|
|
||||||
|
QueryInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsISimpleEnumerator)
|
||||||
|
|| iid.equals(Ci.nsISupports))
|
||||||
|
return this;
|
||||||
|
|
||||||
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function ChromeProvider(manifests)
|
||||||
|
{
|
||||||
|
this._manifests = manifests;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChromeProvider.prototype = {
|
||||||
|
getFile: function(prop, persistent) {
|
||||||
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
|
},
|
||||||
|
|
||||||
|
getFiles: function(prop) {
|
||||||
|
if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
|
||||||
|
return new ArrayEnumerator(this._manifests);
|
||||||
|
}
|
||||||
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
|
},
|
||||||
|
|
||||||
|
QueryInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsIDirectoryServiceProvider)
|
||||||
|
|| iid.equals(Ci.nsIDirectoryServiceProvider2)
|
||||||
|
|| iid.equals(Ci.nsISupports))
|
||||||
|
return this;
|
||||||
|
|
||||||
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function registerManifests(manifests)
|
||||||
|
{
|
||||||
|
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||||
|
getService(Ci.nsIDirectoryService);
|
||||||
|
dirSvc.registerProvider(new ChromeProvider(manifests));
|
||||||
|
}
|
||||||
70
mozilla/chrome/test/unit/test_bug292789.js
Normal file
70
mozilla/chrome/test/unit/test_bug292789.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||||
|
*
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
const MANIFESTS = [
|
||||||
|
do_get_file("chrome/test/unit/data/test_bug292789.manifest")
|
||||||
|
];
|
||||||
|
|
||||||
|
registerManifests(MANIFESTS);
|
||||||
|
|
||||||
|
var gIOS;
|
||||||
|
var gCR;
|
||||||
|
|
||||||
|
function check_accessibility(spec, desired)
|
||||||
|
{
|
||||||
|
var uri = gIOS.newURI(spec, null, null);
|
||||||
|
var actual = gCR.allowContentToAccess(uri);
|
||||||
|
do_check_eq(desired, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_test()
|
||||||
|
{
|
||||||
|
gIOS = Cc["@mozilla.org/network/io-service;1"].
|
||||||
|
getService(Ci.nsIIOService);
|
||||||
|
gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
|
||||||
|
getService(Ci.nsIXULChromeRegistry);
|
||||||
|
gCR.checkForNewChrome();
|
||||||
|
|
||||||
|
check_accessibility("chrome://test1/content/", false);
|
||||||
|
check_accessibility("chrome://test1/content/foo.js", false);
|
||||||
|
check_accessibility("chrome://test2/content/", true);
|
||||||
|
check_accessibility("chrome://test2/content/foo.js", true);
|
||||||
|
check_accessibility("chrome://test3/content/", false);
|
||||||
|
check_accessibility("chrome://test3/content/foo.js", false);
|
||||||
|
check_accessibility("chrome://test4/content/", true);
|
||||||
|
}
|
||||||
@ -36,69 +36,12 @@
|
|||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
|
||||||
const XULAPPINFO_CID = Components.ID("{48a4e946-1f9f-4224-b4b0-9a54183cb81e}");
|
|
||||||
|
|
||||||
const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var MANIFESTS = [
|
var MANIFESTS = [
|
||||||
do_get_file("chrome/test/unit/data/test_bug380398.manifest")
|
do_get_file("chrome/test/unit/data/test_bug380398.manifest")
|
||||||
];
|
];
|
||||||
|
|
||||||
function ArrayEnumerator(array)
|
registerManifests(MANIFESTS);
|
||||||
{
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayEnumerator.prototype = {
|
|
||||||
pos: 0,
|
|
||||||
|
|
||||||
hasMoreElements: function() {
|
|
||||||
return this.pos < this.array.length;
|
|
||||||
},
|
|
||||||
|
|
||||||
getNext: function() {
|
|
||||||
if (this.pos < this.array.length)
|
|
||||||
return this.array[this.pos++];
|
|
||||||
throw Components.results.NS_ERROR_FAILURE;
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsISimpleEnumerator)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ChromeProvider = {
|
|
||||||
getFile: function(prop, persistent) {
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
getFiles: function(prop) {
|
|
||||||
if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
|
|
||||||
return new ArrayEnumerator(MANIFESTS);
|
|
||||||
}
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsIDirectoryServiceProvider)
|
|
||||||
|| iid.equals(Ci.nsIDirectoryServiceProvider2)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
|
||||||
.getService(Ci.nsIDirectoryService);
|
|
||||||
dirSvc.registerProvider(ChromeProvider);
|
|
||||||
|
|
||||||
var XULAppInfo = {
|
var XULAppInfo = {
|
||||||
vendor: "Mozilla",
|
vendor: "Mozilla",
|
||||||
|
|||||||
@ -36,69 +36,12 @@
|
|||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
|
||||||
const XULAPPINFO_CID = Components.ID("{48a4e946-1f9f-4224-b4b0-9a54183cb81e}");
|
|
||||||
|
|
||||||
const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var MANIFESTS = [
|
var MANIFESTS = [
|
||||||
do_get_file("chrome/test/unit/data/test_bug397073.manifest")
|
do_get_file("chrome/test/unit/data/test_bug397073.manifest")
|
||||||
];
|
];
|
||||||
|
|
||||||
function ArrayEnumerator(array)
|
|
||||||
{
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayEnumerator.prototype = {
|
registerManifests(MANIFESTS);
|
||||||
pos: 0,
|
|
||||||
|
|
||||||
hasMoreElements: function() {
|
|
||||||
return this.pos < this.array.length;
|
|
||||||
},
|
|
||||||
|
|
||||||
getNext: function() {
|
|
||||||
if (this.pos < this.array.length)
|
|
||||||
return this.array[this.pos++];
|
|
||||||
throw Components.results.NS_ERROR_FAILURE;
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsISimpleEnumerator)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ChromeProvider = {
|
|
||||||
getFile: function(prop, persistent) {
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
getFiles: function(prop) {
|
|
||||||
if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
|
|
||||||
return new ArrayEnumerator(MANIFESTS);
|
|
||||||
}
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsIDirectoryServiceProvider)
|
|
||||||
|| iid.equals(Ci.nsIDirectoryServiceProvider2)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
|
||||||
.getService(Ci.nsIDirectoryService);
|
|
||||||
dirSvc.registerProvider(ChromeProvider);
|
|
||||||
|
|
||||||
var XULAppInfo = {
|
var XULAppInfo = {
|
||||||
vendor: "Mozilla",
|
vendor: "Mozilla",
|
||||||
|
|||||||
@ -36,69 +36,11 @@
|
|||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
|
||||||
const XULAPPINFO_CID = Components.ID("{48a4e946-1f9f-4224-b4b0-9a54183cb81e}");
|
|
||||||
|
|
||||||
const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var MANIFESTS = [
|
var MANIFESTS = [
|
||||||
do_get_file("chrome/test/unit/data/test_bug399707.manifest")
|
do_get_file("chrome/test/unit/data/test_bug399707.manifest")
|
||||||
];
|
];
|
||||||
|
|
||||||
function ArrayEnumerator(array)
|
registerManifests(MANIFESTS);
|
||||||
{
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayEnumerator.prototype = {
|
|
||||||
pos: 0,
|
|
||||||
|
|
||||||
hasMoreElements: function() {
|
|
||||||
return this.pos < this.array.length;
|
|
||||||
},
|
|
||||||
|
|
||||||
getNext: function() {
|
|
||||||
if (this.pos < this.array.length)
|
|
||||||
return this.array[this.pos++];
|
|
||||||
throw Components.results.NS_ERROR_FAILURE;
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsISimpleEnumerator)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ChromeProvider = {
|
|
||||||
getFile: function(prop, persistent) {
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
getFiles: function(prop) {
|
|
||||||
if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
|
|
||||||
return new ArrayEnumerator(MANIFESTS);
|
|
||||||
}
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsIDirectoryServiceProvider)
|
|
||||||
|| iid.equals(Ci.nsIDirectoryServiceProvider2)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
|
||||||
.getService(Ci.nsIDirectoryService);
|
|
||||||
dirSvc.registerProvider(ChromeProvider);
|
|
||||||
|
|
||||||
var XULAppInfo = {
|
var XULAppInfo = {
|
||||||
vendor: "Mozilla",
|
vendor: "Mozilla",
|
||||||
|
|||||||
@ -36,69 +36,11 @@
|
|||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
|
||||||
const XULAPPINFO_CID = Components.ID("{48a4e946-1f9f-4224-b4b0-9a54183cb81e}");
|
|
||||||
|
|
||||||
const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var MANIFESTS = [
|
var MANIFESTS = [
|
||||||
do_get_file("chrome/test/unit/data/test_bug401153.manifest")
|
do_get_file("chrome/test/unit/data/test_bug401153.manifest")
|
||||||
];
|
];
|
||||||
|
|
||||||
function ArrayEnumerator(array)
|
registerManifests(MANIFESTS);
|
||||||
{
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayEnumerator.prototype = {
|
|
||||||
pos: 0,
|
|
||||||
|
|
||||||
hasMoreElements: function() {
|
|
||||||
return this.pos < this.array.length;
|
|
||||||
},
|
|
||||||
|
|
||||||
getNext: function() {
|
|
||||||
if (this.pos < this.array.length)
|
|
||||||
return this.array[this.pos++];
|
|
||||||
throw Components.results.NS_ERROR_FAILURE;
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsISimpleEnumerator)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ChromeProvider = {
|
|
||||||
getFile: function(prop, persistent) {
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
getFiles: function(prop) {
|
|
||||||
if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
|
|
||||||
return new ArrayEnumerator(MANIFESTS);
|
|
||||||
}
|
|
||||||
throw Components.results.NS_ERROR_FAILURE
|
|
||||||
},
|
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
|
||||||
if (iid.equals(Ci.nsIDirectoryServiceProvider)
|
|
||||||
|| iid.equals(Ci.nsIDirectoryServiceProvider2)
|
|
||||||
|| iid.equals(Ci.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
|
||||||
.getService(Ci.nsIDirectoryService);
|
|
||||||
dirSvc.registerProvider(ChromeProvider);
|
|
||||||
|
|
||||||
var XULAppInfo = {
|
var XULAppInfo = {
|
||||||
vendor: "Mozilla",
|
vendor: "Mozilla",
|
||||||
|
|||||||
@ -36,9 +36,6 @@
|
|||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var gIOS = Cc["@mozilla.org/network/io-service;1"]
|
var gIOS = Cc["@mozilla.org/network/io-service;1"]
|
||||||
.getService(Ci.nsIIOService);
|
.getService(Ci.nsIIOService);
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ interface nsIChromeRegistry : nsISupports
|
|||||||
void checkForNewChrome();
|
void checkForNewChrome();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(3e51f40b-b4b0-4e60-ac45-6c63477ebe41)]
|
[scriptable, uuid(2860e205-490e-4b06-90b6-87160d35a5a7)]
|
||||||
interface nsIXULChromeRegistry : nsIChromeRegistry
|
interface nsIXULChromeRegistry : nsIChromeRegistry
|
||||||
{
|
{
|
||||||
/* Should be called when locales change to reload all chrome (including XUL). */
|
/* Should be called when locales change to reload all chrome (including XUL). */
|
||||||
@ -93,6 +93,13 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
|
|||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
boolean allowScriptsForPackage(in nsIURI url);
|
boolean allowScriptsForPackage(in nsIURI url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content should only be allowed to load chrome JS from certain packages.
|
||||||
|
* This method reflects the contentaccessible flag on packages.
|
||||||
|
* Do not pass non-chrome URIs to this method.
|
||||||
|
*/
|
||||||
|
boolean allowContentToAccess(in nsIURI url);
|
||||||
};
|
};
|
||||||
|
|
||||||
%{ C++
|
%{ C++
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user