diff options
author | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-11 06:55:53 +0000 |
---|---|---|
committer | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-11 06:55:53 +0000 |
commit | 017882554c41b6030a12d50b4044449e3c2409ac (patch) | |
tree | 5cb159fea9feafceb5260e7446cddf380799b182 /webkit/glue/plugins | |
parent | 3335d879a364867309a93749cc9e4805bd92d114 (diff) | |
download | chromium_src-017882554c41b6030a12d50b4044449e3c2409ac.zip chromium_src-017882554c41b6030a12d50b4044449e3c2409ac.tar.gz chromium_src-017882554c41b6030a12d50b4044449e3c2409ac.tar.bz2 |
Checkpoint of plugin support code for Mac. Does not work yet; being checked
in to help stay in sync with linux plugin mods and ensure that it doesn't
break Windows plugins.
Review URL: http://codereview.chromium.org/21095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9558 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 43 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 39 |
2 files changed, 56 insertions, 26 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 8afa505..087abf8 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -589,7 +589,15 @@ const char* NPN_UserAgent(NPP id) { return webkit_glue::GetUserAgent(GURL()).c_str(); } +#if defined(OS_WIN) + static const char *UA = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061103 Firefox/2.0a1"; +#elif defined(OS_MACOSX) + // TODO(port): this is probably wrong... + static const char *UA = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1"; +#else + // TODO(port): set appropriately for other platforms static const char *UA = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061103 Firefox/2.0a1"; +#endif return UA; } @@ -601,7 +609,6 @@ void NPN_Status(NPP id, const char* message) { } void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { -#if defined(OS_WIN) // Invalidates specified drawing area prior to repainting or refreshing a // windowless plugin @@ -619,12 +626,18 @@ void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { if (plugin.get() && plugin->webplugin()) { if (invalidRect) { if (!plugin->windowless()) { +#if defined(OS_WIN) RECT rect = {0}; rect.left = invalidRect->left; rect.right = invalidRect->right; rect.top = invalidRect->top; rect.bottom = invalidRect->bottom; ::InvalidateRect(plugin->window_handle(), &rect, FALSE); +#elif defined(OS_MACOSX) + NOTIMPLEMENTED(); +#else + NOTIMPLEMENTED(); +#endif return; } @@ -637,9 +650,6 @@ void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { plugin->webplugin()->Invalidate(); } } -#else - NOTIMPLEMENTED(); -#endif } void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { @@ -792,6 +802,24 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { } break; } +#if defined(OS_MACOSX) + case NPNVsupportsQuickDrawBool: + { + // we do not support the QuickDraw drawing model + NPBool* supports_qd = reinterpret_cast<NPBool*>(value); + *supports_qd = FALSE; + rv = NPERR_NO_ERROR; + break; + } + case NPNVsupportsCoreGraphicsBool: + { + // we do support (and in fact require) the CoreGraphics drawing model + NPBool* supports_cg = reinterpret_cast<NPBool*>(value); + *supports_cg = TRUE; + rv = NPERR_NO_ERROR; + break; + } +#endif default: { // TODO: implement me @@ -842,6 +870,13 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void *value) { // TODO: implement me DLOG(INFO) << "NPN_SetValue(NPPVpluginKeepLibraryInMemory) is not implemented."; return NPERR_GENERIC_ERROR; +#if defined(OS_MACOSX) + case NPNVpluginDrawingModel: + // we only support the CoreGraphics drawing model + if (reinterpret_cast<int>(value) == NPDrawingModelCoreGraphics) + return NPERR_NO_ERROR; + return NPERR_GENERIC_ERROR; +#endif default: // TODO: implement me DLOG(INFO) << "NPN_SetValue(" << variable << ") is not implemented."; diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 929f30d..48672bd9 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -29,14 +29,13 @@ class WebPluginDelegateImpl : public WebPluginDelegate { static WebPluginDelegateImpl* Create(const FilePath& filename, const std::string& mime_type, gfx::NativeView containing_view); -#if defined(OS_WIN) - static bool IsPluginDelegateWindow(HWND window); - static bool GetPluginNameFromWindow(HWND window, std::wstring *plugin_name); + static bool IsPluginDelegateWindow(gfx::NativeWindow window); + static bool GetPluginNameFromWindow(gfx::NativeWindow window, + std::wstring *plugin_name); // Returns true if the window handle passed in is that of the dummy // activation window for windowless plugins. - static bool IsDummyActivationWindow(HWND window); -#endif // OS_WIN) + static bool IsDummyActivationWindow(gfx::NativeWindow window); // WebPluginDelegate implementation virtual void PluginDestroyed(); @@ -48,14 +47,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate { bool load_manually); virtual void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect); -#if defined(OS_WIN) - virtual void Paint(HDC hdc, const gfx::Rect& rect); - virtual void Print(HDC hdc); -#else - // TODO(port): temporary workaround. - virtual void Paint(void* dc, const gfx::Rect& rect); - virtual void Print(void* dc); -#endif + virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); + virtual void Print(gfx::NativeDrawingContext context); + virtual void SetFocus(); // only called when windowless // only called when windowless virtual bool HandleEvent(NPEvent* event, @@ -157,12 +151,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // used for windowless plugins void WindowlessUpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect); -#if defined(OS_WIN) - void WindowlessPaint(HDC hdc, const gfx::Rect& rect); -#else - // TODO(port): implement. - void WindowlessPaint(void* dc, const gfx::Rect& rect); -#endif + void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect); // Tells the plugin about the current state of the window. // See NPAPI NPP_SetWindow for more information. @@ -184,13 +173,11 @@ class WebPluginDelegateImpl : public WebPluginDelegate { gfx::Rect windowed_last_pos_; #endif -#if defined(OS_WIN) // this is an optimization to avoid calling SetWindow to the plugin // when it is not necessary. Initially, we need to call SetWindow, // and after that we only need to call it when the geometry changes. // use this flag to indicate whether we really need it or not. bool windowless_needs_set_window_; -#endif // used by windowed and windowless plugins bool windowless_; @@ -209,6 +196,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate { gfx::NativeView parent_; NPWindow window_; +#if defined(OS_MACOSX) + NP_CGContext cg_context_; +#endif gfx::Rect window_rect_; gfx::Rect clip_rect_; std::vector<gfx::Rect> cutout_rects_; @@ -225,6 +215,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // To fix a majority of these activation issues we create a dummy visible // child window to which we set focus whenever the windowless plugin // receives a WM_LBUTTONDOWN/WM_RBUTTONDOWN message via NPP_HandleEvent. + HWND dummy_window_for_activation_; bool CreateDummyWindowForActivation(); @@ -252,10 +243,13 @@ class WebPluginDelegateImpl : public 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 // Holds the depth of the HandleEvent callstack. int handle_event_depth_; @@ -267,6 +261,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // asynchronously. ScopedRunnableMethodFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; +#if defined(OS_WIN) // The plugin module handle. HMODULE plugin_module_handle_; @@ -278,10 +273,10 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // SetCursor interceptor for windowless plugins. static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor); +#endif // Holds the current cursor set by the windowless plugin. WebCursor current_windowless_cursor_; -#endif DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateImpl); }; |