mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 181641 - On Mach-0 build, cannot launch if theme was installed into profile with CFM build. Fixes this by fixing the general problem of failure due to missing theme jars. Patch to nsChromeRegistry.cpp by ccarlen, r=ben/sr=brendan. Patch to nsChromeProtocolHandler.cpp by brendan, r=ccarlen/sr=ben.
This commit is contained in:
parent
1866641871
commit
fbf72c7968
@ -703,38 +703,26 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
|
||||
fastLoadServ->GetOutputStream(getter_AddRefs(objectOutput));
|
||||
if (objectOutput) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsCOMPtr<nsIChannel> chan = result;
|
||||
while (!fileChan) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
chan->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// Loop, jar: URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
if (fileChan) {
|
||||
fileChan->GetFile(getter_AddRefs(file));
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
result->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// Loop, jar URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
// Often, however, we have jar:resource:/chrome/A.jar!C.xml.
|
||||
nsCOMPtr<nsIJARURI> jarURI;
|
||||
while ((jarURI = do_QueryInterface(uri)) != nsnull)
|
||||
jarURI->GetJARFile(getter_AddRefs(uri));
|
||||
|
||||
// Here we must have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar. Let's hope for the latter.
|
||||
// Here we have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar.
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
|
||||
if (fileURL) {
|
||||
if (fileURL)
|
||||
fileURL->GetFile(getter_AddRefs(file));
|
||||
if (file)
|
||||
break;
|
||||
}
|
||||
|
||||
// Thanks to the way that the resource: URL implementation
|
||||
// hides its substitution code from itself and the rest of
|
||||
// the world, we must make a new channel simply to get the
|
||||
// substituted URI.
|
||||
ioServ->NewChannelFromURI(uri, getter_AddRefs(chan));
|
||||
if (!chan)
|
||||
break;
|
||||
fileChan = do_QueryInterface(chan);
|
||||
}
|
||||
|
||||
if (!file && fileChan)
|
||||
fileChan->GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
rv = fastLoadServ->AddDependency(file);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -109,6 +109,9 @@
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "imgICache.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIFileURL.h"
|
||||
|
||||
static char kChromePrefix[] = "chrome://";
|
||||
static char kUseXBLFormsPref[] = "nglayout.debug.enable_xbl_forms";
|
||||
@ -481,6 +484,40 @@ SplitURL(nsIURI *aChromeURI, nsCString& aPackage, nsCString& aProvider, nsCStrin
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetBaseURLFile(const nsACString& aBaseURL, nsIFile** aFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
*aFile = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioServ(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = ioServ->NewURI(aBaseURL, nsnull, nsnull, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Loop, jar: URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
// Often, however, we have jar:resource:/chrome/A.jar!C.xml.
|
||||
nsCOMPtr<nsIJARURI> jarURI;
|
||||
while ((jarURI = do_QueryInterface(uri)) != nsnull)
|
||||
jarURI->GetJARFile(getter_AddRefs(uri));
|
||||
|
||||
// Here we must have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar.
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
|
||||
if (fileURL) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
fileURL->GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
NS_ADDREF(*aFile = file);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
NS_ERROR("GetBaseURLFile() failed. Remote chrome?");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Canonify(nsIURI* aChromeURI)
|
||||
@ -649,10 +686,30 @@ nsChromeRegistry::GetBaseURL(const nsACString& aPackage,
|
||||
if (!providerVersion.Equals(packageVersion))
|
||||
selectedProvider = nsnull;
|
||||
}
|
||||
|
||||
if (selectedProvider) {
|
||||
// Ensure that the provider actually exists.
|
||||
// XXX This will have to change if we handle remote chrome.
|
||||
rv = FollowArc(mChromeDataSource, aBaseURL, resource, mBaseURL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> baseURLFile;
|
||||
rv = GetBaseURLFile(aBaseURL, getter_AddRefs(baseURLFile));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool exists;
|
||||
rv = baseURLFile->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv) && exists)
|
||||
return NS_OK;
|
||||
#if DEBUG
|
||||
printf("BaseURL %s cannot be found.\n", PromiseFlatCString(aBaseURL).get());
|
||||
#endif
|
||||
selectedProvider = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedProvider) {
|
||||
// Find provider will attempt to auto-select a version-compatible provider (skin). If none
|
||||
// FindProvider will attempt to auto-select a version-compatible provider (skin). If none
|
||||
// exist it will return nsnull in the selectedProvider variable.
|
||||
FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
|
||||
resource = do_QueryInterface(selectedProvider);
|
||||
@ -2058,6 +2115,25 @@ nsChromeRegistry::SelectProviderForPackage(const nsACString& aProviderType,
|
||||
if (!providerVersion.Equals(packageVersion))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Ensure that the provider actually exists.
|
||||
// XXX This will have to change if we handle remote chrome.
|
||||
nsCAutoString providerBaseURL;
|
||||
rv = FollowArc(mChromeDataSource, providerBaseURL, providerResource, mBaseURL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> baseURLFile;
|
||||
rv = GetBaseURLFile(providerBaseURL, getter_AddRefs(baseURLFile));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
PRBool exists;
|
||||
rv = baseURLFile->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
#if DEBUG
|
||||
printf("BaseURL %s cannot be found.\n", PromiseFlatCString(providerBaseURL).get());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
|
||||
aUseProfile, nsnull, aIsAdding);
|
||||
|
@ -703,38 +703,26 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
|
||||
fastLoadServ->GetOutputStream(getter_AddRefs(objectOutput));
|
||||
if (objectOutput) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsCOMPtr<nsIChannel> chan = result;
|
||||
while (!fileChan) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
chan->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// Loop, jar: URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
if (fileChan) {
|
||||
fileChan->GetFile(getter_AddRefs(file));
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
result->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// Loop, jar URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
// Often, however, we have jar:resource:/chrome/A.jar!C.xml.
|
||||
nsCOMPtr<nsIJARURI> jarURI;
|
||||
while ((jarURI = do_QueryInterface(uri)) != nsnull)
|
||||
jarURI->GetJARFile(getter_AddRefs(uri));
|
||||
|
||||
// Here we must have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar. Let's hope for the latter.
|
||||
// Here we have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar.
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
|
||||
if (fileURL) {
|
||||
if (fileURL)
|
||||
fileURL->GetFile(getter_AddRefs(file));
|
||||
if (file)
|
||||
break;
|
||||
}
|
||||
|
||||
// Thanks to the way that the resource: URL implementation
|
||||
// hides its substitution code from itself and the rest of
|
||||
// the world, we must make a new channel simply to get the
|
||||
// substituted URI.
|
||||
ioServ->NewChannelFromURI(uri, getter_AddRefs(chan));
|
||||
if (!chan)
|
||||
break;
|
||||
fileChan = do_QueryInterface(chan);
|
||||
}
|
||||
|
||||
if (!file && fileChan)
|
||||
fileChan->GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
rv = fastLoadServ->AddDependency(file);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -109,6 +109,9 @@
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "imgICache.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIFileURL.h"
|
||||
|
||||
static char kChromePrefix[] = "chrome://";
|
||||
static char kUseXBLFormsPref[] = "nglayout.debug.enable_xbl_forms";
|
||||
@ -481,6 +484,40 @@ SplitURL(nsIURI *aChromeURI, nsCString& aPackage, nsCString& aProvider, nsCStrin
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetBaseURLFile(const nsACString& aBaseURL, nsIFile** aFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
*aFile = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioServ(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = ioServ->NewURI(aBaseURL, nsnull, nsnull, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Loop, jar: URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
|
||||
// Often, however, we have jar:resource:/chrome/A.jar!C.xml.
|
||||
nsCOMPtr<nsIJARURI> jarURI;
|
||||
while ((jarURI = do_QueryInterface(uri)) != nsnull)
|
||||
jarURI->GetJARFile(getter_AddRefs(uri));
|
||||
|
||||
// Here we must have a URL of the form resource:/chrome/A.jar
|
||||
// or file:/some/path/to/A.jar.
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
|
||||
if (fileURL) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
fileURL->GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
NS_ADDREF(*aFile = file);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
NS_ERROR("GetBaseURLFile() failed. Remote chrome?");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Canonify(nsIURI* aChromeURI)
|
||||
@ -649,10 +686,30 @@ nsChromeRegistry::GetBaseURL(const nsACString& aPackage,
|
||||
if (!providerVersion.Equals(packageVersion))
|
||||
selectedProvider = nsnull;
|
||||
}
|
||||
|
||||
if (selectedProvider) {
|
||||
// Ensure that the provider actually exists.
|
||||
// XXX This will have to change if we handle remote chrome.
|
||||
rv = FollowArc(mChromeDataSource, aBaseURL, resource, mBaseURL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> baseURLFile;
|
||||
rv = GetBaseURLFile(aBaseURL, getter_AddRefs(baseURLFile));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool exists;
|
||||
rv = baseURLFile->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv) && exists)
|
||||
return NS_OK;
|
||||
#if DEBUG
|
||||
printf("BaseURL %s cannot be found.\n", PromiseFlatCString(aBaseURL).get());
|
||||
#endif
|
||||
selectedProvider = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedProvider) {
|
||||
// Find provider will attempt to auto-select a version-compatible provider (skin). If none
|
||||
// FindProvider will attempt to auto-select a version-compatible provider (skin). If none
|
||||
// exist it will return nsnull in the selectedProvider variable.
|
||||
FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
|
||||
resource = do_QueryInterface(selectedProvider);
|
||||
@ -2058,6 +2115,25 @@ nsChromeRegistry::SelectProviderForPackage(const nsACString& aProviderType,
|
||||
if (!providerVersion.Equals(packageVersion))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Ensure that the provider actually exists.
|
||||
// XXX This will have to change if we handle remote chrome.
|
||||
nsCAutoString providerBaseURL;
|
||||
rv = FollowArc(mChromeDataSource, providerBaseURL, providerResource, mBaseURL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> baseURLFile;
|
||||
rv = GetBaseURLFile(providerBaseURL, getter_AddRefs(baseURLFile));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
PRBool exists;
|
||||
rv = baseURLFile->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
#if DEBUG
|
||||
printf("BaseURL %s cannot be found.\n", PromiseFlatCString(providerBaseURL).get());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
|
||||
aUseProfile, nsnull, aIsAdding);
|
||||
|
Loading…
Reference in New Issue
Block a user