зеркало из 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 nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
|
||||
const nsICategoryManager = Components.interfaces.nsICategoryManager;
|
||||
const nsIWebNavigationInfo = Components.interfaces.nsIWebNavigationInfo;
|
||||
|
||||
const NS_BINDING_ABORTED = 0x80020006;
|
||||
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
||||
|
@ -248,10 +249,11 @@ var nsBrowserContentHandler = {
|
|||
|
||||
handleContent : function bch_handleContent(contentType, context, request) {
|
||||
try {
|
||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(nsICategoryManager);
|
||||
var entry = catMan.getCategoryEntry("Gecko-Content-Viewers",
|
||||
contentType);
|
||||
var webNavInfo = Components.classes["@mozilla.org/webnavigation-info;1"]
|
||||
.getService(nsIWebNavigationInfo);
|
||||
if (!webNavInfo.isTypeSupported(contentType, null)) {
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
}
|
||||
} catch (e) {
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ REQUIRES = xpcom \
|
|||
commandhandler \
|
||||
editor \
|
||||
windowwatcher \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
|
@ -106,6 +107,7 @@ XPIDLSRCS = \
|
|||
nsIScrollable.idl \
|
||||
nsITextScroll.idl \
|
||||
nsIWebNavigation.idl \
|
||||
nsIWebNavigationInfo.idl \
|
||||
nsIContentViewer.idl \
|
||||
nsIContentViewerEdit.idl \
|
||||
nsIContentViewerFile.idl \
|
||||
|
@ -125,6 +127,7 @@ CPPSRCS = \
|
|||
nsDefaultURIFixup.cpp \
|
||||
nsGlobalHistoryAdapter.cpp \
|
||||
nsGlobalHistory2Adapter.cpp \
|
||||
nsWebNavigationInfo.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
|
|
|
@ -40,9 +40,10 @@
|
|||
#include "nsDocShell.h"
|
||||
#include "nsDSURIContentListener.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPluginManager.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
|
@ -63,9 +64,9 @@ nsDSURIContentListener::~nsDSURIContentListener()
|
|||
nsresult
|
||||
nsDSURIContentListener::Init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
mCatMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv;
|
||||
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -182,38 +183,22 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
|||
char ** aDesiredContentType,
|
||||
PRBool* aCanHandleContent)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aCanHandleContent);
|
||||
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
if (aContentType && mCatMgr)
|
||||
{
|
||||
rv = IsTypeSupported(aContentType, aCanHandleContent);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!*aCanHandleContent) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
if (aContentType) {
|
||||
PRUint32 canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mDocShell,
|
||||
&canHandle);
|
||||
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -275,30 +260,3 @@ nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
|
|||
}
|
||||
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 "nsString.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsDocShell;
|
||||
class nsIWebNavigationInfo;
|
||||
|
||||
class nsDSURIContentListener :
|
||||
public nsIURIContentListener,
|
||||
|
@ -68,12 +68,6 @@ protected:
|
|||
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:
|
||||
nsDocShell* mDocShell;
|
||||
|
||||
|
@ -83,7 +77,7 @@ protected:
|
|||
nsWeakPtr mWeakParentContentListener;
|
||||
nsIURIContentListener* mParentContentListener;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> mCatMgr;
|
||||
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
||||
};
|
||||
|
||||
#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 \
|
||||
rdf \
|
||||
prefetch \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -41,4 +41,12 @@
|
|||
#define NS_GLOBALHISTORY2_CONTRACTID \
|
||||
"@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__
|
||||
|
|
|
@ -39,8 +39,12 @@
|
|||
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
#include "nsWebShell.h"
|
||||
#include "nsDefaultURIFixup.h"
|
||||
#include "nsWebNavigationInfo.h"
|
||||
|
||||
// uriloader
|
||||
#include "nsURILoader.h"
|
||||
|
@ -61,6 +65,7 @@
|
|||
// docshell
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
|
||||
|
||||
// uriloader
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
|
||||
|
@ -99,6 +104,11 @@ static const nsModuleComponentInfo gDocShellModuleInfo[] = {
|
|||
NS_URIFIXUP_CONTRACTID,
|
||||
nsDefaultURIFixupConstructor
|
||||
},
|
||||
{ "Webnavigation info service",
|
||||
NS_WEBNAVIGATION_INFO_CID,
|
||||
NS_WEBNAVIGATION_INFO_CONTRACTID,
|
||||
nsWebNavigationInfoConstructor
|
||||
},
|
||||
|
||||
// uriloader
|
||||
{ "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, },
|
||||
|
|
|
@ -43,9 +43,11 @@
|
|||
|
||||
#include "WebBrowserContainer.h"
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
|
||||
CWebBrowserContainer::CWebBrowserContainer(CMozillaBrowser *pOwner) :
|
||||
mOwner(pOwner),
|
||||
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)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
if (aContentType)
|
||||
{
|
||||
nsCOMPtr<nsICategoryManager> catMgr;
|
||||
nsresult rv;
|
||||
catMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString value;
|
||||
rv = catMgr->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;
|
||||
|
||||
if (value && *value)
|
||||
*_retval = PR_TRUE;
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mOwner->mWebBrowser));
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService("@mozilla.org/webnavigation-info;1"));
|
||||
if (webNavInfo)
|
||||
{
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
webNav,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
#include "EmbedContentListener.h"
|
||||
#include "EmbedPrivate.h"
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
EmbedContentListener::EmbedContentListener(void)
|
||||
{
|
||||
|
@ -114,26 +115,20 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
|||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsICategoryManager> catMgr;
|
||||
nsresult rv;
|
||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString value;
|
||||
rv = catMgr->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;
|
||||
|
||||
if (value && *value)
|
||||
*_retval = PR_TRUE;
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
if (webNavInfo) {
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation : nsnull,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,9 @@
|
|||
|
||||
#include "PtMozilla.h"
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
EmbedContentListener::EmbedContentListener(void)
|
||||
{
|
||||
|
@ -126,26 +127,20 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
|||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsICategoryManager> catMgr;
|
||||
nsresult rv;
|
||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString value;
|
||||
rv = catMgr->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;
|
||||
|
||||
if (value && *value)
|
||||
*_retval = PR_TRUE;
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
if (webNavInfo) {
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation : nsnull,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,9 @@
|
|||
#include "EmbedContentListener.h"
|
||||
#include "qgeckoembed.h"
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
EmbedContentListener::EmbedContentListener(QGeckoEmbed *aOwner)
|
||||
{
|
||||
|
@ -107,27 +108,21 @@ EmbedContentListener::CanHandleContent(const char *aContentType,
|
|||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
qDebug("HANDLING:");
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsICategoryManager> catMgr;
|
||||
nsresult rv;
|
||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString value;
|
||||
rv = catMgr->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;
|
||||
|
||||
if (value && *value)
|
||||
*_retval = PR_TRUE;
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
if (webNavInfo) {
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->d->navigation : nsnull,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("\tCan handle content %s: %d", aContentType, *_retval);
|
||||
|
|
|
@ -77,6 +77,9 @@
|
|||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
@ -500,25 +503,22 @@ IsSupportedImageMimeType(const char *aMimeType)
|
|||
}
|
||||
|
||||
static PRBool
|
||||
IsSupportedDocumentMimeType(const char *aMimeType)
|
||||
IsSupportedDocumentMimeType(nsIContent* aOurContent,
|
||||
const nsCString& aMimeType)
|
||||
{
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
||||
if (!catman)
|
||||
return PR_FALSE;
|
||||
|
||||
nsXPIDLCString value;
|
||||
nsresult rv = catman->GetCategoryEntry("Gecko-Content-Viewers", aMimeType,
|
||||
getter_Copies(value));
|
||||
|
||||
// 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");
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebNavigationInfo> info(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv));
|
||||
PRUint32 supported;
|
||||
if (info) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav =
|
||||
do_GetInterface(aOurContent->GetCurrentDoc()->GetScriptGlobalObject());
|
||||
rv = info->IsTypeSupported(aMimeType, webNav, &supported);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv) &&
|
||||
supported != nsIWebNavigationInfo::UNSUPPORTED &&
|
||||
supported != nsIWebNavigationInfo::PLUGIN;
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -621,7 +621,7 @@ nsObjectFrame::IsSupportedDocument(nsIContent* aContent)
|
|||
#endif
|
||||
return PR_FALSE;
|
||||
|
||||
return IsSupportedDocumentMimeType(typeStr.get());
|
||||
return IsSupportedDocumentMimeType(aContent, typeStr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3072,6 +3072,11 @@ void nsObjectFrame::FixUpURLS(const nsString &name, nsAString &value)
|
|||
void
|
||||
nsObjectFrame::PluginNotAvailable(const char *aMimeType)
|
||||
{
|
||||
if (!aMimeType) {
|
||||
NS_ERROR("bogus type... behavior will be broken");
|
||||
return;
|
||||
}
|
||||
|
||||
// Tell mContent about the mime type
|
||||
|
||||
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
|
||||
// found event and mark this plugin as broken.
|
||||
if (!IsSupportedImageMimeType(aMimeType) &&
|
||||
!IsSupportedDocumentMimeType(aMimeType)) {
|
||||
!IsSupportedDocumentMimeType(mContent, nsDependentCString(aMimeType))) {
|
||||
FirePluginNotFoundEvent(mContent);
|
||||
|
||||
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
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
|
@ -791,21 +792,21 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
|
|||
nsIInterfaceRequestor * aWindowContext,
|
||||
nsIRequest * aRequest)
|
||||
{
|
||||
NS_PRECONDITION(aContentType, "Must have a content type");
|
||||
|
||||
// Verify that we can handle this content, to avoid infinite window opening
|
||||
// loops
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catMan =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo =
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString value;
|
||||
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers",
|
||||
aContentType,
|
||||
getter_Copies(value));
|
||||
PRUint32 typeSupported;
|
||||
rv = webNavInfo->IsTypeSupported(nsDependentCString(aContentType), nsnull,
|
||||
&typeSupported);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If there is no value (i.e. rv is NS_ERROR_NOT_AVAILABLE), we can't handle
|
||||
// the content.
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE)
|
||||
if (!typeSupported)
|
||||
return NS_ERROR_WONT_HANDLE_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
|
||||
// an entry would have no effect
|
||||
try {
|
||||
var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(Components.interfaces.nsICategoryManager);
|
||||
if (categoryManager.getCategoryEntry("Gecko-Content-Viewers", gMIMEField.value)) {
|
||||
var webNavigationInfo =
|
||||
Components.classes["@mozilla.org/webnavigation-info;1"]
|
||||
.getService(Components.interfaces.nsIWebNavigationInfo);
|
||||
if (webNavigationInfo.isTypeSupported(gMIMEField.value, null)) {
|
||||
var brandBundle = document.getElementById("bundle_Brand");
|
||||
var text = gPrefApplicationsBundle.getString("canHandleInternally");
|
||||
text = text.replace(/%brand%/g, brandBundle.getString("brandShortName"));
|
||||
|
|
Загрузка…
Ссылка в новой задаче