diff options
29 files changed, 278 insertions, 295 deletions
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index 7372796..62b9411 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -33,6 +33,7 @@ #include "chrome/common/gears_api.h" #include "chrome/common/notification_service.h" #include "chrome/common/net/url_request_intercept_job.h" +#include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" #include "net/base/base64.h" #include "net/base/cookie_monster.h" @@ -43,7 +44,6 @@ // TODO(port): Port these files. #if defined(OS_WIN) #include "chrome/browser/dom_ui/html_dialog_contents.h" -#include "chrome/common/plugin_messages.h" #else #include "chrome/common/temp_scaffolding_stubs.h" #endif diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 5031a35..2b62f6c 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -33,26 +33,27 @@ #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" +#include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" #include "net/base/cookie_monster.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" +#include "webkit/glue/plugins/plugin_constants_win.h" // TODO(port): Port these files. #if defined(OS_WIN) #include "base/win_util.h" #include "chrome/browser/sandbox_policy.h" -#include "chrome/common/plugin_messages.h" #include "chrome/common/win_util.h" #include "sandbox/src/sandbox.h" -#include "webkit/glue/plugins/plugin_constants_win.h" #endif static const char kDefaultPluginFinderURL[] = "http://dl.google.com/chrome/plugins/plugins2.xml"; +#if defined(OS_WIN) // The PluginDownloadUrlHelper is used to handle one download URL request // from the plugin. Each download request is handled by a new instance @@ -109,11 +110,7 @@ PluginDownloadUrlHelper::PluginDownloadUrlHelper( download_file_caller_window_(caller_window), download_url_(download_url), download_source_pid_(source_pid) { -#if defined(OS_WIN) DCHECK(::IsWindow(caller_window)); -#else - // TODO(port): Some window verification for mac and linux. -#endif memset(download_file_buffer_->data(), 0, kDownloadFileBufferSize); download_file_.reset(new net::FileStream()); } @@ -156,14 +153,8 @@ void PluginDownloadUrlHelper::OnResponseStarted(URLRequest* request) { file_util::GetTempDir(&download_file_path_); GURL request_url = request->url(); -#if defined(OS_WIN) download_file_path_ = download_file_path_.Append( UTF8ToWide(request_url.ExtractFileName())); -#else - download_file_path_ = download_file_path_.Append( - request_url.ExtractFileName()); -#endif - download_file_->Open(download_file_path_, base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE); @@ -247,7 +238,6 @@ void PluginDownloadUrlHelper::DownloadCompletedHelper(bool success) { download_file_.reset(); } -#if defined(OS_WIN) std::wstring path = download_file_path_.value(); COPYDATASTRUCT download_file_data = {0}; download_file_data.cbData = @@ -259,16 +249,12 @@ void PluginDownloadUrlHelper::DownloadCompletedHelper(bool success) { ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, reinterpret_cast<LPARAM>(&download_file_data)); } -#else - // TODO(port): Send the file data to the caller. - NOTIMPLEMENTED(); -#endif // Don't access any members after this. delete this; } -#if defined(OS_WIN) + // Sends the reply to the create window message on the IO thread. class SendReplyTask : public Task { public: @@ -356,6 +342,14 @@ void PluginProcessHost::OnDestroyWindow(HWND window) { PostMessage(window, WM_CLOSE, 0, 0); } +void PluginProcessHost::OnDownloadUrl(const std::string& url, + int source_pid, + gfx::NativeWindow caller_window) { + PluginDownloadUrlHelper* download_url_helper = + new PluginDownloadUrlHelper(url, source_pid, caller_window); + download_url_helper->InitiateDownload(); +} + void PluginProcessHost::AddWindow(HWND window) { plugin_parent_windows_set_.insert(window); } @@ -499,25 +493,22 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, } void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { -#if defined(OS_WIN) IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) - IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DownloadUrl, OnDownloadUrl) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetPluginFinderUrl, OnGetPluginFinderUrl) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetCookies, OnGetCookies) IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginProcessHostMsg_ResolveProxy, OnResolveProxy) +#if defined(OS_WIN) IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginProcessHostMsg_CreateWindow, OnCreateWindow) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DestroyWindow, OnDestroyWindow) + IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DownloadUrl, OnDownloadUrl) +#endif IPC_MESSAGE_UNHANDLED_ERROR() IPC_END_MESSAGE_MAP() -#else - // TODO(port): Port plugin_messages_internal.h. - NOTIMPLEMENTED(); -#endif } void PluginProcessHost::OnChannelConnected(int32 peer_pid) { @@ -636,14 +627,6 @@ void PluginProcessHost::OnChannelCreated(const std::wstring& channel_name) { sent_requests_.pop(); } -void PluginProcessHost::OnDownloadUrl(const std::string& url, - int source_pid, - gfx::NativeWindow caller_window) { - PluginDownloadUrlHelper* download_url_helper = - new PluginDownloadUrlHelper(url, source_pid, caller_window); - download_url_helper->InitiateDownload(); -} - void PluginProcessHost::OnGetPluginFinderUrl(std::string* plugin_finder_url) { if (!plugin_finder_url) { NOTREACHED(); diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h index 71b7c77..c43fef2 100644 --- a/chrome/browser/plugin_process_host.h +++ b/chrome/browser/plugin_process_host.h @@ -97,8 +97,6 @@ class PluginProcessHost : public ChildProcessHost, IPC::Message* reply_msg); // Message handlers. void OnChannelCreated(const std::wstring& channel_name); - void OnDownloadUrl(const std::string& url, int source_pid, - gfx::NativeWindow caller_window); void OnGetPluginFinderUrl(std::string* plugin_finder_url); void OnGetCookies(uint32 request_context, const GURL& url, std::string* cookies); @@ -108,6 +106,8 @@ class PluginProcessHost : public ChildProcessHost, #if defined(OS_WIN) void OnCreateWindow(HWND parent, IPC::Message* reply_msg); void OnDestroyWindow(HWND window); + void OnDownloadUrl(const std::string& url, int source_pid, + gfx::NativeWindow caller_window); #endif virtual bool CanShutdown() { return sent_requests_.empty(); } diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc index b22d751..7f934b0 100644 --- a/chrome/common/child_process_host.cc +++ b/chrome/common/child_process_host.cc @@ -14,12 +14,10 @@ #include "chrome/common/ipc_logging.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" +#include "chrome/common/plugin_messages.h" #include "chrome/common/process_watcher.h" #include "chrome/common/result_codes.h" -#if defined(OS_WIN) -#include "chrome/common/plugin_messages.h" -#endif namespace { typedef std::list<ChildProcessHost*> ChildProcessList; @@ -153,7 +151,6 @@ void ChildProcessHost::ListenerHook::OnMessageReceived( msg, host_, &msg_is_ok); if (!handled) { -#if defined(OS_WIN) if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { // Must remove the process from the list now, in case it gets used for a // new instance before our watcher tells us that the process terminated. @@ -161,9 +158,6 @@ void ChildProcessHost::ListenerHook::OnMessageReceived( if (host_->CanShutdown()) host_->Send(new PluginProcessMsg_Shutdown()); } else { -#else - { -#endif host_->OnMessageReceived(msg); } } @@ -180,9 +174,7 @@ void ChildProcessHost::ListenerHook::OnMessageReceived( void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { host_->opening_channel_ = false; host_->OnChannelConnected(peer_pid); -#if defined(OS_WIN) host_->Send(new PluginProcessMsg_AskBeforeShutdown()); -#endif // Notify in the main loop of the connection. host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index c1ad034..94b3186 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -9,11 +9,9 @@ #include "chrome/common/child_process.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/ipc_logging.h" +#include "chrome/common/plugin_messages.h" #include "webkit/glue/webkit_glue.h" -#if defined(OS_WIN) -#include "chrome/common/plugin_messages.h" -#endif // V8 needs a 1MB stack size. const size_t ChildThread::kV8StackSize = 1024 * 1024; @@ -71,7 +69,6 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) { if (resource_dispatcher_->OnMessageReceived(msg)) return; -#if defined(OS_WIN) if (msg.type() == PluginProcessMsg_AskBeforeShutdown::ID) { check_with_browser_before_shutdown_ = true; return; @@ -81,7 +78,6 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) { owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); return; } -#endif if (msg.routing_id() == MSG_ROUTING_CONTROL) { OnControlMessageReceived(msg); @@ -121,11 +117,9 @@ void ChildThread::OnProcessFinalRelease() { return; } -#if defined(OS_WIN) // The child process shutdown sequence is a request response based mechanism, // where we send out an initial feeler request to the child process host // instance in the browser to verify if it's ok to shutdown the child process. // The browser then sends back a response if it's ok to shutdown. Send(new PluginProcessHostMsg_ShutdownRequest); -#endif } diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index d02b3b2..cb63533 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -27,8 +27,11 @@ // can get *MsgLog function etc. This makes ipc logs much more informative. #include "chrome/common/render_messages.h" #include "chrome/test/automation/automation_messages.h" + #if defined(OS_WIN) -// TODO(port): These messages will need to be ported at some point +// Pulling this file in Mac/Linux causes a lot of binaries to need to bring in +// WebKit and all the dependencies, which results in a very large number of +// linker errors. #include "chrome/common/plugin_messages.h" #endif diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 4cc8048..7b5ce73 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -13,6 +13,7 @@ #include <string> #include <vector> +#include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "base/basictypes.h" #include "chrome/common/ipc_message_utils.h" @@ -27,12 +28,14 @@ // predefined IPC message. struct PluginMsg_Init_Params { - HWND containing_window; + gfx::NativeViewId containing_window; GURL url; std::vector<std::string> arg_names; std::vector<std::string> arg_values; - bool load_manually; +#if defined(OS_WIN) HANDLE modal_dialog_event; +#endif + bool load_manually; }; struct PluginHostMsg_URLRequest_Params { @@ -43,7 +46,7 @@ struct PluginHostMsg_URLRequest_Params { bool is_file_data; bool notify; std::string url; - HANDLE notify_data; + intptr_t notify_data; bool popups_allowed; }; @@ -51,13 +54,8 @@ struct PluginMsg_URLRequestReply_Params { int resource_id; std::string url; bool notify_needed; - HANDLE notify_data; - HANDLE stream; -}; - -struct PluginMsg_PrintResponse_Params { - HANDLE shared_memory; - size_t size; + intptr_t notify_data; + intptr_t stream; }; struct PluginMsg_DidReceiveResponseParams { @@ -96,7 +94,7 @@ struct NPVariant_Param { double double_value; std::string string_value; int npobject_routing_id; - void* npobject_pointer; + intptr_t npobject_pointer; }; @@ -112,16 +110,20 @@ struct ParamTraits<PluginMsg_Init_Params> { DCHECK(p.arg_names.size() == p.arg_values.size()); WriteParam(m, p.arg_names); WriteParam(m, p.arg_values); - WriteParam(m, p.load_manually); +#if defined(OS_WIN) WriteParam(m, p.modal_dialog_event); +#endif + WriteParam(m, p.load_manually); } static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->containing_window) && ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->arg_names) && ReadParam(m, iter, &p->arg_values) && - ReadParam(m, iter, &p->load_manually) && - ReadParam(m, iter, &p->modal_dialog_event); +#if defined(OS_WIN) + ReadParam(m, iter, &p->modal_dialog_event) && +#endif + ReadParam(m, iter, &p->load_manually); } static void Log(const param_type& p, std::wstring* l) { l->append(L"("); @@ -133,9 +135,11 @@ struct ParamTraits<PluginMsg_Init_Params> { l->append(L", "); LogParam(p.arg_values, l); l->append(L", "); - LogParam(p.load_manually, l); - l->append(L", "); +#if defined(OS_WIN) LogParam(p.modal_dialog_event, l); + l->append(L", "); +#endif + LogParam(p.load_manually, l); l->append(L")"); } }; @@ -223,22 +227,6 @@ struct ParamTraits<PluginMsg_URLRequestReply_Params> { }; template <> -struct ParamTraits<PluginMsg_PrintResponse_Params> { - typedef PluginMsg_PrintResponse_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.shared_memory); - WriteParam(m, p.size); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ReadParam(m, iter, &r->shared_memory) && - ReadParam(m, iter, &r->size); - } - static void Log(const param_type& p, std::wstring* l) { - } -}; - -template <> struct ParamTraits<PluginMsg_DidReceiveResponseParams> { typedef PluginMsg_DidReceiveResponseParams param_type; static void Write(Message* m, const param_type& p) { @@ -294,6 +282,7 @@ struct ParamTraits<NPEvent> { return true; } static void Log(const param_type& p, std::wstring* l) { +#if defined(OS_WIN) std::wstring event, wparam, lparam; lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam)); switch(p.event) { @@ -356,6 +345,9 @@ struct ParamTraits<NPEvent> { l->append(L", "); LogParam(lparam, l); l->append(L")"); +#else + l->append(L"<NPEvent>"); +#endif } }; diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 61c53f0..11a0365 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -41,11 +41,6 @@ IPC_BEGIN_MESSAGES(PluginProcessHost) IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ChannelCreated, std::wstring /* channel_name */) - IPC_MESSAGE_ROUTED3(PluginProcessHostMsg_DownloadUrl, - std::string /* URL */, - int /* process id */, - HWND /* caller window */) - IPC_SYNC_MESSAGE_CONTROL0_1(PluginProcessHostMsg_GetPluginFinderUrl, std::string /* plugin finder URL */) @@ -77,6 +72,7 @@ IPC_BEGIN_MESSAGES(PluginProcessHost) int /* network error */, std::string /* proxy list */) +#if defined(OS_WIN) // Creates a child window of the given parent window on the UI thread. IPC_SYNC_MESSAGE_CONTROL1_1(PluginProcessHostMsg_CreateWindow, HWND /* parent */, @@ -86,6 +82,12 @@ IPC_BEGIN_MESSAGES(PluginProcessHost) IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_DestroyWindow, HWND /* window */) + IPC_MESSAGE_ROUTED3(PluginProcessHostMsg_DownloadUrl, + std::string /* URL */, + int /* process id */, + HWND /* caller window */) +#endif + IPC_END_MESSAGES(PluginProcessHost) @@ -122,12 +124,13 @@ IPC_BEGIN_MESSAGES(Plugin) // plugin knows it can send more invalidates. IPC_MESSAGE_ROUTED0(PluginMsg_DidPaint) - IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_Print, - PluginMsg_PrintResponse_Params /* params */) + IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_Print, + base::SharedMemoryHandle /* shared_memory*/, + size_t /* size */) IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_GetPluginScriptableObject, int /* route_id */, - void* /* npobject_ptr */) + intptr_t /* npobject_ptr */) IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_DidFinishLoadWithReason, int /* reason */) @@ -173,7 +176,7 @@ IPC_BEGIN_MESSAGES(Plugin) std::wstring /* result */, bool /* success */, bool /* notify required */, - int /* notify data */) + intptr_t /* notify data */) IPC_MESSAGE_ROUTED2(PluginMsg_DidReceiveManualResponse, std::string /* url */, @@ -194,7 +197,7 @@ IPC_BEGIN_MESSAGES(Plugin) IPC_SYNC_MESSAGE_ROUTED3_0(PluginMsg_URLRequestRouted, std::string /* url */, bool /* notify_needed */, - HANDLE /* notify data */) + intptr_t /* notify data */) IPC_END_MESSAGES(Plugin) @@ -206,13 +209,17 @@ IPC_BEGIN_MESSAGES(PluginHost) // Sends the plugin window information to the renderer. // The window parameter is a handle to the window if the plugin is a windowed // plugin. It is NULL for windowless plugins. + IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindow, + gfx::NativeViewId /* window */) + +#if defined(OS_WIN) // The modal_loop_pump_messages_event parameter is an event handle which is // passed in for windowless plugins and is used to indicate if messages // are to be pumped in sync calls to the plugin process. Currently used // in HandleEvent calls. - IPC_SYNC_MESSAGE_ROUTED2_0(PluginHostMsg_SetWindow, - HWND /* window */, + IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindowlessPumpEvent, HANDLE /* modal_loop_pump_messages_event */) +#endif IPC_MESSAGE_ROUTED1(PluginHostMsg_URLRequest, PluginHostMsg_URLRequest_Params) @@ -226,12 +233,12 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_GetWindowScriptNPObject, int /* route id */, bool /* success */, - void* /* npobject_ptr */) + intptr_t /* npobject_ptr */) IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_GetPluginElement, int /* route id */, bool /* success */, - void* /* npobject_ptr */) + intptr_t /* npobject_ptr */) IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie, GURL /* url */, @@ -264,9 +271,9 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_MESSAGE_ROUTED5(PluginHostMsg_InitiateHTTPRangeRequest, std::string /* url */, std::string /* range_info */, - HANDLE /* existing_stream */, + intptr_t /* existing_stream */, bool /* notify_needed */, - HANDLE /* notify_data */) + intptr_t /* notify_data */) IPC_END_MESSAGES(PluginHost) diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index 019b1b2..0264321 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -48,7 +48,7 @@ NPObjectProxy* NPObjectProxy::GetProxy(NPObject* object) { NPObjectProxy::NPObjectProxy( PluginChannelBase* channel, int route_id, - void* npobject_ptr, + intptr_t npobject_ptr, base::WaitableEvent* modal_dialog_event) : channel_(channel), route_id_(route_id), @@ -67,7 +67,7 @@ NPObjectProxy::~NPObjectProxy() { NPObject* NPObjectProxy::Create(PluginChannelBase* channel, int route_id, - void* npobject_ptr, + intptr_t npobject_ptr, base::WaitableEvent* modal_dialog_event) { NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>( NPN_CreateObject(0, &npclass_proxy_)); diff --git a/chrome/plugin/npobject_proxy.h b/chrome/plugin/npobject_proxy.h index f0e1085..bb0ec2c 100644 --- a/chrome/plugin/npobject_proxy.h +++ b/chrome/plugin/npobject_proxy.h @@ -35,7 +35,7 @@ class NPObjectProxy : public IPC::Channel::Listener, // modal_dialog_event_ is must be valid for the lifetime of the NPObjectProxy. static NPObject* Create(PluginChannelBase* channel, int route_id, - void* npobject_ptr, + intptr_t npobject_ptr, base::WaitableEvent* modal_dialog_event); // IPC::Message::Sender implementation: @@ -45,7 +45,7 @@ class NPObjectProxy : public IPC::Channel::Listener, // Returns the real NPObject's pointer (obviously only valid in the other // process). - void* npobject_ptr() { return npobject_ptr_; } + intptr_t npobject_ptr() { return npobject_ptr_; } // The next 8 functions are called on NPObjects from the plugin and browser. static bool NPHasMethod(NPObject *obj, @@ -96,7 +96,7 @@ class NPObjectProxy : public IPC::Channel::Listener, private: NPObjectProxy(PluginChannelBase* channel, int route_id, - void* npobject_ptr, + intptr_t npobject_ptr, base::WaitableEvent* modal_dialog_event); // IPC::Channel::Listener implementation: @@ -111,7 +111,7 @@ class NPObjectProxy : public IPC::Channel::Listener, static NPClass npclass_proxy_; int route_id_; - void* npobject_ptr_; + intptr_t npobject_ptr_; scoped_refptr<PluginChannelBase> channel_; base::WaitableEvent* modal_dialog_event_; }; diff --git a/chrome/plugin/npobject_util.cc b/chrome/plugin/npobject_util.cc index 8e30495..d7bad8f 100644 --- a/chrome/plugin/npobject_util.cc +++ b/chrome/plugin/npobject_util.cc @@ -193,7 +193,8 @@ void CreateNPVariantParam(const NPVariant& variant, NPObjectStub* object_stub = new NPObjectStub( variant.value.objectValue, channel, route_id, modal_dialog_event); param->npobject_routing_id = route_id; - param->npobject_pointer = variant.value.objectValue; + param->npobject_pointer = + reinterpret_cast<intptr_t>(variant.value.objectValue); } else { param->type = NPVARIANT_PARAM_VOID; } @@ -249,7 +250,7 @@ void CreateNPVariant(const NPVariant_Param& param, case NPVARIANT_PARAM_OBJECT_POINTER: result->type = NPVariantType_Object; result->value.objectValue = - static_cast<NPObject*>(param.npobject_pointer); + reinterpret_cast<NPObject*>(param.npobject_pointer); NPN_RetainObject(result->value.objectValue); break; default: diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 9993c37..fe9aa02 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -114,6 +114,7 @@ void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { namespace webkit_glue { +#if defined(OS_WIN) bool DownloadUrl(const std::string& url, HWND caller_window) { PluginThread* plugin_thread = PluginThread::current(); if (!plugin_thread) { @@ -126,6 +127,7 @@ bool DownloadUrl(const std::string& url, HWND caller_window) { caller_window); return plugin_thread->Send(message); } +#endif bool GetPluginFinderURL(std::string* plugin_finder_url) { if (!plugin_finder_url) { diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 93d9fa3..9d83b49 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -127,10 +127,12 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, FilePath path = FilePath(command_line.GetSwitchValue(switches::kPluginPath)); delegate_ = WebPluginDelegate::Create( - path, mime_type_, params.containing_window); + path, mime_type_, gfx::NativeViewFromId(params.containing_window)); if (delegate_) { - webplugin_ = new WebPluginProxy( - channel_, instance_id_, delegate_, params.modal_dialog_event); + webplugin_ = new WebPluginProxy(channel_, instance_id_, delegate_); +#if defined(OS_WIN) + webplugin_->SetModalDialogEvent(params.modal_dialog_event); +#endif *result = delegate_->Initialize( params.url, argn, argv, argc, webplugin_, params.load_manually); } @@ -211,7 +213,8 @@ void WebPluginDelegateStub::OnDidPaint() { webplugin_->DidPaint(); } -void WebPluginDelegateStub::OnPrint(PluginMsg_PrintResponse_Params* params) { +void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, + size_t* size) { gfx::Emf emf; if (!emf.CreateDc(NULL, NULL)) { NOTREACHED(); @@ -225,14 +228,13 @@ void WebPluginDelegateStub::OnPrint(PluginMsg_PrintResponse_Params* params) { return; } - size_t size = emf.GetDataSize(); - DCHECK(size); - params->size = size; + *size = emf.GetDataSize(); + DCHECK(*size); base::SharedMemory shared_buf; - CreateSharedBuffer(size, &shared_buf, ¶ms->shared_memory); + CreateSharedBuffer(*size, &shared_buf, shared_memory); // Retrieve a copy of the data. - bool success = emf.GetData(shared_buf.memory(), size); + bool success = emf.GetData(shared_buf.memory(), *size); DCHECK(success); } @@ -246,7 +248,7 @@ void WebPluginDelegateStub::OnUpdateGeometry( } void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, - void** npobject_ptr) { + intptr_t* npobject_ptr) { NPObject* object = delegate_->GetPluginScriptableObject(); if (!object) { *route_id = MSG_ROUTING_NONE; @@ -254,7 +256,7 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, } *route_id = channel_->GenerateRouteID(); - *npobject_ptr = object; + *npobject_ptr = reinterpret_cast<intptr_t>(object); // The stub will delete itself when the proxy tells it that it's released, or // otherwise when the channel is closed. NPObjectStub* stub = new NPObjectStub( @@ -268,7 +270,7 @@ void WebPluginDelegateStub::OnSendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { delegate_->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -337,6 +339,6 @@ void WebPluginDelegateStub::OnHandleURLRequestReply( void WebPluginDelegateStub::OnURLRequestRouted(const std::string& url, bool notify_needed, - HANDLE notify_data) { + intptr_t notify_data) { delegate_->URLRequestRouted(url, notify_needed, notify_data); } diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 9599945..995d318 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -20,7 +20,6 @@ class WebPluginProxy; class WebPluginDelegate; struct PluginMsg_Init_Params; struct PluginMsg_DidReceiveResponseParams; -struct PluginMsg_PrintResponse_Params; struct PluginMsg_URLRequestReply_Params; class WebCursor; @@ -63,17 +62,17 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, void OnPaint(const gfx::Rect& damaged_rect); void OnDidPaint(); - void OnPrint(PluginMsg_PrintResponse_Params* params); + void OnPrint(base::SharedMemoryHandle* shared_memory, size_t* size); void OnUpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, const base::SharedMemoryHandle& windowless_buffer, const base::SharedMemoryHandle& background_buffer); - void OnGetPluginScriptableObject(int* route_id, void** npobject_ptr); + void OnGetPluginScriptableObject(int* route_id, intptr_t* npobject_ptr); void OnSendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data); + intptr_t notify_data); void OnDidReceiveManualResponse( const std::string& url, @@ -87,7 +86,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, const PluginMsg_URLRequestReply_Params& params); void OnURLRequestRouted(const std::string& url, bool notify_needed, - HANDLE notify_data); + intptr_t notify_data); void CreateSharedBuffer(size_t size, base::SharedMemory* shared_buf, diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 34bdb92..3fb67c7 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -29,8 +29,7 @@ static ContextMap& GetContextMap() { WebPluginProxy::WebPluginProxy( PluginChannel* channel, int route_id, - WebPluginDelegate* delegate, - HANDLE modal_dialog_event) + WebPluginDelegate* delegate) : channel_(channel), route_id_(route_id), cp_browsing_context_(0), @@ -41,19 +40,6 @@ WebPluginProxy::WebPluginProxy( #pragma warning(suppress: 4355) // can use this runnable_method_factory_(this), parent_window_(NULL) { - - HANDLE event; - BOOL result = DuplicateHandle(channel->renderer_handle(), - modal_dialog_event, - GetCurrentProcess(), - &event, - SYNCHRONIZE, - FALSE, - 0); - DCHECK(result) << - "Couldn't duplicate the modal dialog handle for the plugin." \ - "handle: " << channel->renderer_handle() << ". err: " << GetLastError(); - modal_dialog_event_.reset(new base::WaitableEvent(event)); } WebPluginProxy::~WebPluginProxy() { @@ -70,18 +56,8 @@ bool WebPluginProxy::Send(IPC::Message* msg) { return channel_->Send(msg); } -bool WebPluginProxy::SetWindow(HWND window, HANDLE pump_messages_event) { - HANDLE pump_messages_event_for_renderer = NULL; - - if (pump_messages_event) { - DCHECK(window == NULL); - DuplicateHandle(GetCurrentProcess(), pump_messages_event, - channel_->renderer_handle(), - &pump_messages_event_for_renderer, - 0, FALSE, DUPLICATE_SAME_ACCESS); - DCHECK(pump_messages_event_for_renderer != NULL); - } else { - DCHECK (window); +bool WebPluginProxy::SetWindow(gfx::NativeView window) { + if (window) { // To make scrolling windowed plugins fast, we create the page's direct // child windows in the browser process. This way no cross process messages // are sent. @@ -102,12 +78,41 @@ bool WebPluginProxy::SetWindow(HWND window, HANDLE pump_messages_event) { window = parent_window_; } - Send(new PluginHostMsg_SetWindow(route_id_, window, - pump_messages_event_for_renderer)); + Send(new PluginHostMsg_SetWindow(route_id_, gfx::IdFromNativeView(window))); return false; } +#if defined(OS_WIN) +void WebPluginProxy::SetWindowlessPumpEvent(HANDLE pump_messages_event) { + HANDLE pump_messages_event_for_renderer = NULL; + DuplicateHandle(GetCurrentProcess(), pump_messages_event, + channel_->renderer_handle(), + &pump_messages_event_for_renderer, + 0, FALSE, DUPLICATE_SAME_ACCESS); + DCHECK(pump_messages_event_for_renderer != NULL); + Send(new PluginHostMsg_SetWindowlessPumpEvent( + route_id_, pump_messages_event_for_renderer)); +} + +void WebPluginProxy::SetModalDialogEvent(HANDLE modal_dialog_event) { + // TODO(port): figure out how this will be set in the browser process, or + // come up with a different mechanism. + HANDLE event; + BOOL result = DuplicateHandle(channel_->renderer_handle(), + modal_dialog_event, + GetCurrentProcess(), + &event, + SYNCHRONIZE, + FALSE, + 0); + DCHECK(result) << + "Couldn't duplicate the modal dialog handle for the plugin." \ + "handle: " << channel_->renderer_handle() << ". err: " << GetLastError(); + modal_dialog_event_.reset(new base::WaitableEvent(event)); +} +#endif + void WebPluginProxy::CancelResource(int id) { Send(new PluginHostMsg_CancelResource(route_id_, id)); resource_clients_.erase(id); @@ -147,7 +152,7 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() { int npobject_route_id = channel_->GenerateRouteID(); bool success = false; - void* npobject_ptr; + intptr_t npobject_ptr; Send(new PluginHostMsg_GetWindowScriptNPObject( route_id_, npobject_route_id, &success, &npobject_ptr)); if (!success) @@ -167,7 +172,7 @@ NPObject* WebPluginProxy::GetPluginElement() { int npobject_route_id = channel_->GenerateRouteID(); bool success = false; - void* npobject_ptr; + intptr_t npobject_ptr; Send(new PluginHostMsg_GetPluginElement( route_id_, npobject_route_id, &success, &npobject_ptr)); if (!success) @@ -265,7 +270,8 @@ void WebPluginProxy::HandleURLRequest(const char *method, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed) { + intptr_t notify_data, + bool popups_allowed) { if (!url) { NOTREACHED(); return; @@ -433,9 +439,9 @@ void WebPluginProxy::CancelDocumentLoad() { void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, const char* range_info, - void* existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data) { + int notify_data) { Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, range_info, existing_stream, diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index cba1ac5..8c4629d 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -30,12 +30,15 @@ class WebPluginProxy : public WebPlugin { // marshalled WebPlugin calls. WebPluginProxy(PluginChannel* channel, int route_id, - WebPluginDelegate* delegate, - HANDLE modal_dialog_event); + WebPluginDelegate* delegate); ~WebPluginProxy(); // WebPlugin overrides - bool SetWindow(HWND window, HANDLE pump_messages_event); + bool SetWindow(gfx::NativeView window); +#if defined(OS_WIN) + void SetWindowlessPumpEvent(HANDLE pump_messages_event); + void SetModalDialogEvent(HANDLE modal_dialog_event); +#endif void CancelResource(int id); void Invalidate(); void InvalidateRect(const gfx::Rect& rect); @@ -79,7 +82,7 @@ class WebPluginProxy : public WebPlugin { const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed); + intptr_t notify_data, bool popups_allowed); void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, @@ -90,9 +93,9 @@ class WebPluginProxy : public WebPlugin { void InitiateHTTPRangeRequest(const char* url, const char* range_info, - void* existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data); + intptr_t notify_data); bool IsOffTheRecord(); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 87185ff..c877fb8 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -45,7 +45,7 @@ class ResourceClientProxy : public WebPluginResourceClient { } void Initialize(int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { resource_id_ = resource_id; url_ = url; notify_needed_ = notify_needed; @@ -128,7 +128,7 @@ private: scoped_refptr<PluginChannelHost> channel_; std::string url_; bool notify_needed_; - void* notify_data_; + intptr_t notify_data_; // Set to true if the response expected is a multibyte response. // For e.g. response for a HTTP byte range request. bool multibyte_response_expected_; @@ -231,7 +231,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, // Now tell the PluginInstance in the plugin process to initialize. PluginMsg_Init_Params params; - params.containing_window = gfx::NativeViewFromId(render_view_->host_window()); + params.containing_window = render_view_->host_window(); params.url = url; for (int i = 0; i < argc; ++i) { params.arg_names.push_back(argn[i]); @@ -243,7 +243,9 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, } } params.load_manually = load_manually; +#if defined(OS_WIN) params.modal_dialog_event = render_view_->modal_dialog_event()->handle(); +#endif plugin_ = plugin; @@ -268,7 +270,7 @@ void WebPluginDelegateProxy::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { PluginMsg_SendJavaScriptStream* msg = new PluginMsg_SendJavaScriptStream(instance_id_, url, result, success, notify_needed, @@ -317,6 +319,8 @@ void WebPluginDelegateProxy::InstallMissingPlugin() { void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) + IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessPumpEvent, + OnSetWindowlessPumpEvent) IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, @@ -517,17 +521,19 @@ bool WebPluginDelegateProxy::BackgroundChanged( } void WebPluginDelegateProxy::Print(HDC hdc) { - PluginMsg_PrintResponse_Params params = { 0 }; - Send(new PluginMsg_Print(instance_id_, ¶ms)); + base::SharedMemoryHandle shared_memory; + size_t size; + if (!Send(new PluginMsg_Print(instance_id_, &shared_memory, &size))) + return; - base::SharedMemory memory(params.shared_memory, true); - if (!memory.Map(params.size)) { + base::SharedMemory memory(shared_memory, true); + if (!memory.Map(size)) { NOTREACHED(); return; } gfx::Emf emf; - if (!emf.CreateFromData(memory.memory(), params.size)) { + if (!emf.CreateFromData(memory.memory(), size)) { NOTREACHED(); return; } @@ -540,7 +546,7 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { return NPN_RetainObject(npobject_); int route_id = MSG_ROUTING_NONE; - void* npobject_ptr; + intptr_t npobject_ptr; Send(new PluginMsg_GetPluginScriptableObject( instance_id_, &route_id, &npobject_ptr)); if (route_id == MSG_ROUTING_NONE) @@ -579,21 +585,22 @@ int WebPluginDelegateProxy::GetProcessId() { return channel_host_->peer_pid(); } -void WebPluginDelegateProxy::OnSetWindow( - HWND window, HANDLE modal_loop_pump_messages_event) { +void WebPluginDelegateProxy::OnSetWindow(gfx::NativeViewId window_id) { + gfx::NativeView window = gfx::NativeViewFromId(window_id); windowless_ = window == NULL; if (plugin_) - plugin_->SetWindow(window, modal_loop_pump_messages_event); + plugin_->SetWindow(window); +} +#if defined(OS_WIN) + void WebPluginDelegateProxy::OnSetWindowlessPumpEvent( + HANDLE modal_loop_pump_messages_event) { DCHECK(modal_loop_pump_messages_event_ == NULL); - if (modal_loop_pump_messages_event) { - modal_loop_pump_messages_event_.reset( - new base::WaitableEvent(modal_loop_pump_messages_event)); - } else { - modal_loop_pump_messages_event_.reset(); - } + modal_loop_pump_messages_event_.reset( + new base::WaitableEvent(modal_loop_pump_messages_event)); } +#endif void WebPluginDelegateProxy::OnCancelResource(int id) { if (plugin_) @@ -610,7 +617,7 @@ void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) { } void WebPluginDelegateProxy::OnGetWindowScriptNPObject( - int route_id, bool* success, void** npobject_ptr) { + int route_id, bool* success, intptr_t* npobject_ptr) { *success = false; NPObject* npobject = NULL; if (plugin_) @@ -627,11 +634,11 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject( window_script_object_ = stub; window_script_object_->set_proxy(this); *success = true; - *npobject_ptr = npobject; + *npobject_ptr = reinterpret_cast<intptr_t>(npobject); } void WebPluginDelegateProxy::OnGetPluginElement( - int route_id, bool* success, void** npobject_ptr) { + int route_id, bool* success, intptr_t* npobject_ptr) { *success = false; NPObject* npobject = NULL; if (plugin_) @@ -645,7 +652,7 @@ void WebPluginDelegateProxy::OnGetPluginElement( npobject, channel_host_.get(), route_id, render_view_->modal_dialog_event()); *success = true; - *npobject_ptr = npobject; + *npobject_ptr = reinterpret_cast<intptr_t>(npobject); } void WebPluginDelegateProxy::OnSetCookie(const GURL& url, @@ -741,7 +748,7 @@ void WebPluginDelegateProxy::OnHandleURLRequest( WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void* notify_data, void* npstream) { + intptr_t notify_data, intptr_t npstream) { ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, instance_id_); proxy->Initialize(resource_id, url, notify_needed, notify_data, npstream); @@ -750,7 +757,7 @@ WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( void WebPluginDelegateProxy::URLRequestRouted(const std::string& url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { Send(new PluginMsg_URLRequestRouted(instance_id_, url, notify_needed, notify_data)); } @@ -761,7 +768,7 @@ void WebPluginDelegateProxy::OnCancelDocumentLoad() { void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( const std::string& url, const std::string& range_info, - HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { + intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), existing_stream, notify_needed, notify_data); diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index d7864e2..8af9733 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -75,7 +75,7 @@ class WebPluginDelegateProxy : public WebPluginDelegate, virtual void SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data); + intptr_t notify_data); virtual void DidReceiveManualResponse(const std::string& url, const std::string& mime_type, @@ -90,12 +90,12 @@ class WebPluginDelegateProxy : public WebPluginDelegate, virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, bool notify_needed, - void* notify_data, - void* existing_stream); + intptr_t notify_data, + intptr_t existing_stream); // Notifies the delegate about a Get/Post URL request getting routed virtual void URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data); + intptr_t notify_data); protected: template<class WebPluginDelegateProxy> friend class DeleteTask; @@ -108,16 +108,18 @@ class WebPluginDelegateProxy : public WebPluginDelegate, // Message handlers for messages that proxy WebPlugin methods, which // we translate into calls to the real WebPlugin. - void OnSetWindow(gfx::NativeView window, - HANDLE modal_loop_pump_messages_event); + void OnSetWindow(gfx::NativeViewId window); +#if defined(OS_WIN) + void OnSetWindowlessPumpEvent(HANDLE modal_loop_pump_messages_event); +#endif void OnCompleteURL(const std::string& url_in, std::string* url_out, bool* result); void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); void OnCancelResource(int id); void OnInvalidateRect(const gfx::Rect& rect); void OnGetWindowScriptNPObject(int route_id, bool* success, - void** npobject_ptr); - void OnGetPluginElement(int route_id, bool* success, void** npobject_ptr); + intptr_t* npobject_ptr); + void OnGetPluginElement(int route_id, bool* success, intptr_t* npobject_ptr); void OnSetCookie(const GURL& url, const GURL& policy_url, const std::string& cookie); @@ -131,8 +133,9 @@ class WebPluginDelegateProxy : public WebPluginDelegate, void OnCancelDocumentLoad(); void OnInitiateHTTPRangeRequest(const std::string& url, const std::string& range_info, - HANDLE existing_stream, bool notify_needed, - HANDLE notify_data); + intptr_t existing_stream, + bool notify_needed, + intptr_t notify_data); // Draw a graphic indicating a crashed plugin. void PaintSadPlugin(HDC hdc, const gfx::Rect& rect); diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index b0c199a..b87160a 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -340,16 +340,10 @@ static NPError GetURLNotify(NPP id, scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin.get()) { - plugin->webplugin()->HandleURLRequest("GET", - is_javascript_url, - target, - 0, - 0, - false, - notify, - url, - notify_data, - plugin->popups_allowed()); + plugin->webplugin()->HandleURLRequest( + "GET", is_javascript_url, target, 0, 0, false, + notify, url, reinterpret_cast<intptr_t>(notify_data), + plugin->popups_allowed()); } else { NOTREACHED(); return NPERR_GENERIC_ERROR; @@ -485,16 +479,9 @@ static NPError PostURLNotify(NPP id, // Unfortunately, our stream needs these broken apart, // so we need to parse the data and set headers and data // separately. - plugin->webplugin()->HandleURLRequest("POST", - is_javascript_url, - target, - len, - buf, - false, - notify, - url, - notify_data, - plugin->popups_allowed()); + plugin->webplugin()->HandleURLRequest( + "POST", is_javascript_url, target, len, buf, false, notify, url, + reinterpret_cast<intptr_t>(notify_data), plugin->popups_allowed()); return NPERR_NO_ERROR; } diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc index 6738435..f8c1814 100644 --- a/webkit/glue/plugins/plugin_instance.cc +++ b/webkit/glue/plugins/plugin_instance.cc @@ -167,7 +167,7 @@ NPObject *PluginInstance::GetPluginScriptableObject() { } void PluginInstance::SetURLLoadData(const GURL& url, - void* notify_data) { + intptr_t notify_data) { get_url_ = url; get_notify_data_ = notify_data; } @@ -175,7 +175,8 @@ void PluginInstance::SetURLLoadData(const GURL& url, // WebPluginLoadDelegate methods void PluginInstance::DidFinishLoadWithReason(NPReason reason) { if (!get_url_.is_empty()) { - NPP_URLNotify(get_url_.spec().c_str(), reason, get_notify_data_); + NPP_URLNotify(get_url_.spec().c_str(), reason, + reinterpret_cast<void*>(get_notify_data_)); } get_url_ = GURL(); @@ -351,7 +352,7 @@ void PluginInstance::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { if (success) { PluginStringStream *stream = new PluginStringStream(this, url, notify_needed, @@ -505,9 +506,9 @@ void PluginInstance::RequestRead(NPStream* stream, NPByteRange* range_list) { webplugin_->InitiateHTTPRangeRequest( stream->url, range_info.c_str(), - plugin_stream, + reinterpret_cast<intptr_t>(plugin_stream), plugin_stream->notify_needed(), - plugin_stream->notify_data()); + reinterpret_cast<intptr_t>(plugin_stream->notify_data())); break; } } diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h index e973717..2c3bb49 100644 --- a/webkit/glue/plugins/plugin_instance.h +++ b/webkit/glue/plugins/plugin_instance.h @@ -138,7 +138,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { // Helper method to set some persistent data for getURLNotify since // resource fetches happen async. - void SetURLLoadData(const GURL& url, void* notify_data); + void SetURLLoadData(const GURL& url, intptr_t notify_data); // If true, send the Mozilla user agent instead of Chrome's to the plugin. bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } @@ -166,7 +166,8 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { bool NPP_Print(NPPrint* platform_print); void SendJavaScriptStream(const std::string& url, const std::wstring& result, - bool success, bool notify_needed, int notify_data); + bool success, bool notify_needed, + intptr_t notify_data); void DidReceiveManualResponse(const std::string& url, const std::string& mime_type, @@ -231,7 +232,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { WebPlugin* webplugin_; std::string mime_type_; GURL get_url_; - void* get_notify_data_; + intptr_t get_notify_data_; bool use_mozilla_user_agent_; #if defined(OS_WIN) scoped_refptr<MozillaExtensionApi> mozilla_extenstions_; diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index 3d18525..87d02cb 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -253,6 +253,13 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; windowless_ = instance_->windowless(); + if (!windowless_) { + if (!WindowedCreatePlugin()) + return false; + } + + windowed_manage_position_ = plugin->SetWindow(windowed_handle_); +#if defined(OS_WIN) if (windowless_) { // For windowless plugins we should set the containing window handle // as the instance window handle. This is what Safari does. Not having @@ -262,13 +269,9 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, instance_->set_window_handle(parent_); CreateDummyWindowForActivation(); handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); - } else { - if (!WindowedCreatePlugin()) - return false; + plugin->SetWindowlessPumpEvent(handle_event_pump_messages_event_); } - - windowed_manage_position_ = - plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); +#endif plugin_url_ = url.spec(); // The windowless version of the Silverlight plugin calls the @@ -382,7 +385,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -1090,7 +1093,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -1106,17 +1109,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 74b0e13..a429e63 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -65,7 +65,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { virtual void SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data); + intptr_t notify_data); virtual void DidReceiveManualResponse(const std::string& url, const std::string& mime_type, const std::string& headers, @@ -79,11 +79,11 @@ class WebPluginDelegateImpl : public WebPluginDelegate { virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, bool notify_needed, - void *notify_data, - void* stream); + intptr_t notify_data, + intptr_t stream); virtual void URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data); + intptr_t notify_data); virtual bool IsWindowless() const { return windowless_ ; } virtual const gfx::Rect& GetRect() const { return window_rect_; } virtual const gfx::Rect& GetClipRect() const { return clip_rect_; } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc index c77b61b..8d20186 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc @@ -128,7 +128,7 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; } - plugin->SetWindow(windowed_handle_, /* unused event param */ NULL); + plugin->SetWindow(windowed_handle_); plugin_url_ = url.spec(); return true; @@ -197,7 +197,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -653,7 +653,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -669,17 +669,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc index 7c806dc..f758ce0 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc @@ -154,7 +154,7 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, return false; } - // plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); + // plugin->SetWindow(windowed_handle_); plugin_url_ = url.spec(); return true; @@ -223,7 +223,7 @@ void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) { + intptr_t notify_data) { instance()->SendJavaScriptStream(url, result, success, notify_needed, notify_data); } @@ -423,7 +423,7 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, - void *notify_data, void* existing_stream) { + intptr_t notify_data, intptr_t existing_stream) { // Stream already exists. This typically happens for range requests // initiated via NPN_RequestRead. if (existing_stream) { @@ -439,17 +439,15 @@ WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream(resource_id, - url, - mime_type, - notify_needed, - notify_data); + NPAPI::PluginStreamUrl *stream = instance()->CreateStream( + resource_id, url, mime_type, notify_needed, + reinterpret_cast<void*>(notify_data)); return stream; } void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) { + intptr_t notify_data) { if (notify_needed) { instance()->SetURLLoadData(GURL(url.c_str()), notify_data); } diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index f78deaa..8c56100 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -86,15 +86,17 @@ class WebPlugin { // windowed (i.e. handle is not NULL) or windowless (handle is NULL). This // tells the WebPlugin to send mouse/keyboard events to the plugin delegate, // as well as the information about the HDC for paint operations. - // The pump_messages_event is a event handle which is valid only for - // windowless plugins and is used in NPP_HandleEvent calls to pump messages - // if the plugin enters a modal loop. // The return value is only valid for windowed plugins. If true, it means // that the the HWND position should be managed by the delegate. If false, // the plugin should be kept at the origin and it'll get moved elsewhere. - virtual bool SetWindow(gfx::NativeView window, - HANDLE pump_messages_event) = 0; + virtual bool SetWindow(gfx::NativeView window) = 0; +#if defined(OS_WIN) + // The pump_messages_event is a event handle which is valid only for + // windowless plugins and is used in NPP_HandleEvent calls to pump messages + // if the plugin enters a modal loop. // Cancels a pending request. + virtual void SetWindowlessPumpEvent(HANDLE pump_messages_event) = 0; +#endif virtual void CancelResource(int id) = 0; virtual void Invalidate() = 0; virtual void InvalidateRect(const gfx::Rect& rect) = 0; @@ -132,7 +134,7 @@ class WebPlugin { const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed) = 0; + intptr_t notify_data, bool popups_allowed) = 0; // Cancels document load. virtual void CancelDocumentLoad() = 0; @@ -140,9 +142,9 @@ class WebPlugin { // Initiates a HTTP range request. virtual void InitiateHTTPRangeRequest(const char* url, const char* range_info, - void* existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data) = 0; + intptr_t notify_data) = 0; // Returns true iff in off the record (Incognito) mode. virtual bool IsOffTheRecord() = 0; diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h index 7f0f424..a6e711bd 100644 --- a/webkit/glue/webplugin_delegate.h +++ b/webkit/glue/webplugin_delegate.h @@ -105,7 +105,7 @@ class WebPluginDelegate { virtual void SendJavaScriptStream(const std::string& url, const std::wstring& result, bool success, bool notify_needed, - int notify_data) = 0; + intptr_t notify_data) = 0; // Receives notification about data being available. virtual void DidReceiveManualResponse(const std::string& url, @@ -133,12 +133,12 @@ class WebPluginDelegate { virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, bool notify_needed, - void *notify_data, - void* stream) = 0; + intptr_t notify_data, + intptr_t stream) = 0; // Notifies the delegate about a Get/Post URL request getting routed. virtual void URLRequestRouted(const std::string&url, bool notify_needed, - void* notify_data) = 0; + intptr_t notify_data) = 0; virtual bool IsWindowless() const; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index e822cfc..f61bb16 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -336,8 +336,7 @@ WebPluginImpl::WebPluginImpl(WebCore::HTMLPlugInElement* element, WebPluginImpl::~WebPluginImpl() { } -bool WebPluginImpl::SetWindow(gfx::NativeView window, - HANDLE pump_messages_event) { +bool WebPluginImpl::SetWindow(gfx::NativeView window) { if (window) { DCHECK(!windowless_); // Make sure not called twice. window_ = window; @@ -366,7 +365,7 @@ bool WebPluginImpl::CompleteURL(const std::string& url_in, bool WebPluginImpl::ExecuteScript(const std::string& url, const std::wstring& script, bool notify_needed, - int notify_data, + intptr_t notify_data, bool popups_allowed) { // This could happen if the WebPluginContainer was already deleted. if (!frame()) @@ -1006,7 +1005,7 @@ void WebPluginImpl::didReceiveResponse(WebCore::ResourceHandle* handle, WebPluginResourceClient* resource_client = delegate_->CreateResourceClient(clients_[i].id, plugin_url_.spec().c_str(), - NULL, false, NULL); + false, 0, NULL); clients_[i].client = resource_client; client = resource_client; break; @@ -1151,7 +1150,7 @@ void WebPluginImpl::HandleURLRequest(const char *method, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed) { + intptr_t notify_data, bool popups_allowed) { HandleURLRequestInternal(method, is_javascript_url, target, len, buf, is_file_data, notify, url, notify_data, popups_allowed, true); @@ -1160,7 +1159,7 @@ void WebPluginImpl::HandleURLRequest(const char *method, void WebPluginImpl::HandleURLRequestInternal( const char *method, bool is_javascript_url, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, - const char* url, void* notify_data, bool popups_allowed, + const char* url, intptr_t notify_data, bool popups_allowed, bool use_plugin_src_as_referrer) { // For this request, we either route the output to a frame // because a target has been specified, or we handle the request @@ -1190,9 +1189,8 @@ void WebPluginImpl::HandleURLRequestInternal( WebCore::String(escaped_script.data(), static_cast<int>(escaped_script.length()))); - ExecuteScript(original_url, - webkit_glue::StringToStdWString(script), notify, - reinterpret_cast<int>(notify_data), popups_allowed); + ExecuteScript(original_url, webkit_glue::StringToStdWString(script), notify, + notify_data, popups_allowed); } else { std::string complete_url_string; CompleteURL(url, &complete_url_string); @@ -1288,9 +1286,9 @@ void WebPluginImpl::CancelDocumentLoad() { void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, const char* range_info, - HANDLE existing_stream, + intptr_t existing_stream, bool notify_needed, - HANDLE notify_data) { + int notify_data) { int resource_id = GetNextResourceId(); std::string complete_url_string; CompleteURL(url, &complete_url_string); diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h index 8e0b6d2..a93b299 100644 --- a/webkit/glue/webplugin_impl.h +++ b/webkit/glue/webplugin_impl.h @@ -147,7 +147,10 @@ class WebPluginImpl : public WebPlugin, int arg_count, char** arg_names, char** arg_values); // WebPlugin implementation: - bool SetWindow(gfx::NativeView window, HANDLE pump_messages_event); + bool SetWindow(gfx::NativeView window); +#if defined(OS_WIN) + void SetWindowlessPumpEvent(HANDLE pump_messages_event) { } +#endif // Given a (maybe partial) url, completes using the base url. bool CompleteURL(const std::string& url_in, std::string* url_out); @@ -158,7 +161,7 @@ class WebPluginImpl : public WebPlugin, // plugin as is. This avoids having to track the notification arguments // in the plugin process. bool ExecuteScript(const std::string& url, const std::wstring& script, - bool notify_needed, int notify_data, bool popups_allowed); + bool notify_needed, intptr_t notify_data, bool popups_allowed); // Given a download request, check if we need to route the output // to a frame. Returns ROUTED if the load is done and routed to @@ -289,13 +292,13 @@ class WebPluginImpl : public WebPlugin, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed); + intptr_t notify_data, bool popups_allowed); void CancelDocumentLoad(); void InitiateHTTPRangeRequest(const char* url, const char* range_info, - HANDLE existing_stream, bool notify_needed, - HANDLE notify_data); + intptr_t existing_stream, bool notify_needed, + intptr_t notify_data); // Ignore in-process plugins mode for this flag. bool IsOffTheRecord() { return false; } @@ -309,7 +312,7 @@ class WebPluginImpl : public WebPlugin, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, - void* notify_data, bool popups_allowed, + intptr_t notify_data, bool popups_allowed, bool use_plugin_src_as_referrer); // Tears down the existing plugin instance and creates a new plugin instance |