From 18bcc3c1e8ac29683e6d09a9c2d8b3037b0fb360 Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Tue, 27 Jan 2009 21:39:15 +0000 Subject: POSIX: gfx::NativeViewId and CrossProcessEvent Create a couple new typedefs for porting work. Firstly, gfx::NativeViewId is a handle to a platform specific widget in the renderer process. For Windows, this is just a HWND as before. However, in other platforms the ids used in the renderer process will be something else. CrossProcessEvent is the type of a HANDLE to a Windows event object which is used across processes. Since we aren't going to support these sorts of events on non-Windows platforms, this will have to go away at some point. For now, however, this lets us build code without too many ifdefs all over the place. Review URL: http://codereview.chromium.org/18768 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8756 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/modal_dialog_event.h | 20 +++++++++++++ chrome/common/render_messages.h | 24 +++++++++++++++ chrome/common/render_messages_internal.h | 50 ++++++++++---------------------- 3 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 chrome/common/modal_dialog_event.h (limited to 'chrome/common') diff --git a/chrome/common/modal_dialog_event.h b/chrome/common/modal_dialog_event.h new file mode 100644 index 0000000..2a14c87 --- /dev/null +++ b/chrome/common/modal_dialog_event.h @@ -0,0 +1,20 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_MODAL_DIALOG_EVENT_H_ +#define CHROME_COMMON_MODAL_DIALOG_EVENT_H_ + +// This structure is passed around where we need a modal dialog event, which +// is currently not plumbed on Mac & Linux. +// +// TODO(port) Fix this. This structure should probably go away and we should +// do the modal dialog event in some portable way. If you remove this, be +// sure to also remove the ParamTraits for it in resource_messages.h +struct ModalDialogEvent { +#if defined(OS_WIN) + HANDLE event; +#endif +}; + +#endif // CHROME_COMMON_MODAL_DIALOG_EVENT_H_ diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index b0338b7..83dddb1 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -15,6 +15,7 @@ #include "chrome/common/filter_policy.h" #include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" +#include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_transition_types.h" #include "googleurl/src/gurl.h" #include "net/base/upload_data.h" @@ -1723,6 +1724,29 @@ struct ParamTraits { } }; +template<> +struct ParamTraits { + typedef ModalDialogEvent param_type; +#if defined(OS_WIN) + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.event); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->event); + } +#else + static void Write(Message* m, const param_type& p) { + } + static bool Read(const Message* m, void** iter, param_type* p) { + return true; + } +#endif + + static void Log(const param_type& p, std::wstring* l) { + l->append(L""); + } +}; + } // namespace IPC #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 1081e54..30c6469 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -13,6 +13,7 @@ #include "base/clipboard.h" #include "base/gfx/rect.h" +#include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" #include "chrome/common/ipc_message_macros.h" #include "skia/include/SkBitmap.h" @@ -39,12 +40,14 @@ IPC_BEGIN_MESSAGES(View, 1) IPC_MESSAGE_CONTROL1(ViewMsg_SetNextPageID, int32 /* next_page_id */) -#if defined(OS_WIN) // Tells the renderer to create a new view. // This message is slightly different, the view it takes is the view to // create, the message itself is sent as a non-view control message. - IPC_MESSAGE_CONTROL4(ViewMsg_New, HWND, HANDLE, WebPreferences, int32) -#endif // defined(OS_WIN) + IPC_MESSAGE_CONTROL4(ViewMsg_New, + gfx::NativeViewId, /* parent window */ + ModalDialogEvent, /* model dialog box event */ + WebPreferences, + int32 /* view id */) // Tells the renderer to set its maximum cache size to the supplied value IPC_MESSAGE_CONTROL3(ViewMsg_SetCacheCapacities, @@ -61,13 +64,8 @@ IPC_BEGIN_MESSAGES(View, 1) // Reply in response to ViewHostMsg_ShowView or ViewHostMsg_ShowWidget. // similar to the new command, but used when the renderer created a view // first, and we need to update it -#if defined(OS_WIN) IPC_MESSAGE_ROUTED1(ViewMsg_CreatingNew_ACK, - HWND /* parent_hwnd */) -#else // defined(OS_WIN) - // On POSIX, we don't pass "window handles" between processes. - IPC_MESSAGE_ROUTED0(ViewMsg_CreatingNew_ACK) -#endif + gfx::NativeViewId /* parent_hwnd */) // Tells the render view to close. IPC_MESSAGE_ROUTED0(ViewMsg_Close) @@ -495,7 +493,6 @@ IPC_END_MESSAGES(View) // These are messages sent from the renderer to the browser process. IPC_BEGIN_MESSAGES(ViewHost, 2) -#if defined(OS_WIN) // Sent by the renderer when it is creating a new window. The browser creates // a tab for it and responds with a ViewMsg_CreatingNew_ACK. If route_id is // MSG_ROUTING_NONE, the view couldn't be created. modal_dialog_event is set @@ -504,16 +501,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) int /* opener_id */, bool /* user_gesture */, int /* route_id */, - HANDLE /* modal_dialog_event */) -#else // defined(OS_WIN) - // On POSIX, we don't use the cross process events for modal dialogs. At some - // point, we won't use them on any platform, but for now we just define a - // message without the last parameter. - IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWindow, - int /* opener_id */, - bool /* user_gesture */, - int /* route_id */) -#endif + ModalDialogEvent /* modal_dialog_event */) // Similar to ViewHostMsg_CreateView, except used for sub-widgets, like //