summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 21:12:11 +0000
committerpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 21:12:11 +0000
commite344a05a48730f00fe670e6ceb00afdc8b1be414 (patch)
tree7d0ef6750ff61630da9eb1c5e52091711e4a950d /chrome/common
parent35e6071b402c63474795843629533a2444f8e8ad (diff)
downloadchromium_src-e344a05a48730f00fe670e6ceb00afdc8b1be414.zip
chromium_src-e344a05a48730f00fe670e6ceb00afdc8b1be414.tar.gz
chromium_src-e344a05a48730f00fe670e6ceb00afdc8b1be414.tar.bz2
Implement HTML selects as native Cocoa controls for Chrome.
BUG=8389 (http://crbug.com/8389) Review URL: http://codereview.chromium.org/57032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/render_messages.h105
-rw-r--r--chrome/common/render_messages_internal.h5
2 files changed, 110 insertions, 0 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index f711cf6..e0c6004 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -374,6 +374,23 @@ struct ViewHostMsg_Audio_CreateStream {
size_t packet_size;
};
+// This message is used for supporting popup menus on Mac OS X using native
+// Cocoa controls. The renderer sends us this message which we use to populate
+// the popup menu.
+struct ViewHostMsg_ShowPopup_Params {
+ // Position on the screen.
+ gfx::Rect bounds;
+
+ // The height of each item in the menu.
+ int item_height;
+
+ // The currently selected (displayed) item in the menu.
+ int selected_item;
+
+ // The entire list of items in the popup menu.
+ std::vector<WebMenuItem> popup_items;
+};
+
namespace IPC {
template <>
@@ -1832,6 +1849,94 @@ struct ParamTraits<WebAppCacheContext::ContextType> {
}
};
+template<>
+struct ParamTraits<WebMenuItem::Type> {
+ typedef WebMenuItem::Type param_type;
+ static void Write(Message* m, const param_type& p) {
+ m->WriteInt(p);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ int type;
+ if (!m->ReadInt(iter, &type))
+ return false;
+ *p = static_cast<WebMenuItem::Type>(type);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ std::wstring type;
+ switch (p) {
+ case WebMenuItem::OPTION:
+ type = L"OPTION";
+ break;
+ case WebMenuItem::GROUP:
+ type = L"GROUP";
+ break;
+ case WebMenuItem::SEPARATOR:
+ type = L"SEPARATOR";
+ break;
+ default:
+ type = L"UNKNOWN";
+ break;
+ }
+ LogParam(type, l);
+ }
+};
+
+template<>
+struct ParamTraits<WebMenuItem> {
+ typedef WebMenuItem param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.label);
+ WriteParam(m, p.type);
+ WriteParam(m, p.enabled);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return
+ ReadParam(m, iter, &p->label) &&
+ ReadParam(m, iter, &p->type) &&
+ ReadParam(m, iter, &p->enabled);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.label, l);
+ l->append(L", ");
+ LogParam(p.type, l);
+ l->append(L", ");
+ LogParam(p.enabled, l);
+ l->append(L")");
+ }
+};
+
+// Traits for ViewHostMsg_ShowPopup_Params.
+template <>
+struct ParamTraits<ViewHostMsg_ShowPopup_Params> {
+ typedef ViewHostMsg_ShowPopup_Params param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.bounds);
+ WriteParam(m, p.item_height);
+ WriteParam(m, p.selected_item);
+ WriteParam(m, p.popup_items);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return
+ ReadParam(m, iter, &p->bounds) &&
+ ReadParam(m, iter, &p->item_height) &&
+ ReadParam(m, iter, &p->selected_item) &&
+ ReadParam(m, iter, &p->popup_items);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.bounds, l);
+ l->append(L", ");
+ LogParam(p.item_height, l);
+ l->append(L", ");
+ LogParam(p.selected_item, l);
+ l->append(L", ");
+ LogParam(p.popup_items, l);
+ l->append(L")");
+ }
+};
+
} // namespace IPC
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index fe0161e..ae14335 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1337,4 +1337,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL2(ViewHostMsg_ExtensionPostMessage,
int /* port_id */,
std::string /* message */)
+
+ // Message to show a popup menu using native cocoa controls (Mac only).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup,
+ ViewHostMsg_ShowPopup_Params)
+
IPC_END_MESSAGES(ViewHost)