mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
151db44859
--HG-- rename : embedding/browser/webBrowser/nsCTooltipTextProvider.h => embedding/browser/nsCTooltipTextProvider.h rename : embedding/browser/webBrowser/nsCWebBrowser.idl => embedding/browser/nsCWebBrowser.idl rename : embedding/browser/webBrowser/nsCommandHandler.cpp => embedding/browser/nsCommandHandler.cpp rename : embedding/browser/webBrowser/nsCommandHandler.h => embedding/browser/nsCommandHandler.h rename : embedding/browser/webBrowser/nsContextMenuInfo.cpp => embedding/browser/nsContextMenuInfo.cpp rename : embedding/browser/webBrowser/nsContextMenuInfo.h => embedding/browser/nsContextMenuInfo.h rename : embedding/browser/webBrowser/nsDocShellTreeOwner.cpp => embedding/browser/nsDocShellTreeOwner.cpp rename : embedding/browser/webBrowser/nsDocShellTreeOwner.h => embedding/browser/nsDocShellTreeOwner.h rename : embedding/browser/webBrowser/nsEmbedStream.cpp => embedding/browser/nsEmbedStream.cpp rename : embedding/browser/webBrowser/nsEmbedStream.h => embedding/browser/nsEmbedStream.h rename : embedding/browser/webBrowser/nsICommandHandler.idl => embedding/browser/nsICommandHandler.idl rename : embedding/browser/webBrowser/nsIContextMenuListener.idl => embedding/browser/nsIContextMenuListener.idl rename : embedding/browser/webBrowser/nsIContextMenuListener2.idl => embedding/browser/nsIContextMenuListener2.idl rename : embedding/browser/webBrowser/nsIEmbeddingSiteWindow.idl => embedding/browser/nsIEmbeddingSiteWindow.idl rename : embedding/browser/webBrowser/nsIPrintPreviewNavigation.idl => embedding/browser/nsIPrintPreviewNavigation.idl rename : embedding/browser/webBrowser/nsIPrintingPrompt.idl => embedding/browser/nsIPrintingPrompt.idl rename : embedding/browser/webBrowser/nsIPrintingPromptService.idl => embedding/browser/nsIPrintingPromptService.idl rename : embedding/browser/webBrowser/nsITooltipListener.idl => embedding/browser/nsITooltipListener.idl rename : embedding/browser/webBrowser/nsITooltipTextProvider.idl => embedding/browser/nsITooltipTextProvider.idl rename : embedding/browser/webBrowser/nsIWebBrowser.idl => embedding/browser/nsIWebBrowser.idl rename : embedding/browser/webBrowser/nsIWebBrowserChrome.idl => embedding/browser/nsIWebBrowserChrome.idl rename : embedding/browser/webBrowser/nsIWebBrowserChrome2.idl => embedding/browser/nsIWebBrowserChrome2.idl rename : embedding/browser/webBrowser/nsIWebBrowserChrome3.idl => embedding/browser/nsIWebBrowserChrome3.idl rename : embedding/browser/webBrowser/nsIWebBrowserChromeFocus.idl => embedding/browser/nsIWebBrowserChromeFocus.idl rename : embedding/browser/webBrowser/nsIWebBrowserFocus.idl => embedding/browser/nsIWebBrowserFocus.idl rename : embedding/browser/webBrowser/nsIWebBrowserPrint.idl => embedding/browser/nsIWebBrowserPrint.idl rename : embedding/browser/webBrowser/nsIWebBrowserSetup.idl => embedding/browser/nsIWebBrowserSetup.idl rename : embedding/browser/webBrowser/nsIWebBrowserStream.idl => embedding/browser/nsIWebBrowserStream.idl rename : embedding/browser/webBrowser/nsWebBrowser.cpp => embedding/browser/nsWebBrowser.cpp rename : embedding/browser/webBrowser/nsWebBrowser.h => embedding/browser/nsWebBrowser.h rename : embedding/browser/webBrowser/nsWebBrowserContentPolicy.cpp => embedding/browser/nsWebBrowserContentPolicy.cpp rename : embedding/browser/webBrowser/nsWebBrowserContentPolicy.h => embedding/browser/nsWebBrowserContentPolicy.h
103 lines
3.5 KiB
C++
103 lines
3.5 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* vim: ft=cpp tw=78 sw=4 et ts=8
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsWebBrowserContentPolicy.h"
|
|
#include "nsIDocShell.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsContentPolicyUtils.h"
|
|
#include "nsIContentViewer.h"
|
|
|
|
nsWebBrowserContentPolicy::nsWebBrowserContentPolicy()
|
|
{
|
|
MOZ_COUNT_CTOR(nsWebBrowserContentPolicy);
|
|
}
|
|
|
|
nsWebBrowserContentPolicy::~nsWebBrowserContentPolicy()
|
|
{
|
|
MOZ_COUNT_DTOR(nsWebBrowserContentPolicy);
|
|
}
|
|
|
|
NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
|
|
|
|
NS_IMETHODIMP
|
|
nsWebBrowserContentPolicy::ShouldLoad(uint32_t contentType,
|
|
nsIURI *contentLocation,
|
|
nsIURI *requestingLocation,
|
|
nsISupports *requestingContext,
|
|
const nsACString &mimeGuess,
|
|
nsISupports *extra,
|
|
nsIPrincipal *requestPrincipal,
|
|
int16_t *shouldLoad)
|
|
{
|
|
NS_PRECONDITION(shouldLoad, "Null out param");
|
|
|
|
*shouldLoad = nsIContentPolicy::ACCEPT;
|
|
|
|
nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
|
|
/* We're going to dereference shell, so make sure it isn't null */
|
|
if (!shell) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult rv;
|
|
bool allowed = true;
|
|
|
|
switch (contentType) {
|
|
case nsIContentPolicy::TYPE_SCRIPT:
|
|
rv = shell->GetAllowJavascript(&allowed);
|
|
break;
|
|
case nsIContentPolicy::TYPE_SUBDOCUMENT:
|
|
rv = shell->GetAllowSubframes(&allowed);
|
|
break;
|
|
#if 0
|
|
/* XXXtw: commented out in old code; add during conpol phase 2 */
|
|
case nsIContentPolicy::TYPE_REFRESH:
|
|
rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
|
|
break;
|
|
#endif
|
|
case nsIContentPolicy::TYPE_IMAGE:
|
|
rv = shell->GetAllowImages(&allowed);
|
|
break;
|
|
default:
|
|
return NS_OK;
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && !allowed) {
|
|
*shouldLoad = nsIContentPolicy::REJECT_TYPE;
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsWebBrowserContentPolicy::ShouldProcess(uint32_t contentType,
|
|
nsIURI *contentLocation,
|
|
nsIURI *requestingLocation,
|
|
nsISupports *requestingContext,
|
|
const nsACString &mimeGuess,
|
|
nsISupports *extra,
|
|
nsIPrincipal *requestPrincipal,
|
|
int16_t *shouldProcess)
|
|
{
|
|
NS_PRECONDITION(shouldProcess, "Null out param");
|
|
|
|
*shouldProcess = nsIContentPolicy::ACCEPT;
|
|
|
|
// Object tags will always open channels with TYPE_OBJECT, but may end up
|
|
// loading with TYPE_IMAGE or TYPE_DOCUMENT as their final type, so we block
|
|
// actual-plugins at the process stage
|
|
if (contentType != nsIContentPolicy::TYPE_OBJECT) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
|
|
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
|
|
*shouldProcess = nsIContentPolicy::REJECT_TYPE;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|