зеркало из https://github.com/mozilla/pjs.git
Create a service that can be asked whether a given webnavigation (or a
"typical" webnavigation) supports loading of a certain MIME type. Bug 283125, r=biesi, sr=darin
This commit is contained in:
Родитель
4a98e6c61a
Коммит
f411c17a49
|
@ -57,6 +57,7 @@ const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||||
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
|
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
|
||||||
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
|
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
|
||||||
const nsICategoryManager = Components.interfaces.nsICategoryManager;
|
const nsICategoryManager = Components.interfaces.nsICategoryManager;
|
||||||
|
const nsIWebNavigationInfo = Components.interfaces.nsIWebNavigationInfo;
|
||||||
|
|
||||||
const NS_BINDING_ABORTED = 0x80020006;
|
const NS_BINDING_ABORTED = 0x80020006;
|
||||||
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
||||||
|
@ -248,10 +249,11 @@ var nsBrowserContentHandler = {
|
||||||
|
|
||||||
handleContent : function bch_handleContent(contentType, context, request) {
|
handleContent : function bch_handleContent(contentType, context, request) {
|
||||||
try {
|
try {
|
||||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"]
|
var webNavInfo = Components.classes["@mozilla.org/webnavigation-info;1"]
|
||||||
.getService(nsICategoryManager);
|
.getService(nsIWebNavigationInfo);
|
||||||
var entry = catMan.getCategoryEntry("Gecko-Content-Viewers",
|
if (!webNavInfo.isTypeSupported(contentType, null)) {
|
||||||
contentType);
|
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ REQUIRES = xpcom \
|
||||||
commandhandler \
|
commandhandler \
|
||||||
editor \
|
editor \
|
||||||
windowwatcher \
|
windowwatcher \
|
||||||
|
imglib2 \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
SDK_XPIDLSRCS = \
|
SDK_XPIDLSRCS = \
|
||||||
|
@ -106,6 +107,7 @@ XPIDLSRCS = \
|
||||||
nsIScrollable.idl \
|
nsIScrollable.idl \
|
||||||
nsITextScroll.idl \
|
nsITextScroll.idl \
|
||||||
nsIWebNavigation.idl \
|
nsIWebNavigation.idl \
|
||||||
|
nsIWebNavigationInfo.idl \
|
||||||
nsIContentViewer.idl \
|
nsIContentViewer.idl \
|
||||||
nsIContentViewerEdit.idl \
|
nsIContentViewerEdit.idl \
|
||||||
nsIContentViewerFile.idl \
|
nsIContentViewerFile.idl \
|
||||||
|
@ -125,6 +127,7 @@ CPPSRCS = \
|
||||||
nsDefaultURIFixup.cpp \
|
nsDefaultURIFixup.cpp \
|
||||||
nsGlobalHistoryAdapter.cpp \
|
nsGlobalHistoryAdapter.cpp \
|
||||||
nsGlobalHistory2Adapter.cpp \
|
nsGlobalHistory2Adapter.cpp \
|
||||||
|
nsWebNavigationInfo.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# we don't want the shared lib, but we want to force the creation of a
|
# we don't want the shared lib, but we want to force the creation of a
|
||||||
|
|
|
@ -40,9 +40,10 @@
|
||||||
#include "nsDocShell.h"
|
#include "nsDocShell.h"
|
||||||
#include "nsDSURIContentListener.h"
|
#include "nsDSURIContentListener.h"
|
||||||
#include "nsIChannel.h"
|
#include "nsIChannel.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsXPIDLString.h"
|
#include "nsXPIDLString.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsDocShellCID.h"
|
||||||
#include "nsIPluginManager.h"
|
#include "nsIWebNavigationInfo.h"
|
||||||
#include "nsIDOMWindowInternal.h"
|
#include "nsIDOMWindowInternal.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
|
|
||||||
|
@ -63,9 +64,9 @@ nsDSURIContentListener::~nsDSURIContentListener()
|
||||||
nsresult
|
nsresult
|
||||||
nsDSURIContentListener::Init()
|
nsDSURIContentListener::Init()
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv;
|
||||||
mCatMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,38 +183,22 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
||||||
char ** aDesiredContentType,
|
char ** aDesiredContentType,
|
||||||
PRBool* aCanHandleContent)
|
PRBool* aCanHandleContent)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
||||||
NS_ENSURE_ARG_POINTER(aCanHandleContent);
|
|
||||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||||
|
|
||||||
*aCanHandleContent = PR_FALSE;
|
*aCanHandleContent = PR_FALSE;
|
||||||
|
*aDesiredContentType = nsnull;
|
||||||
|
|
||||||
if (aContentType && mCatMgr)
|
nsresult rv = NS_OK;
|
||||||
{
|
if (aContentType) {
|
||||||
rv = IsTypeSupported(aContentType, aCanHandleContent);
|
PRUint32 canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
if (NS_FAILED(rv))
|
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
return rv;
|
mDocShell,
|
||||||
|
&canHandle);
|
||||||
if (!*aCanHandleContent) {
|
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
// Try loading plugins to see whether someone neglected to do so
|
|
||||||
nsCOMPtr<nsIPluginManager> pluginManager =
|
|
||||||
do_GetService("@mozilla.org/plugin/manager;1");
|
|
||||||
if (pluginManager) {
|
|
||||||
// PR_FALSE will ensure that currently running plugins will not
|
|
||||||
// be shut down
|
|
||||||
rv = pluginManager->ReloadPlugins(PR_FALSE);
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
// OK, we reloaded plugins and there were new ones
|
|
||||||
// (otherwise NS_ERROR_PLUGINS_PLUGINSNOTCHANGED would have
|
|
||||||
// been returned). Try checking whether we can handle the
|
|
||||||
// content now.
|
|
||||||
return IsTypeSupported(aContentType, aCanHandleContent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -275,30 +260,3 @@ nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsDSURIContentListener::IsTypeSupported(const char* aContentType,
|
|
||||||
PRBool* aIsSupported)
|
|
||||||
{
|
|
||||||
NS_PRECONDITION(aContentType, "Must have content type");
|
|
||||||
NS_PRECONDITION(mCatMgr, "Must have category manager");
|
|
||||||
NS_PRECONDITION(aIsSupported, "Null out param?");
|
|
||||||
|
|
||||||
nsXPIDLCString value;
|
|
||||||
nsresult rv = mCatMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
|
||||||
aContentType,
|
|
||||||
getter_Copies(value));
|
|
||||||
|
|
||||||
// If the category manager can't find what we're looking for
|
|
||||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
|
||||||
// that to the caller since it's really not a failure
|
|
||||||
|
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
// XXXbz should we check that this service actually exists? May be a
|
|
||||||
// good idea...
|
|
||||||
|
|
||||||
*aIsSupported = !value.IsEmpty();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
|
@ -43,10 +43,10 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIURIContentListener.h"
|
#include "nsIURIContentListener.h"
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsWeakReference.h"
|
#include "nsWeakReference.h"
|
||||||
|
|
||||||
class nsDocShell;
|
class nsDocShell;
|
||||||
|
class nsIWebNavigationInfo;
|
||||||
|
|
||||||
class nsDSURIContentListener :
|
class nsDSURIContentListener :
|
||||||
public nsIURIContentListener,
|
public nsIURIContentListener,
|
||||||
|
@ -68,12 +68,6 @@ protected:
|
||||||
mDocShell = nsnull;
|
mDocShell = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether aContentType is supported. If this method throws, the
|
|
||||||
// value of aIsSupported is undefined and should not be looked at.
|
|
||||||
// aContentType must not be null before this is called, and we must have an
|
|
||||||
// mCatMgr.
|
|
||||||
nsresult IsTypeSupported(const char* aContentType, PRBool* aIsSupported);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsDocShell* mDocShell;
|
nsDocShell* mDocShell;
|
||||||
|
|
||||||
|
@ -83,7 +77,7 @@ protected:
|
||||||
nsWeakPtr mWeakParentContentListener;
|
nsWeakPtr mWeakParentContentListener;
|
||||||
nsIURIContentListener* mParentContentListener;
|
nsIURIContentListener* mParentContentListener;
|
||||||
|
|
||||||
nsCOMPtr<nsICategoryManager> mCatMgr;
|
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsDSURIContentListener_h__ */
|
#endif /* nsDSURIContentListener_h__ */
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** 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
|
||||||
|
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* 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 ***** */
|
||||||
|
|
||||||
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
|
interface nsIWebNavigation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The nsIWebNavigationInfo interface exposes a way to get information
|
||||||
|
* on the capabilities of Gecko webnavigation objects.
|
||||||
|
*
|
||||||
|
* @status UNDER_REVIEW
|
||||||
|
*/
|
||||||
|
[scriptable, uuid(62a93afb-93a1-465c-84c8-0432264229de)]
|
||||||
|
interface nsIWebNavigationInfo : nsISupports
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returned by isTypeSupported to indicate lack of support for a type.
|
||||||
|
* @note this is guaranteed not to change, so that boolean tests can be done
|
||||||
|
* on the return value if isTypeSupported to detect whether a type is
|
||||||
|
* supported at all.
|
||||||
|
*/
|
||||||
|
const unsigned long UNSUPPORTED = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by isTypeSupported to indicate that a type is supported as an
|
||||||
|
* image.
|
||||||
|
*/
|
||||||
|
const unsigned long IMAGE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by isTypeSupported to indicate that a type is supported via an
|
||||||
|
* NPAPI ("Netscape 4 API") plug-in. This is not the value returned for
|
||||||
|
* "XPCOM plug-ins".
|
||||||
|
*/
|
||||||
|
const unsigned long PLUGIN = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note Other return types may be added here in the future as they become
|
||||||
|
* relevant.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returned by isTypeSupported to indicate that a type is supported via some
|
||||||
|
* other means.
|
||||||
|
*/
|
||||||
|
const unsigned long OTHER = 1 << 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query whether aType is supported.
|
||||||
|
* @param aType the MIME type in question.
|
||||||
|
* @param aWebNav the nsIWebNavigation object for which the request
|
||||||
|
* is being made. This is allowed to be null. If it is non-null,
|
||||||
|
* the return value of this method may depend on the exact state of
|
||||||
|
* aWebNav and the values set through nsIWebBrowserSetup; otherwise
|
||||||
|
* the method will assume that the caller is interested in information
|
||||||
|
* about nsIWebNavigation objects in their default state.
|
||||||
|
* @return an enum value indicating whether and how aType is supported.
|
||||||
|
* @note This method may rescan plugins to ensure that they're properly
|
||||||
|
* registered for the types they support.
|
||||||
|
*/
|
||||||
|
unsigned long isTypeSupported(in ACString aType, in nsIWebNavigation aWebNav);
|
||||||
|
};
|
|
@ -0,0 +1,153 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** 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
|
||||||
|
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* 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 ***** */
|
||||||
|
|
||||||
|
#include "nsWebNavigationInfo.h"
|
||||||
|
#include "nsIWebNavigation.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIDocumentLoaderFactory.h"
|
||||||
|
#include "nsIPluginManager.h"
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(nsWebNavigationInfo, nsIWebNavigationInfo)
|
||||||
|
|
||||||
|
#define CONTENT_DLF_CONTRACT "@mozilla.org/content/document-loader-factory;1"
|
||||||
|
#define PLUGIN_DLF_CONTRACT \
|
||||||
|
"@mozilla.org/content/plugin/document-loader-factory;1"
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsWebNavigationInfo::Init()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
mCategoryManager = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
mImgLoader = do_GetService("@mozilla.org/image/loader;1", &rv);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
||||||
|
nsIWebNavigation* aWebNav,
|
||||||
|
PRUint32* aIsTypeSupported)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(aIsTypeSupported, "null out param?");
|
||||||
|
|
||||||
|
// Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
|
||||||
|
// an nsSHistory, but not much we can do with that). So if we start using
|
||||||
|
// it here, we need to be careful to get to the docshell correctly.
|
||||||
|
|
||||||
|
// For now just report what the Gecko-Content-Viewers category has
|
||||||
|
// to say for itself.
|
||||||
|
*aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
|
|
||||||
|
const nsCString& flatType = PromiseFlatCString(aType);
|
||||||
|
nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
if (*aIsTypeSupported) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try reloading plugins in case they've changed.
|
||||||
|
nsCOMPtr<nsIPluginManager> pluginManager =
|
||||||
|
do_GetService("@mozilla.org/plugin/manager;1");
|
||||||
|
if (pluginManager) {
|
||||||
|
// PR_FALSE will ensure that currently running plugins will not
|
||||||
|
// be shut down
|
||||||
|
rv = pluginManager->ReloadPlugins(PR_FALSE);
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
// OK, we reloaded plugins and there were new ones
|
||||||
|
// (otherwise NS_ERROR_PLUGINS_PLUGINSNOTCHANGED would have
|
||||||
|
// been returned). Try checking whether we can handle the
|
||||||
|
// content now.
|
||||||
|
return IsTypeSupportedInternal(flatType, aIsTypeSupported);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
|
||||||
|
PRUint32* aIsSupported)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(mCategoryManager, "Must have category manager");
|
||||||
|
NS_PRECONDITION(aIsSupported, "Null out param?");
|
||||||
|
|
||||||
|
nsXPIDLCString value;
|
||||||
|
nsresult rv = mCategoryManager->GetCategoryEntry("Gecko-Content-Viewers",
|
||||||
|
aType.get(),
|
||||||
|
getter_Copies(value));
|
||||||
|
|
||||||
|
// If the category manager can't find what we're looking for
|
||||||
|
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
||||||
|
// that to the caller since it's really not a failure
|
||||||
|
|
||||||
|
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
// Now try to get an actual document loader factory for this contractid. If
|
||||||
|
// there is no contractid, don't try and just return false for *aIsSupported.
|
||||||
|
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory;
|
||||||
|
if (!value.IsEmpty()) {
|
||||||
|
docLoaderFactory = do_GetService(value.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we got a factory, we should be able to handle this type
|
||||||
|
if (!docLoaderFactory) {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
else if (value.EqualsLiteral(CONTENT_DLF_CONTRACT)) {
|
||||||
|
PRBool isImage = PR_FALSE;
|
||||||
|
mImgLoader->SupportImageWithMimeType(aType.get(), &isImage);
|
||||||
|
if (isImage) {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::IMAGE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (value.EqualsLiteral(PLUGIN_DLF_CONTRACT)) {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** 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
|
||||||
|
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* 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 ***** */
|
||||||
|
|
||||||
|
#ifndef nsWebNavigationInfo_h__
|
||||||
|
#define nsWebNavigationInfo_h__
|
||||||
|
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsICategoryManager.h"
|
||||||
|
#include "imgILoader.h"
|
||||||
|
#include "nsStringFwd.h"
|
||||||
|
|
||||||
|
// Class ID for webnavigationinfo
|
||||||
|
#define NS_WEBNAVIGATION_INFO_CID \
|
||||||
|
{ 0xf30bc0a2, 0x958b, 0x4287,{0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e}}
|
||||||
|
|
||||||
|
class nsWebNavigationInfo : public nsIWebNavigationInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsWebNavigationInfo() {}
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
NS_DECL_NSIWEBNAVIGATIONINFO
|
||||||
|
|
||||||
|
nsresult Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
~nsWebNavigationInfo() {}
|
||||||
|
|
||||||
|
// Check whether aType is supported. If this method throws, the
|
||||||
|
// value of aIsSupported is not changed.
|
||||||
|
nsresult IsTypeSupportedInternal(const nsCString& aType,
|
||||||
|
PRUint32* aIsSupported);
|
||||||
|
|
||||||
|
nsCOMPtr<nsICategoryManager> mCategoryManager;
|
||||||
|
// XXXbz we only need this because images register for the same
|
||||||
|
// contractid as documents, so we can't tell them apart based on
|
||||||
|
// contractid.
|
||||||
|
nsCOMPtr<imgILoader> mImgLoader;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // nsWebNavigationInfo_h__
|
|
@ -79,6 +79,7 @@ REQUIRES = xpcom \
|
||||||
mimetype \
|
mimetype \
|
||||||
rdf \
|
rdf \
|
||||||
prefetch \
|
prefetch \
|
||||||
|
imglib2 \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
|
|
|
@ -41,4 +41,12 @@
|
||||||
#define NS_GLOBALHISTORY2_CONTRACTID \
|
#define NS_GLOBALHISTORY2_CONTRACTID \
|
||||||
"@mozilla.org/browser/global-history;2"
|
"@mozilla.org/browser/global-history;2"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A contract that can be used to get a service that provides
|
||||||
|
* meta-information about nsIWebNavigation objects' capabilities.
|
||||||
|
* @implements nsIWebNavigationInfo
|
||||||
|
*/
|
||||||
|
#define NS_WEBNAVIGATION_INFO_CONTRACTID \
|
||||||
|
"@mozilla.org/webnavigation-info;1"
|
||||||
|
|
||||||
#endif // nsDocShellCID_h__
|
#endif // nsDocShellCID_h__
|
||||||
|
|
|
@ -39,8 +39,12 @@
|
||||||
|
|
||||||
#include "nsIModule.h"
|
#include "nsIModule.h"
|
||||||
#include "nsIGenericFactory.h"
|
#include "nsIGenericFactory.h"
|
||||||
|
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
|
|
||||||
#include "nsWebShell.h"
|
#include "nsWebShell.h"
|
||||||
#include "nsDefaultURIFixup.h"
|
#include "nsDefaultURIFixup.h"
|
||||||
|
#include "nsWebNavigationInfo.h"
|
||||||
|
|
||||||
// uriloader
|
// uriloader
|
||||||
#include "nsURILoader.h"
|
#include "nsURILoader.h"
|
||||||
|
@ -61,6 +65,7 @@
|
||||||
// docshell
|
// docshell
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init)
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
|
||||||
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
|
||||||
|
|
||||||
// uriloader
|
// uriloader
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
|
||||||
|
@ -99,6 +104,11 @@ static const nsModuleComponentInfo gDocShellModuleInfo[] = {
|
||||||
NS_URIFIXUP_CONTRACTID,
|
NS_URIFIXUP_CONTRACTID,
|
||||||
nsDefaultURIFixupConstructor
|
nsDefaultURIFixupConstructor
|
||||||
},
|
},
|
||||||
|
{ "Webnavigation info service",
|
||||||
|
NS_WEBNAVIGATION_INFO_CID,
|
||||||
|
NS_WEBNAVIGATION_INFO_CONTRACTID,
|
||||||
|
nsWebNavigationInfoConstructor
|
||||||
|
},
|
||||||
|
|
||||||
// uriloader
|
// uriloader
|
||||||
{ "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, },
|
{ "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, },
|
||||||
|
|
|
@ -43,9 +43,11 @@
|
||||||
|
|
||||||
#include "WebBrowserContainer.h"
|
#include "WebBrowserContainer.h"
|
||||||
|
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
|
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
|
||||||
CWebBrowserContainer::CWebBrowserContainer(CMozillaBrowser *pOwner) :
|
CWebBrowserContainer::CWebBrowserContainer(CMozillaBrowser *pOwner) :
|
||||||
mOwner(pOwner),
|
mOwner(pOwner),
|
||||||
mEvents1(mOwner),
|
mEvents1(mOwner),
|
||||||
|
@ -405,28 +407,25 @@ NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, char *
|
||||||
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
|
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
|
||||||
{
|
{
|
||||||
*_retval = PR_FALSE;
|
*_retval = PR_FALSE;
|
||||||
|
*aDesiredContentType = nsnull;
|
||||||
|
|
||||||
if (aContentType)
|
if (aContentType)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsICategoryManager> catMgr;
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mOwner->mWebBrowser));
|
||||||
nsresult rv;
|
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||||
catMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
do_GetService("@mozilla.org/webnavigation-info;1"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (webNavInfo)
|
||||||
nsXPIDLCString value;
|
{
|
||||||
rv = catMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
PRUint32 canHandle;
|
||||||
aContentType,
|
nsresult rv =
|
||||||
getter_Copies(value));
|
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
|
webNav,
|
||||||
// If the category manager can't find what we're looking for
|
&canHandle);
|
||||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// that to the caller since it's really not a failure
|
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
|
}
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
if (value && *value)
|
|
||||||
*_retval = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,9 @@
|
||||||
#include "EmbedContentListener.h"
|
#include "EmbedContentListener.h"
|
||||||
#include "EmbedPrivate.h"
|
#include "EmbedPrivate.h"
|
||||||
|
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
|
|
||||||
EmbedContentListener::EmbedContentListener(void)
|
EmbedContentListener::EmbedContentListener(void)
|
||||||
{
|
{
|
||||||
|
@ -114,26 +115,20 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||||
PRBool *_retval)
|
PRBool *_retval)
|
||||||
{
|
{
|
||||||
*_retval = PR_FALSE;
|
*_retval = PR_FALSE;
|
||||||
|
*aDesiredContentType = nsnull;
|
||||||
|
|
||||||
if (aContentType) {
|
if (aContentType) {
|
||||||
nsCOMPtr<nsICategoryManager> catMgr;
|
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||||
nsresult rv;
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
if (webNavInfo) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
PRUint32 canHandle;
|
||||||
nsXPIDLCString value;
|
nsresult rv =
|
||||||
rv = catMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
aContentType,
|
mOwner ? mOwner->mNavigation : nsnull,
|
||||||
getter_Copies(value));
|
&canHandle);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// If the category manager can't find what we're looking for
|
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
}
|
||||||
// that to the caller since it's really not a failure
|
|
||||||
|
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
if (value && *value)
|
|
||||||
*_retval = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,9 @@
|
||||||
|
|
||||||
#include "PtMozilla.h"
|
#include "PtMozilla.h"
|
||||||
|
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
|
|
||||||
EmbedContentListener::EmbedContentListener(void)
|
EmbedContentListener::EmbedContentListener(void)
|
||||||
{
|
{
|
||||||
|
@ -126,26 +127,20 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||||
PRBool *_retval)
|
PRBool *_retval)
|
||||||
{
|
{
|
||||||
*_retval = PR_FALSE;
|
*_retval = PR_FALSE;
|
||||||
|
*aDesiredContentType = nsnull;
|
||||||
|
|
||||||
if (aContentType) {
|
if (aContentType) {
|
||||||
nsCOMPtr<nsICategoryManager> catMgr;
|
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||||
nsresult rv;
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
if (webNavInfo) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
PRUint32 canHandle;
|
||||||
nsXPIDLCString value;
|
nsresult rv =
|
||||||
rv = catMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
aContentType,
|
mOwner ? mOwner->mNavigation : nsnull,
|
||||||
getter_Copies(value));
|
&canHandle);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// If the category manager can't find what we're looking for
|
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
}
|
||||||
// that to the caller since it's really not a failure
|
|
||||||
|
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
if (value && *value)
|
|
||||||
*_retval = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,9 @@
|
||||||
#include "EmbedContentListener.h"
|
#include "EmbedContentListener.h"
|
||||||
#include "qgeckoembed.h"
|
#include "qgeckoembed.h"
|
||||||
|
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
|
|
||||||
EmbedContentListener::EmbedContentListener(QGeckoEmbed *aOwner)
|
EmbedContentListener::EmbedContentListener(QGeckoEmbed *aOwner)
|
||||||
{
|
{
|
||||||
|
@ -107,27 +108,21 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||||
PRBool *_retval)
|
PRBool *_retval)
|
||||||
{
|
{
|
||||||
*_retval = PR_FALSE;
|
*_retval = PR_FALSE;
|
||||||
|
*aDesiredContentType = nsnull;
|
||||||
qDebug("HANDLING:");
|
qDebug("HANDLING:");
|
||||||
|
|
||||||
if (aContentType) {
|
if (aContentType) {
|
||||||
nsCOMPtr<nsICategoryManager> catMgr;
|
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||||
nsresult rv;
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
if (webNavInfo) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
PRUint32 canHandle;
|
||||||
nsXPIDLCString value;
|
nsresult rv =
|
||||||
rv = catMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
aContentType,
|
mOwner ? mOwner->d->navigation : nsnull,
|
||||||
getter_Copies(value));
|
&canHandle);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// If the category manager can't find what we're looking for
|
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
}
|
||||||
// that to the caller since it's really not a failure
|
|
||||||
|
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
if (value && *value)
|
|
||||||
*_retval = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("\tCan handle content %s: %d", aContentType, *_retval);
|
qDebug("\tCan handle content %s: %d", aContentType, *_retval);
|
||||||
|
|
|
@ -77,6 +77,9 @@
|
||||||
#include "nsLayoutAtoms.h"
|
#include "nsLayoutAtoms.h"
|
||||||
#include "nsIDocShellTreeItem.h"
|
#include "nsIDocShellTreeItem.h"
|
||||||
#include "nsIDocShellTreeOwner.h"
|
#include "nsIDocShellTreeOwner.h"
|
||||||
|
#include "nsIWebNavigation.h"
|
||||||
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
#include "nsIWebBrowserChrome.h"
|
#include "nsIWebBrowserChrome.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIDOMNodeList.h"
|
#include "nsIDOMNodeList.h"
|
||||||
|
@ -500,25 +503,22 @@ IsSupportedImageMimeType(const char *aMimeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
IsSupportedDocumentMimeType(const char *aMimeType)
|
IsSupportedDocumentMimeType(nsIContent* aOurContent,
|
||||||
|
const nsCString& aMimeType)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsICategoryManager> catman =
|
nsresult rv;
|
||||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
nsCOMPtr<nsIWebNavigationInfo> info(
|
||||||
if (!catman)
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv));
|
||||||
return PR_FALSE;
|
PRUint32 supported;
|
||||||
|
if (info) {
|
||||||
nsXPIDLCString value;
|
nsCOMPtr<nsIWebNavigation> webNav =
|
||||||
nsresult rv = catman->GetCategoryEntry("Gecko-Content-Viewers", aMimeType,
|
do_GetInterface(aOurContent->GetCurrentDoc()->GetScriptGlobalObject());
|
||||||
getter_Copies(value));
|
rv = info->IsTypeSupported(aMimeType, webNav, &supported);
|
||||||
|
}
|
||||||
// If we have a content viewer entry in the catagory manager for
|
|
||||||
// this mime type and it's not the full-page plugin one, return
|
|
||||||
// PR_TRUE to act like an IFRAME.
|
|
||||||
return
|
|
||||||
NS_SUCCEEDED(rv) &&
|
|
||||||
!value.IsEmpty() &&
|
|
||||||
!value.Equals("@mozilla.org/content/plugin/document-loader-factory;1");
|
|
||||||
|
|
||||||
|
return NS_SUCCEEDED(rv) &&
|
||||||
|
supported != nsIWebNavigationInfo::UNSUPPORTED &&
|
||||||
|
supported != nsIWebNavigationInfo::PLUGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -621,7 +621,7 @@ nsObjectFrame::IsSupportedDocument(nsIContent* aContent)
|
||||||
#endif
|
#endif
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
return IsSupportedDocumentMimeType(typeStr.get());
|
return IsSupportedDocumentMimeType(aContent, typeStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -3072,6 +3072,11 @@ void nsObjectFrame::FixUpURLS(const nsString &name, nsAString &value)
|
||||||
void
|
void
|
||||||
nsObjectFrame::PluginNotAvailable(const char *aMimeType)
|
nsObjectFrame::PluginNotAvailable(const char *aMimeType)
|
||||||
{
|
{
|
||||||
|
if (!aMimeType) {
|
||||||
|
NS_ERROR("bogus type... behavior will be broken");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Tell mContent about the mime type
|
// Tell mContent about the mime type
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLObjectElement> object(do_QueryInterface(mContent));
|
nsCOMPtr<nsIDOMHTMLObjectElement> object(do_QueryInterface(mContent));
|
||||||
|
@ -3094,7 +3099,7 @@ nsObjectFrame::PluginNotAvailable(const char *aMimeType)
|
||||||
// For non-image and non-document mime types, fire the plugin not
|
// For non-image and non-document mime types, fire the plugin not
|
||||||
// found event and mark this plugin as broken.
|
// found event and mark this plugin as broken.
|
||||||
if (!IsSupportedImageMimeType(aMimeType) &&
|
if (!IsSupportedImageMimeType(aMimeType) &&
|
||||||
!IsSupportedDocumentMimeType(aMimeType)) {
|
!IsSupportedDocumentMimeType(mContent, nsDependentCString(aMimeType))) {
|
||||||
FirePluginNotFoundEvent(mContent);
|
FirePluginNotFoundEvent(mContent);
|
||||||
|
|
||||||
mIsBrokenPlugin = PR_TRUE;
|
mIsBrokenPlugin = PR_TRUE;
|
||||||
|
|
|
@ -1,174 +0,0 @@
|
||||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/* ***** 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
|
|
||||||
* Netscape Communications Corporation.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Alec Flett <alecf@netscape.com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either of 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 mediatorContractId = "@mozilla.org/appshell/window-mediator;1";
|
|
||||||
const nsIWebBrowserChrome = Components.interfaces.nsIWebBrowserChrome;
|
|
||||||
|
|
||||||
function nsBrowserContentListener(toplevelWindow, contentWindow)
|
|
||||||
{
|
|
||||||
// this one is not as easy as you would hope.
|
|
||||||
// need to convert toplevelWindow to an XPConnected object, instead
|
|
||||||
// of a DOM-based object, to be able to QI() it to nsIXULWindow
|
|
||||||
|
|
||||||
this.init(toplevelWindow, contentWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* implements nsIURIContentListener */
|
|
||||||
|
|
||||||
nsBrowserContentListener.prototype =
|
|
||||||
{
|
|
||||||
init: function(toplevelWindow, contentWindow)
|
|
||||||
{
|
|
||||||
this.toplevelWindow = toplevelWindow;
|
|
||||||
this.contentWindow = contentWindow;
|
|
||||||
|
|
||||||
// hook up the whole parent chain thing
|
|
||||||
var windowDocShell = this.convertWindowToDocShell(toplevelWindow);
|
|
||||||
if (windowDocShell) {
|
|
||||||
windowDocshell
|
|
||||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Components.interfaces.nsIURIContentListener)
|
|
||||||
.parentContentListener = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
var registerWindow = false;
|
|
||||||
try {
|
|
||||||
var treeItem = contentWindow.docShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem);
|
|
||||||
var treeOwner = treeItem.treeOwner;
|
|
||||||
var interfaceRequestor = treeOwner.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
|
||||||
var webBrowserChrome = interfaceRequestor.getInterface(nsIWebBrowserChrome);
|
|
||||||
if (webBrowserChrome)
|
|
||||||
{
|
|
||||||
var chromeFlags = webBrowserChrome.chromeFlags;
|
|
||||||
var res = chromeFlags & nsIWebBrowserChrome.CHROME_ALL;
|
|
||||||
var res2 = chromeFlags & nsIWebBrowserChrome.CHROME_DEFAULT;
|
|
||||||
if ( res == nsIWebBrowserChrome.CHROME_ALL || res2 == nsIWebBrowserChrome.CHROME_DEFAULT)
|
|
||||||
{
|
|
||||||
registerWindow = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (ex) {}
|
|
||||||
|
|
||||||
// register ourselves
|
|
||||||
if (registerWindow)
|
|
||||||
{
|
|
||||||
var uriLoader = Components.classes["@mozilla.org/uriloader;1"].getService(Components.interfaces.nsIURILoader);
|
|
||||||
uriLoader.registerContentListener(this);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
close: function()
|
|
||||||
{
|
|
||||||
this.contentWindow = null;
|
|
||||||
var uriLoader = Components.classes["@mozilla.org/uriloader;1"].getService(Components.interfaces.nsIURILoader);
|
|
||||||
|
|
||||||
uriLoader.unRegisterContentListener(this);
|
|
||||||
},
|
|
||||||
QueryInterface: function(iid)
|
|
||||||
{
|
|
||||||
if (iid.equals(Components.interfaces.nsIURIContentListener) ||
|
|
||||||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
|
||||||
iid.equals(Components.interfaces.nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onStartURIOpen: function(uri)
|
|
||||||
{
|
|
||||||
// ignore and don't abort
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
doContent: function(contentType, isContentPreferred, request, contentHandler)
|
|
||||||
{
|
|
||||||
// forward the doContent to our content area webshell
|
|
||||||
var docShell = this.contentWindow.docShell;
|
|
||||||
var contentListener;
|
|
||||||
try {
|
|
||||||
contentListener =
|
|
||||||
docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Components.interfaces.nsIURIContentListener);
|
|
||||||
} catch (ex) {
|
|
||||||
dump(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!contentListener) return false;
|
|
||||||
|
|
||||||
return contentListener.doContent(contentType, isContentPreferred, request, contentHandler);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
isPreferred: function(contentType, desiredContentType)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var catMgr = Components.classes["@mozilla.org/categorymanager;1"]
|
|
||||||
.getService(Components.interfaces.nsICategoryManager);
|
|
||||||
var entry = catMgr.getCategoryEntry("Gecko-Content-Viewers",
|
|
||||||
contentType);
|
|
||||||
if (entry) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (e) {
|
|
||||||
// XXX propagate failures other than "NS_ERROR_NOT_AVAILABLE"?
|
|
||||||
// This seems to never get called, so not like it matters....
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canHandleContent: function(contentType, isContentPreferred, desiredContentType)
|
|
||||||
{
|
|
||||||
var docShell = this.contentWindow.docShell;
|
|
||||||
var contentListener;
|
|
||||||
try {
|
|
||||||
contentListener =
|
|
||||||
docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIURIContentListener);
|
|
||||||
} catch (ex) {
|
|
||||||
dump(ex);
|
|
||||||
}
|
|
||||||
if (!contentListener) return false;
|
|
||||||
|
|
||||||
return contentListener.canHandleContent(contentType, isContentPreferred, desiredContentType);
|
|
||||||
},
|
|
||||||
convertWindowToDocShell: function(win) {
|
|
||||||
// don't know how to do this
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
loadCookie: null,
|
|
||||||
parentContentListener: null
|
|
||||||
}
|
|
|
@ -45,7 +45,8 @@
|
||||||
|
|
||||||
// Interfaces Needed
|
// Interfaces Needed
|
||||||
#include "nsIBaseWindow.h"
|
#include "nsIBaseWindow.h"
|
||||||
#include "nsICategoryManager.h"
|
#include "nsIWebNavigationInfo.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
#include "nsIDocShellTreeItem.h"
|
#include "nsIDocShellTreeItem.h"
|
||||||
#include "nsIHttpProtocolHandler.h"
|
#include "nsIHttpProtocolHandler.h"
|
||||||
|
@ -791,21 +792,21 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
|
||||||
nsIInterfaceRequestor * aWindowContext,
|
nsIInterfaceRequestor * aWindowContext,
|
||||||
nsIRequest * aRequest)
|
nsIRequest * aRequest)
|
||||||
{
|
{
|
||||||
|
NS_PRECONDITION(aContentType, "Must have a content type");
|
||||||
|
|
||||||
// Verify that we can handle this content, to avoid infinite window opening
|
// Verify that we can handle this content, to avoid infinite window opening
|
||||||
// loops
|
// loops
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsICategoryManager> catMan =
|
nsCOMPtr<nsIWebNavigationInfo> webNavInfo =
|
||||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsXPIDLCString value;
|
PRUint32 typeSupported;
|
||||||
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers",
|
rv = webNavInfo->IsTypeSupported(nsDependentCString(aContentType), nsnull,
|
||||||
aContentType,
|
&typeSupported);
|
||||||
getter_Copies(value));
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// If there is no value (i.e. rv is NS_ERROR_NOT_AVAILABLE), we can't handle
|
if (!typeSupported)
|
||||||
// the content.
|
|
||||||
if (rv == NS_ERROR_NOT_AVAILABLE)
|
|
||||||
return NS_ERROR_WONT_HANDLE_CONTENT;
|
return NS_ERROR_WONT_HANDLE_CONTENT;
|
||||||
|
|
||||||
// create a new browser window to handle the content
|
// create a new browser window to handle the content
|
||||||
|
|
|
@ -315,9 +315,10 @@
|
||||||
// Check if Mozilla can handle this type internally, in which case
|
// Check if Mozilla can handle this type internally, in which case
|
||||||
// an entry would have no effect
|
// an entry would have no effect
|
||||||
try {
|
try {
|
||||||
var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
|
var webNavigationInfo =
|
||||||
.getService(Components.interfaces.nsICategoryManager);
|
Components.classes["@mozilla.org/webnavigation-info;1"]
|
||||||
if (categoryManager.getCategoryEntry("Gecko-Content-Viewers", gMIMEField.value)) {
|
.getService(Components.interfaces.nsIWebNavigationInfo);
|
||||||
|
if (webNavigationInfo.isTypeSupported(gMIMEField.value, null)) {
|
||||||
var brandBundle = document.getElementById("bundle_Brand");
|
var brandBundle = document.getElementById("bundle_Brand");
|
||||||
var text = gPrefApplicationsBundle.getString("canHandleInternally");
|
var text = gPrefApplicationsBundle.getString("canHandleInternally");
|
||||||
text = text.replace(/%brand%/g, brandBundle.getString("brandShortName"));
|
text = text.replace(/%brand%/g, brandBundle.getString("brandShortName"));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче