// Copyright (c) 2011 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. // IPC messages for page rendering. // Multiply-included message file, hence no include guard. #include "content/common/common_param_traits.h" #include "content/common/css_colors.h" #include "content/common/edit_command.h" #include "content/common/renderer_preferences.h" #include "ipc/ipc_message_macros.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" #include "ui/gfx/rect.h" #include "webkit/glue/context_menu.h" #include "webkit/glue/webmenuitem.h" #include "webkit/glue/webpreferences.h" #define IPC_MESSAGE_START ViewMsgStart IPC_ENUM_TRAITS(CSSColors::CSSColorName) IPC_ENUM_TRAITS(RendererPreferencesHintingEnum) IPC_ENUM_TRAITS(RendererPreferencesSubpixelRenderingEnum) IPC_ENUM_TRAITS(WebKit::WebContextMenuData::MediaType) IPC_ENUM_TRAITS(WebKit::WebMediaPlayerAction::Type) IPC_ENUM_TRAITS(WebMenuItem::Type) IPC_STRUCT_TRAITS_BEGIN(EditCommand) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(value) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(RendererPreferences) IPC_STRUCT_TRAITS_MEMBER(can_accept_load_drops) IPC_STRUCT_TRAITS_MEMBER(should_antialias_text) IPC_STRUCT_TRAITS_MEMBER(hinting) IPC_STRUCT_TRAITS_MEMBER(subpixel_rendering) IPC_STRUCT_TRAITS_MEMBER(focus_ring_color) IPC_STRUCT_TRAITS_MEMBER(thumb_active_color) IPC_STRUCT_TRAITS_MEMBER(thumb_inactive_color) IPC_STRUCT_TRAITS_MEMBER(track_color) IPC_STRUCT_TRAITS_MEMBER(active_selection_bg_color) IPC_STRUCT_TRAITS_MEMBER(active_selection_fg_color) IPC_STRUCT_TRAITS_MEMBER(inactive_selection_bg_color) IPC_STRUCT_TRAITS_MEMBER(inactive_selection_fg_color) IPC_STRUCT_TRAITS_MEMBER(browser_handles_top_level_requests) IPC_STRUCT_TRAITS_MEMBER(caret_blink_interval) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(WebKit::WebMediaPlayerAction) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(enable) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(WebPreferences) IPC_STRUCT_TRAITS_MEMBER(standard_font_family) IPC_STRUCT_TRAITS_MEMBER(fixed_font_family) IPC_STRUCT_TRAITS_MEMBER(serif_font_family) IPC_STRUCT_TRAITS_MEMBER(sans_serif_font_family) IPC_STRUCT_TRAITS_MEMBER(cursive_font_family) IPC_STRUCT_TRAITS_MEMBER(fantasy_font_family) IPC_STRUCT_TRAITS_MEMBER(default_font_size) IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size) IPC_STRUCT_TRAITS_MEMBER(minimum_font_size) IPC_STRUCT_TRAITS_MEMBER(minimum_logical_font_size) IPC_STRUCT_TRAITS_MEMBER(default_encoding) IPC_STRUCT_TRAITS_MEMBER(javascript_enabled) IPC_STRUCT_TRAITS_MEMBER(web_security_enabled) IPC_STRUCT_TRAITS_MEMBER(javascript_can_open_windows_automatically) IPC_STRUCT_TRAITS_MEMBER(loads_images_automatically) IPC_STRUCT_TRAITS_MEMBER(plugins_enabled) IPC_STRUCT_TRAITS_MEMBER(dom_paste_enabled) IPC_STRUCT_TRAITS_MEMBER(developer_extras_enabled) IPC_STRUCT_TRAITS_MEMBER(inspector_settings) IPC_STRUCT_TRAITS_MEMBER(site_specific_quirks_enabled) IPC_STRUCT_TRAITS_MEMBER(shrinks_standalone_images_to_fit) IPC_STRUCT_TRAITS_MEMBER(uses_universal_detector) IPC_STRUCT_TRAITS_MEMBER(text_areas_are_resizable) IPC_STRUCT_TRAITS_MEMBER(java_enabled) IPC_STRUCT_TRAITS_MEMBER(allow_scripts_to_close_windows) IPC_STRUCT_TRAITS_MEMBER(uses_page_cache) IPC_STRUCT_TRAITS_MEMBER(remote_fonts_enabled) IPC_STRUCT_TRAITS_MEMBER(javascript_can_access_clipboard) IPC_STRUCT_TRAITS_MEMBER(xss_auditor_enabled) IPC_STRUCT_TRAITS_MEMBER(local_storage_enabled) IPC_STRUCT_TRAITS_MEMBER(databases_enabled) IPC_STRUCT_TRAITS_MEMBER(application_cache_enabled) IPC_STRUCT_TRAITS_MEMBER(tabs_to_links) IPC_STRUCT_TRAITS_MEMBER(hyperlink_auditing_enabled) IPC_STRUCT_TRAITS_MEMBER(user_style_sheet_enabled) IPC_STRUCT_TRAITS_MEMBER(user_style_sheet_location) IPC_STRUCT_TRAITS_MEMBER(author_and_user_styles_enabled) IPC_STRUCT_TRAITS_MEMBER(frame_flattening_enabled) IPC_STRUCT_TRAITS_MEMBER(allow_universal_access_from_file_urls) IPC_STRUCT_TRAITS_MEMBER(allow_file_access_from_file_urls) IPC_STRUCT_TRAITS_MEMBER(webaudio_enabled) IPC_STRUCT_TRAITS_MEMBER(experimental_webgl_enabled) IPC_STRUCT_TRAITS_MEMBER(gl_multisampling_enabled) IPC_STRUCT_TRAITS_MEMBER(show_composited_layer_borders) IPC_STRUCT_TRAITS_MEMBER(show_composited_layer_tree) IPC_STRUCT_TRAITS_MEMBER(show_fps_counter) IPC_STRUCT_TRAITS_MEMBER(accelerated_compositing_enabled) IPC_STRUCT_TRAITS_MEMBER(force_compositing_mode) IPC_STRUCT_TRAITS_MEMBER(composite_to_texture_enabled) IPC_STRUCT_TRAITS_MEMBER(accelerated_2d_canvas_enabled) IPC_STRUCT_TRAITS_MEMBER(accelerated_plugins_enabled) IPC_STRUCT_TRAITS_MEMBER(accelerated_layers_enabled) IPC_STRUCT_TRAITS_MEMBER(accelerated_video_enabled) IPC_STRUCT_TRAITS_MEMBER(memory_info_enabled) IPC_STRUCT_TRAITS_MEMBER(interactive_form_validation_enabled) IPC_STRUCT_TRAITS_MEMBER(fullscreen_enabled) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(WebMenuItem) IPC_STRUCT_TRAITS_MEMBER(label) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(action) IPC_STRUCT_TRAITS_MEMBER(rtl) IPC_STRUCT_TRAITS_MEMBER(has_directional_override) IPC_STRUCT_TRAITS_MEMBER(enabled) IPC_STRUCT_TRAITS_MEMBER(checked) IPC_STRUCT_TRAITS_MEMBER(submenu) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(webkit_glue::CustomContextMenuContext) IPC_STRUCT_TRAITS_MEMBER(is_pepper_menu) IPC_STRUCT_TRAITS_MEMBER(request_id) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(ContextMenuParams) IPC_STRUCT_TRAITS_MEMBER(media_type) IPC_STRUCT_TRAITS_MEMBER(x) IPC_STRUCT_TRAITS_MEMBER(y) IPC_STRUCT_TRAITS_MEMBER(link_url) IPC_STRUCT_TRAITS_MEMBER(unfiltered_link_url) IPC_STRUCT_TRAITS_MEMBER(src_url) IPC_STRUCT_TRAITS_MEMBER(is_image_blocked) IPC_STRUCT_TRAITS_MEMBER(page_url) IPC_STRUCT_TRAITS_MEMBER(frame_url) IPC_STRUCT_TRAITS_MEMBER(frame_content_state) IPC_STRUCT_TRAITS_MEMBER(media_flags) IPC_STRUCT_TRAITS_MEMBER(selection_text) IPC_STRUCT_TRAITS_MEMBER(misspelled_word) IPC_STRUCT_TRAITS_MEMBER(dictionary_suggestions) IPC_STRUCT_TRAITS_MEMBER(spellcheck_enabled) IPC_STRUCT_TRAITS_MEMBER(is_editable) #if defined(OS_MACOSX) IPC_STRUCT_TRAITS_MEMBER(writing_direction_default) IPC_STRUCT_TRAITS_MEMBER(writing_direction_left_to_right) IPC_STRUCT_TRAITS_MEMBER(writing_direction_right_to_left) #endif // OS_MACOSX IPC_STRUCT_TRAITS_MEMBER(edit_flags) IPC_STRUCT_TRAITS_MEMBER(security_info) IPC_STRUCT_TRAITS_MEMBER(frame_charset) IPC_STRUCT_TRAITS_MEMBER(custom_context) IPC_STRUCT_TRAITS_MEMBER(custom_items) IPC_STRUCT_TRAITS_END() // 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. IPC_STRUCT_BEGIN(ViewHostMsg_ShowPopup_Params) // Position on the screen. IPC_STRUCT_MEMBER(gfx::Rect, bounds) // The height of each item in the menu. IPC_STRUCT_MEMBER(int, item_height) // The size of the font to use for those items. IPC_STRUCT_MEMBER(double, item_font_size) // The currently selected (displayed) item in the menu. IPC_STRUCT_MEMBER(int, selected_item) // The entire list of items in the popup menu. IPC_STRUCT_MEMBER(std::vector, popup_items) // Whether items should be right-aligned. IPC_STRUCT_MEMBER(bool, right_aligned) IPC_STRUCT_END() IPC_STRUCT_BEGIN(ViewMsg_New_Params) // The parent window's id. IPC_STRUCT_MEMBER(gfx::NativeViewId, parent_window) // Renderer-wide preferences. IPC_STRUCT_MEMBER(RendererPreferences, renderer_preferences) // Preferences for this view. IPC_STRUCT_MEMBER(WebPreferences, web_preferences) // The ID of the view to be created. IPC_STRUCT_MEMBER(int32, view_id) // The session storage namespace ID this view should use. IPC_STRUCT_MEMBER(int64, session_storage_namespace_id) // The name of the frame associated with this view (or empty if none). IPC_STRUCT_MEMBER(string16, frame_name) IPC_STRUCT_END() // Messages sent from the browser to the renderer. // Used typically when recovering from a crash. The new rendering process // sets its global "next page id" counter to the given value. IPC_MESSAGE_CONTROL1(ViewMsg_SetNextPageID, int32 /* next_page_id */) // Sends System Colors corresponding to a set of CSS color keywords // down the pipe. // This message must be sent to the renderer immediately on launch // before creating any new views. // The message can also be sent during a renderer's lifetime if system colors // are updated. // TODO(jeremy): Possibly change IPC format once we have this all hooked up. IPC_MESSAGE_ROUTED1(ViewMsg_SetCSSColors, std::vector) // Asks the browser for a unique routing ID. IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_GenerateRoutingID, int /* routing_id */) // Tells the renderer to create a new view. // This message is slightly different, the view it takes (via // ViewMsg_New_Params) is the view to create, the message itself is sent as a // non-view control message. IPC_MESSAGE_CONTROL1(ViewMsg_New, ViewMsg_New_Params) // 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. IPC_MESSAGE_ROUTED1(ViewMsg_CreatingNew_ACK, gfx::NativeViewId /* parent_hwnd */) // Sends updated preferences to the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_SetRendererPrefs, RendererPreferences) // This passes a set of webkit preferences down to the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences, WebPreferences) // Tells the render view to close. IPC_MESSAGE_ROUTED0(ViewMsg_Close) // Tells the render view to change its size. A ViewHostMsg_PaintRect message // is generated in response provided new_size is not empty and not equal to // the view's current size. The generated ViewHostMsg_PaintRect message will // have the IS_RESIZE_ACK flag set. It also receives the resizer rect so that // we don't have to fetch it every time WebKit asks for it. IPC_MESSAGE_ROUTED2(ViewMsg_Resize, gfx::Size /* new_size */, gfx::Rect /* resizer_rect */) // Sent to inform the view that it was hidden. This allows it to reduce its // resource utilization. IPC_MESSAGE_ROUTED0(ViewMsg_WasHidden) // Tells the render view that it is no longer hidden (see WasHidden), and the // render view is expected to respond with a full repaint if needs_repainting // is true. In that case, the generated ViewHostMsg_PaintRect message will // have the IS_RESTORE_ACK flag set. If needs_repainting is false, then this // message does not trigger a message in response. IPC_MESSAGE_ROUTED1(ViewMsg_WasRestored, bool /* needs_repainting */) // Sent to render the view into the supplied transport DIB, resize // the web widget to match the |page_size|, scale it by the // appropriate scale to make it fit the |desired_size|, and return // it. In response to this message, the host generates a // ViewHostMsg_PaintAtSize_ACK message. Note that the DIB *must* be // the right size to receive an RGBA image at the |desired_size|. // |tag| is sent along with ViewHostMsg_PaintAtSize_ACK unmodified to // identify the PaintAtSize message the ACK belongs to. IPC_MESSAGE_ROUTED4(ViewMsg_PaintAtSize, TransportDIB::Handle /* dib_handle */, int /* tag */, gfx::Size /* page_size */, gfx::Size /* desired_size */) // Tells the render view that a ViewHostMsg_UpdateRect message was processed. // This signals the render view that it can send another UpdateRect message. IPC_MESSAGE_ROUTED0(ViewMsg_UpdateRect_ACK) // Message payload includes: // 1. A blob that should be cast to WebInputEvent // 2. An optional boolean value indicating if a RawKeyDown event is associated // to a keyboard shortcut of the browser. IPC_MESSAGE_ROUTED0(ViewMsg_HandleInputEvent) // This message notifies the renderer that the next key event is bound to one // or more pre-defined edit commands. If the next key event is not handled // by webkit, the specified edit commands shall be executed against current // focused frame. // Parameters // * edit_commands (see chrome/common/edit_command_types.h) // Contains one or more edit commands. // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed // definition of webkit edit commands. // // This message must be sent just before sending a key event. IPC_MESSAGE_ROUTED1(ViewMsg_SetEditCommandsForNextKeyEvent, std::vector /* edit_commands */) // Message payload is the name/value of a WebCore edit command to execute. IPC_MESSAGE_ROUTED2(ViewMsg_ExecuteEditCommand, std::string, /* name */ std::string /* value */) IPC_MESSAGE_ROUTED0(ViewMsg_MouseCaptureLost) // TODO(darin): figure out how this meshes with RestoreFocus IPC_MESSAGE_ROUTED1(ViewMsg_SetFocus, bool /* enable */) // Tells the renderer to focus the first (last if reverse is true) focusable // node. IPC_MESSAGE_ROUTED1(ViewMsg_SetInitialFocus, bool /* reverse */) // Tells the renderer to scroll the currently focused node into view only if // the currently focused node is a Text node (textfield, text area or content // editable divs). IPC_MESSAGE_ROUTED0(ViewMsg_ScrollFocusedEditableNodeIntoView) // Executes custom context menu action that was provided from WebKit. IPC_MESSAGE_ROUTED2(ViewMsg_CustomContextMenuAction, webkit_glue::CustomContextMenuContext /* custom_context */, unsigned /* action */) // Sent in response to a ViewHostMsg_ContextMenu to let the renderer know that // the menu has been closed. IPC_MESSAGE_ROUTED1(ViewMsg_ContextMenuClosed, webkit_glue::CustomContextMenuContext /* custom_context */) // Tells the renderer to perform the given action on the media player // located at the given point. IPC_MESSAGE_ROUTED2(ViewMsg_MediaPlayerActionAt, gfx::Point, /* location */ WebKit::WebMediaPlayerAction) // Messages sent from the renderer to the browser. // Used to tell the parent that the user right clicked on an area of the // content area, and a context menu should be shown for it. The params // object contains information about the node(s) that were selected when the // user right clicked. IPC_MESSAGE_ROUTED1(ViewHostMsg_ContextMenu, ContextMenuParams) // Message to show a popup menu using native cocoa controls (Mac only). IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup, ViewHostMsg_ShowPopup_Params)