summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 16:52:53 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 16:52:53 +0000
commitaedf21e6299d270c7e044e2f9c2f7f3135551c7c (patch)
treee0c42a85c508647004189eb5ae165cf922601327 /webkit/glue
parentb2d8b5e8189485482b85e6d1a21d10d7779a4d3c (diff)
downloadchromium_src-aedf21e6299d270c7e044e2f9c2f7f3135551c7c.zip
chromium_src-aedf21e6299d270c7e044e2f9c2f7f3135551c7c.tar.gz
chromium_src-aedf21e6299d270c7e044e2f9c2f7f3135551c7c.tar.bz2
Add the plumbing and test code for plugins opening files from the sandbox. This
does not implement the actual opening of the files (currently the chain ends in resource_message_filter.cc), I will do that separately with some additional security review. This current patch just gets the synchronous request to the browser and returns a NULL result. TEST=none BUG=none Review URL: http://codereview.chromium.org/340050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/pepper/pepper.h4
-rw-r--r--webkit/glue/plugins/plugin_host.cc11
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h59
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_win.cc33
-rw-r--r--webkit/glue/webkitclient_impl.cc3
-rw-r--r--webkit/glue/webplugin_delegate.h4
7 files changed, 68 insertions, 54 deletions
diff --git a/webkit/glue/pepper/pepper.h b/webkit/glue/pepper/pepper.h
index 901109b..9ae47f9 100644
--- a/webkit/glue/pepper/pepper.h
+++ b/webkit/glue/pepper/pepper.h
@@ -149,6 +149,7 @@ typedef NPError (*NPFlushRenderContextPtr)(NPP instance,
void* userData);
typedef NPError (*NPDestroyRenderContextPtr)(NPP instance,
NPRenderContext* context);
+typedef NPError (*NPOpenFilePtr)(NPP instance, const char* fileName, void** handle);
typedef struct _NPPepperExtensions
{
@@ -157,6 +158,9 @@ typedef struct _NPPepperExtensions
NPFlushRenderContextPtr flushRender;
NPDestroyRenderContextPtr destroyRender;
/* Shared memory extensions */
+
+ /* I/O extensions */
+ NPOpenFilePtr openFile;
} NPPepperExtensions;
#endif /* PEPPER_APIS_ENABLED */
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 5385dda..efd84af 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -702,6 +702,14 @@ static NPError DestroyRenderContext(NPP id,
// TODO(sehr) implement render context destruction.
return NPERR_GENERIC_ERROR;
}
+
+static NPError OpenFileInSandbox(NPP id, const char* file_name, void** handle) {
+ scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
+ if (!plugin)
+ return NPERR_GENERIC_ERROR;
+ webkit_glue::WebPluginDelegate* delegate = plugin->webplugin()->delegate();
+ return delegate->OpenFileInSandbox(file_name, handle);
+}
#endif // defined(PEPPER_APIS_ENABLED)
NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
@@ -862,7 +870,8 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
static const NPPepperExtensions kExtensions = {
InitializeRenderContext,
FlushRenderContext,
- DestroyRenderContext
+ DestroyRenderContext,
+ OpenFileInSandbox,
};
// Return a pointer to the canonical function table.
NPPepperExtensions* extensions =
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 65e01b6..8384e73 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -270,7 +270,34 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// a plugin in the course of a NPP_HandleEvent call.
static LRESULT CALLBACK HandleEventMessageFilterHook(int code, WPARAM wParam,
LPARAM lParam);
+
+ // TrackPopupMenu interceptor. Parameters are the same as the Win32 function
+ // TrackPopupMenu.
+ static BOOL WINAPI TrackPopupMenuPatch(HMENU menu, unsigned int flags, int x,
+ int y, int reserved, HWND window,
+ const RECT* rect);
+
+ // SetCursor interceptor for windowless plugins.
+ static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor);
+
+ // RegEnumKeyExW interceptor.
+ static LONG WINAPI RegEnumKeyExWPatch(
+ HKEY key, DWORD index, LPWSTR name, LPDWORD name_size, LPDWORD reserved,
+ LPWSTR class_name, LPDWORD class_size, PFILETIME last_write_time);
+
+#elif defined(OS_MACOSX)
+
+ // Indicates that it's time to send the plugin a null event.
+ void OnNullEvent();
+
+ // Runnable Method Factory used to drip null events into the plugin.
+ ScopedRunnableMethodFactory<WebPluginDelegateImpl> null_event_factory_;
+
+ // Last mouse position within the plugin's rect (used for null events).
+ int last_mouse_x_;
+ int last_mouse_y_;
#endif
+
// Called by the message filter hook when the plugin enters a modal loop.
void OnModalLoopEntered();
@@ -286,11 +313,9 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
#if defined(OS_WIN)
// Handle to the message filter hook
HHOOK handle_event_message_filter_hook_;
-#endif
// Event which is set when the plugin enters a modal loop in the course
// of a NPP_HandleEvent call.
-#if defined(OS_WIN)
HANDLE handle_event_pump_messages_event_;
#endif
@@ -306,38 +331,10 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
ScopedRunnableMethodFactory<WebPluginDelegateImpl> user_gesture_msg_factory_;
#endif
-#if defined(OS_WIN)
- // TrackPopupMenu interceptor. Parameters are the same as the Win32 function
- // TrackPopupMenu.
- static BOOL WINAPI TrackPopupMenuPatch(HMENU menu, unsigned int flags, int x,
- int y, int reserved, HWND window,
- const RECT* rect);
-
- // SetCursor interceptor for windowless plugins.
- static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor);
-
- // RegEnumKeyExW interceptor.
- static LONG WINAPI RegEnumKeyExWPatch(
- HKEY key, DWORD index, LPWSTR name, LPDWORD name_size, LPDWORD reserved,
- LPWSTR class_name, LPDWORD class_size, PFILETIME last_write_time);
-#endif
-
-#if defined(OS_MACOSX)
- // Runnable Method Factory used to drip null events into the plugin
- ScopedRunnableMethodFactory<WebPluginDelegateImpl> null_event_factory_;
-
- // indicates that it's time to send the plugin a null event
- void OnNullEvent();
-
- // last mouse position within the plugin's rect (used for null events)
- int last_mouse_x_;
- int last_mouse_y_;
-#endif
-
// Holds the current cursor set by the windowless plugin.
WebCursor current_windowless_cursor_;
DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
};
-#endif // #ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H_
+#endif // WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H_
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 5452e61..d51e4fc 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -102,12 +102,12 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
parent_(containing_view),
qd_world_(0),
quirks_(0),
- handle_event_depth_(0),
- user_gesture_message_posted_(this),
- user_gesture_msg_factory_(this),
null_event_factory_(this),
last_mouse_x_(0),
- last_mouse_y_(0) {
+ last_mouse_y_(0),
+ handle_event_depth_(0),
+ user_gesture_message_posted_(this),
+ user_gesture_msg_factory_(this) {
memset(&window_, 0, sizeof(window_));
#ifndef NP_NO_QUICKDRAW
memset(&qd_port_, 0, sizeof(qd_port_));
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
index 330cb39..9c28d0f 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
@@ -437,18 +437,18 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
// The window will be sized and shown later.
windowed_handle_ = CreateWindowEx(
- WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
- kNativeWindowClassName,
- 0,
- WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- 0,
- 0,
- 0,
- 0,
- parent_,
- 0,
- GetModuleHandle(NULL),
- 0);
+ WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
+ kNativeWindowClassName,
+ 0,
+ WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ 0,
+ 0,
+ 0,
+ 0,
+ parent_,
+ 0,
+ GetModuleHandle(NULL),
+ 0);
if (windowed_handle_ == 0)
return false;
@@ -559,10 +559,11 @@ void WebPluginDelegateImpl::OnThrottleMessage() {
}
}
- if (throttle_queue->size() > 0)
+ if (throttle_queue->size() > 0) {
MessageLoop::current()->PostDelayedTask(FROM_HERE,
NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage),
kFlashWMUSERMessageThrottleDelayMs);
+ }
}
// Schedule a windows message for delivery later.
@@ -756,7 +757,7 @@ void WebPluginDelegateImpl::WindowedSetWindow() {
ATOM WebPluginDelegateImpl::RegisterNativeWindowClass() {
static bool have_registered_window_class = false;
if (have_registered_window_class == true)
- return true;
+ return true;
have_registered_window_class = true;
@@ -856,7 +857,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc(
delegate->is_calling_wndproc = true;
if (!delegate->user_gesture_message_posted_ &&
- IsUserGestureMessage(message)) {
+ IsUserGestureMessage(message)) {
delegate->user_gesture_message_posted_ = true;
delegate->instance()->PushPopupsEnabledState(true);
@@ -874,7 +875,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc(
if (message == WM_NCDESTROY) {
RemoveProp(hwnd, kWebPluginDelegateProperty);
- ATOM plugin_name_atom = reinterpret_cast <ATOM>(
+ ATOM plugin_name_atom = reinterpret_cast<ATOM>(
RemoveProp(hwnd, kPluginNameAtomProperty));
if (plugin_name_atom != 0)
GlobalDeleteAtom(plugin_name_atom);
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index a578d7c..50ffbd1 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -389,8 +389,7 @@ WebKit::WebString WebKitClientImpl::pathByAppendingComponent(
return webkit_glue::FilePathStringToWebString(combined_path.value());
}
-bool WebKitClientImpl::makeAllDirectories(
- const WebKit::WebString& path) {
+bool WebKitClientImpl::makeAllDirectories(const WebKit::WebString& path) {
DCHECK(!sandboxEnabled());
FilePath::StringType file_path = webkit_glue::WebStringToFilePathString(path);
return file_util::CreateDirectory(FilePath(file_path));
diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h
index a2df27f..3d4515e 100644
--- a/webkit/glue/webplugin_delegate.h
+++ b/webkit/glue/webplugin_delegate.h
@@ -137,6 +137,10 @@ class WebPluginDelegate {
virtual NPError FlushRenderContext(NPRenderContext* context) {
return NPERR_GENERIC_ERROR;
}
+
+ virtual NPError OpenFileInSandbox(const char* file_name, void** handle) {
+ return NPERR_GENERIC_ERROR;
+ }
};
} // namespace webkit_glue