summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins')
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp2
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp16
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm18
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.h58
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm180
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp37
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h4
7 files changed, 274 insertions, 41 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
index f0ed9f74c..802c2dfde 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
@@ -190,7 +190,7 @@ bool NPJSObject::setProperty(NPIdentifier propertyName, const NPVariant* value)
PutPropertySlot slot;
m_jsObject->methodTable()->put(m_jsObject.get(), exec, identifierFromIdentifierRep(exec, identifierRep), jsValue, slot);
} else
- m_jsObject->methodTable()->putByIndex(m_jsObject.get(), exec, identifierRep->number(), jsValue);
+ m_jsObject->methodTable()->putByIndex(m_jsObject.get(), exec, identifierRep->number(), jsValue, false);
exec->clearException();
return true;
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index e09ada40a..bdc6e9de9 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -36,6 +36,10 @@
#include <WebCore/SharedBuffer.h>
#include <utility>
+#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#include "NetscapeSandboxFunctions.h"
+#endif
+
using namespace WebCore;
using namespace std;
@@ -411,6 +415,8 @@ static const unsigned WKNVExpectsNonretainedLayer = 74657;
// Whether plug-in code is allowed to enter (arbitrary) sandbox for the process.
static const unsigned WKNVAllowedToEnterSandbox = 74658;
+// WKNVSandboxFunctions = 74659 is defined in NetscapeSandboxFunctions.h
+
// The Core Animation render server port.
static const unsigned WKNVCALayerRenderServerPort = 71879;
@@ -418,7 +424,7 @@ static const unsigned WKNVCALayerRenderServerPort = 71879;
static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
{
- switch (variable) {
+ switch (static_cast<unsigned>(variable)) {
case NPNVWindowNPObject: {
RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
PluginDestructionProtector protector(plugin.get());
@@ -502,6 +508,14 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
*(NPBool*)value = true;
break;
+#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ case WKNVSandboxFunctions:
+ {
+ *(WKNSandboxFunctions **)value = netscapeSandboxFunctions();
+ break;
+ }
+#endif
+
#ifndef NP_NO_QUICKDRAW
case NPNVsupportsQuickDrawBool:
// We don't support the QuickDraw drawing model.
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
index 7e436958c..c8d53819f 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -532,12 +532,12 @@ static NPCocoaEvent initializeMouseEvent(const WebMouseEvent& mouseEvent, const
bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
{
+ IntPoint eventPositionInPluginCoordinates;
+ if (!convertFromRootView(mouseEvent.position(), eventPositionInPluginCoordinates))
+ return true;
+
switch (m_eventModel) {
case NPEventModelCocoa: {
- IntPoint eventPositionInPluginCoordinates;
- if (!convertFromRootView(mouseEvent.position(), eventPositionInPluginCoordinates))
- return true;
-
NPCocoaEvent event = initializeMouseEvent(mouseEvent, eventPositionInPluginCoordinates);
NPCocoaEvent* previousMouseEvent = m_currentMouseEvent;
@@ -579,8 +579,14 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
EventRecord event = initializeEventRecord(eventKind);
event.modifiers = modifiersForEvent(mouseEvent);
- event.where.h = mouseEvent.globalPosition().x();
- event.where.v = mouseEvent.globalPosition().y();
+
+ double globalX;
+ double globalY;
+ if (!convertPoint(eventPositionInPluginCoordinates.x(), eventPositionInPluginCoordinates.y(), NPCoordinateSpacePlugin, globalX, globalY, NPCoordinateSpaceFlippedScreen))
+ ASSERT_NOT_REACHED();
+
+ event.where.h = globalX;
+ event.where.v = globalY;
NPP_HandleEvent(&event);
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.h b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.h
new file mode 100644
index 000000000..4c77981b6
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NetscapeSandboxFunctions_h
+#define NetscapeSandboxFunctions_h
+
+#include <WebCore/npapi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WKNVSandboxFunctions 74659
+#define WKNVSandboxFunctionsVersionCurrent 1
+
+typedef NPError (*WKN_EnterSandboxProcPtr)(const char *readOnlyPaths[], const char *readWritePaths[]);
+typedef NPError (*WKN_FileStopAccessingProcPtr)(const char* path);
+
+NPError WKN_EnterSandbox(const char *readOnlyPaths[], const char *readWritePaths[]);
+NPError WKN_FileStopAccessing(const char* path);
+
+typedef struct _WKNSandboxFunctions {
+ uint16_t size;
+ uint16_t version;
+
+ WKN_EnterSandboxProcPtr enterSandbox;
+ WKN_FileStopAccessingProcPtr fileStopAccessing;
+} WKNSandboxFunctions;
+
+WKNSandboxFunctions* netscapeSandboxFunctions();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
new file mode 100644
index 000000000..43aea5faa
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetscapeSandboxFunctions.h"
+
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+
+#import "PluginProcess.h"
+#import "WebKitSystemInterface.h"
+#import <WebCore/FileSystem.h>
+#import <WebCore/SoftLinking.h>
+#import <sys/stat.h>
+#import <sysexits.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+#import <wtf/text/CString.h>
+
+SOFT_LINK_FRAMEWORK(CoreServices)
+SOFT_LINK_OPTIONAL(CoreServices, CFURLStopAccessingSecurityScopedResource, void, unused, (CFURLRef))
+
+using namespace WebKit;
+using namespace WebCore;
+
+WKNSandboxFunctions* netscapeSandboxFunctions()
+{
+ static WKNSandboxFunctions functions = {
+ sizeof(WKNSandboxFunctions),
+ WKNVSandboxFunctionsVersionCurrent,
+ WKN_EnterSandbox,
+ WKN_FileStopAccessing
+ };
+ return &functions;
+}
+
+static bool enteredSandbox;
+
+static CString readSandboxProfile()
+{
+ RetainPtr<CFURLRef> profileURL(AdoptCF, CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("plugin"), CFSTR("sb"), 0));
+ char profilePath[PATH_MAX];
+ if (!CFURLGetFileSystemRepresentation(profileURL.get(), false, reinterpret_cast<UInt8*>(profilePath), sizeof(profilePath))) {
+ fprintf(stderr, "Could not get file system representation of plug-in sandbox URL\n");
+ return CString();
+ }
+
+ FILE *file = fopen(profilePath, "r");
+ if (!file) {
+ fprintf(stderr, "Could not open plug-in sandbox file '%s'\n", profilePath);
+ return CString();
+ }
+
+ struct stat fileInfo;
+ if (stat(profilePath, &fileInfo)) {
+ fprintf(stderr, "Could not get plug-in sandbox file size '%s'\n", profilePath);
+ return CString();
+ }
+
+ char* characterBuffer;
+ CString result = CString::newUninitialized(fileInfo.st_size, characterBuffer);
+
+ if (1 != fread(characterBuffer, fileInfo.st_size, 1, file)) {
+ fprintf(stderr, "Could not read plug-in sandbox file '%s'\n", profilePath);
+ return CString();
+ }
+
+ fclose(file);
+
+ return result;
+}
+
+NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths[])
+{
+ if (enteredSandbox)
+ return NPERR_GENERIC_ERROR;
+
+ CString profile = readSandboxProfile();
+ if (profile.isNull())
+ exit(EX_NOPERM);
+
+ Vector<const char*> extendedReadOnlyPaths;
+ if (readOnlyPaths) {
+ for (unsigned i = 0; readOnlyPaths[i]; ++i)
+ extendedReadOnlyPaths.append(readOnlyPaths[i]);
+ }
+
+ CString pluginModulePath = fileSystemRepresentation(PluginProcess::shared().pluginPath());
+ extendedReadOnlyPaths.append(pluginModulePath.data());
+
+ // On-disk WebKit framework locations, to account for debug installations.
+ // Allowing the whole directory containing WebKit2.framework for the sake of APIs that implicitly load other WebKit frameworks.
+ // We don't want to load them now, and thus don't have any better idea of where they are located on disk.
+ extendedReadOnlyPaths.append([[[[[NSBundle bundleWithIdentifier:@"com.apple.WebKit2"] bundleURL] URLByDeletingLastPathComponent] path] fileSystemRepresentation]);
+
+ extendedReadOnlyPaths.append(static_cast<const char*>(0));
+
+ Vector<const char*> extendedReadWritePaths;
+ if (readWritePaths) {
+ for (unsigned i = 0; readWritePaths[i]; ++i)
+ extendedReadWritePaths.append(readWritePaths[i]);
+ }
+
+ // FIXME: <rdar://problem/10785457> Use a custom temporary directory.
+ char darwinUserTempDirectory[PATH_MAX];
+ if (confstr(_CS_DARWIN_USER_TEMP_DIR, darwinUserTempDirectory, PATH_MAX) > 0)
+ extendedReadWritePaths.append(darwinUserTempDirectory);
+
+ // FIXME: <rdar://problem/10792047> Use a custom cache directory.
+ char darwinUserCacheDirectory[PATH_MAX];
+ size_t darwinUserCachePathSize = confstr(_CS_DARWIN_USER_CACHE_DIR, darwinUserCacheDirectory, PATH_MAX);
+ if (darwinUserCachePathSize > 0)
+ extendedReadWritePaths.append(darwinUserCacheDirectory);
+
+ RetainPtr<CFStringRef> cachePath(AdoptCF, WKCopyFoundationCacheDirectory());
+ extendedReadWritePaths.append([(NSString *)cachePath.get() fileSystemRepresentation]);
+
+ extendedReadWritePaths.append(static_cast<const char*>(0));
+
+ // WKEnterPluginSandbox canonicalizes path arrays, but not parameters (because it cannot know if one is a path).
+ char* homeDirectory = realpath([NSHomeDirectory() fileSystemRepresentation], 0);
+ if (!homeDirectory)
+ exit(EX_NOPERM);
+ const char* sandboxParameters[] = { "HOME_DIR", homeDirectory, 0, 0 };
+
+ if (!WKEnterPluginSandbox(profile.data(), sandboxParameters, extendedReadOnlyPaths.data(), extendedReadWritePaths.data())) {
+ fprintf(stderr, "Couldn't initialize sandbox profile\n");
+ exit(EX_NOPERM);
+ }
+
+ if (noErr != WKEnableSandboxStyleFileQuarantine()) {
+ fprintf(stderr, "Couldn't enable file quarantine\n");
+ exit(EX_NOPERM);
+ }
+
+ free(homeDirectory);
+ enteredSandbox = true;
+ return NPERR_NO_ERROR;
+}
+
+NPError WKN_FileStopAccessing(const char* path)
+{
+ if (!enteredSandbox)
+ return NPERR_GENERIC_ERROR;
+
+ if (!CFURLStopAccessingSecurityScopedResourcePtr())
+ return NPERR_NO_ERROR;
+
+ RetainPtr<CFStringRef> urlString(AdoptCF, CFStringCreateWithFileSystemRepresentation(0, path));
+ if (!urlString)
+ return NPERR_INVALID_PARAM;
+ RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithFileSystemPath(0, urlString.get(), kCFURLPOSIXPathStyle, false));
+
+ CFURLStopAccessingSecurityScopedResourcePtr()(url.get());
+
+ return NPERR_NO_ERROR;
+}
+
+#endif
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
index 904a83dcd..d5b8353ee 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
@@ -227,34 +227,15 @@ void BuiltInPDFView::updateScrollbars()
scrollbarRect.contract(0, m_horizontalScrollbar->height());
m_verticalScrollbar->setFrameRect(scrollbarRect);
}
-}
-
-void BuiltInPDFView::didAddHorizontalScrollbar(Scrollbar* scrollbar)
-{
- pluginView()->frame()->document()->didAddWheelEventHandler();
- ScrollableArea::didAddHorizontalScrollbar(scrollbar);
-}
-
-void BuiltInPDFView::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
-{
- ScrollableArea::willRemoveHorizontalScrollbar(scrollbar);
- // FIXME: Maybe need a separate ScrollableArea::didRemoveHorizontalScrollbar callback?
- if (PluginView* pluginView = this->pluginView())
- pluginView->frame()->document()->didRemoveWheelEventHandler();
-}
-
-void BuiltInPDFView::didAddVerticalScrollbar(Scrollbar* scrollbar)
-{
- pluginView()->frame()->document()->didAddWheelEventHandler();
- ScrollableArea::didAddVerticalScrollbar(scrollbar);
-}
+
+ FrameView* frameView = m_frame->coreFrame()->view();
+ if (!frameView)
+ return;
-void BuiltInPDFView::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
-{
- ScrollableArea::willRemoveVerticalScrollbar(scrollbar);
- // FIXME: Maybe need a separate ScrollableArea::didRemoveHorizontalScrollbar callback?
- if (PluginView* pluginView = this->pluginView())
- pluginView->frame()->document()->didRemoveWheelEventHandler();
+ if (m_verticalScrollbar || m_horizontalScrollbar)
+ frameView->addScrollableArea(this);
+ else
+ frameView->removeScrollableArea(this);
}
PassRefPtr<Scrollbar> BuiltInPDFView::createScrollbar(ScrollbarOrientation orientation)
@@ -348,8 +329,6 @@ void BuiltInPDFView::calculateSizes()
bool BuiltInPDFView::initialize(const Parameters& parameters)
{
- m_frame->coreFrame()->view()->addScrollableArea(this);
-
// Load the src URL if needed.
m_sourceURL = parameters.url;
if (!parameters.loadManually && !parameters.url.isEmpty())
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
index d6c364f00..e4a624a67 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
@@ -58,10 +58,6 @@ private:
const PluginView* pluginView() const;
void updateScrollbars();
- void didAddHorizontalScrollbar(WebCore::Scrollbar*);
- void willRemoveHorizontalScrollbar(WebCore::Scrollbar*);
- void didAddVerticalScrollbar(WebCore::Scrollbar*);
- void willRemoveVerticalScrollbar(WebCore::Scrollbar*);
PassRefPtr<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation);
void destroyScrollbar(WebCore::ScrollbarOrientation);
void addArchiveResource();