// 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. // This header is meant to be included in multiple passes, hence no traditional // header guard. // See ipc_message_macros.h for explanation of the macros and passes. #include #include #include "build/build_config.h" #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 "chrome/common/transport_dib.h" #include "skia/include/SkBitmap.h" #include "webkit/glue/console_message_level.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/screen_info.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webinputevent.h" #include "webkit/glue/webplugin.h" // TODO(mpcomplete): rename ViewMsg and ViewHostMsg to something that makes // more sense with our current design. //----------------------------------------------------------------------------- // RenderView messages // These are messages sent from the browser to the renderer process. IPC_BEGIN_MESSAGES(View) // 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 */) // 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, 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, size_t /* min_dead_capacity */, size_t /* max_dead_capacity */, size_t /* capacity */) // Allows a chrome plugin loaded in the browser process to send arbitrary // data to an instance of the same plugin loaded in a renderer process. IPC_MESSAGE_CONTROL2(ViewMsg_PluginMessage, FilePath /* plugin_path of plugin */, std::vector /* opaque data */) // 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 */) // 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 */) // Tells the render view to capture a thumbnail image of the page. The // render view responds with a ViewHostMsg_Thumbnail. IPC_MESSAGE_ROUTED0(ViewMsg_CaptureThumbnail) // Tells the render view that a ViewHostMsg_PaintRect message was processed. // This signals the render view that it can send another PaintRect message. IPC_MESSAGE_ROUTED0(ViewMsg_PaintRect_ACK) // Tells the render view to switch the CSS to print media type, renders every // requested pages and switch back the CSS to display media type. IPC_MESSAGE_ROUTED0(ViewMsg_PrintPages) // Tells the render view that a ViewHostMsg_ScrollRect message was processed. // This signals the render view that it can send another ScrollRect message. IPC_MESSAGE_ROUTED0(ViewMsg_ScrollRect_ACK) // Message payload is a blob that should be cast to WebInputEvent IPC_MESSAGE_ROUTED0(ViewMsg_HandleInputEvent) 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 perform the specified navigation, interrupting any // existing navigation. IPC_MESSAGE_ROUTED1(ViewMsg_Navigate, ViewMsg_Navigate_Params) IPC_MESSAGE_ROUTED0(ViewMsg_Stop) // Tells the renderer to load the specified html text and report a navigation // to display_url if passing true for new navigation. IPC_MESSAGE_ROUTED4(ViewMsg_LoadAlternateHTMLText, std::string /* utf8 html text */, bool, /* new navigation */ GURL /* display url */, std::string /* security info */) // This message notifies the renderer that the user has closed the FindInPage // window (and that the selection should be cleared and the tick-marks // erased). If |clear_selection| is true, it will also clear the current // selection. IPC_MESSAGE_ROUTED1(ViewMsg_StopFinding, bool /* clear_selection */) // These messages are typically generated from context menus and request the // renderer to apply the specified operation to the current selection. IPC_MESSAGE_ROUTED0(ViewMsg_Undo) IPC_MESSAGE_ROUTED0(ViewMsg_Redo) IPC_MESSAGE_ROUTED0(ViewMsg_Cut) IPC_MESSAGE_ROUTED0(ViewMsg_Copy) IPC_MESSAGE_ROUTED0(ViewMsg_Paste) IPC_MESSAGE_ROUTED1(ViewMsg_Replace, std::wstring) IPC_MESSAGE_ROUTED0(ViewMsg_ToggleSpellCheck) IPC_MESSAGE_ROUTED0(ViewMsg_Delete) IPC_MESSAGE_ROUTED0(ViewMsg_SelectAll) // Copies the image at location x, y to the clipboard (if there indeed is an // image at that location). IPC_MESSAGE_ROUTED2(ViewMsg_CopyImageAt, int /* x */, int /* y */) // History system notification that the visited link database has been // replaced. It has one SharedMemoryHandle argument consisting of the table // handle. This handle is valid in the context of the renderer IPC_MESSAGE_CONTROL1(ViewMsg_VisitedLink_NewTable, base::SharedMemoryHandle) // Notification that the user scripts have been updated. It has one // SharedMemoryHandle argument consisting of the pickled script data. This // handle is valid in the context of the renderer. IPC_MESSAGE_CONTROL1(ViewMsg_UserScripts_NewScripts, base::SharedMemoryHandle) // Sent when the user wants to search for a word on the page (find in page). // Request parameters are passed in as a FindInPageMsg_Request struct. IPC_MESSAGE_ROUTED1(ViewMsg_Find, FindInPageRequest) // Sent when the headers are available for a resource request. IPC_MESSAGE_ROUTED2(ViewMsg_Resource_ReceivedResponse, int /* request_id */, ResourceResponseHead) // Sent as upload progress is being made IPC_MESSAGE_ROUTED3(ViewMsg_Resource_UploadProgress, int /* request_id */, int64 /* position */, int64 /* size */) // Sent when the request has been redirected. IPC_MESSAGE_ROUTED2(ViewMsg_Resource_ReceivedRedirect, int /* request_id */, GURL /* new_url */) // Sent when some data from a resource request is ready. The handle should // already be mapped into the process that receives this message. IPC_MESSAGE_ROUTED3(ViewMsg_Resource_DataReceived, int /* request_id */, base::SharedMemoryHandle /* data */, int /* data_len */) // Sent when the request has been completed. IPC_MESSAGE_ROUTED3(ViewMsg_Resource_RequestComplete, int /* request_id */, URLRequestStatus /* status */, std::string /* security info */) // Request for the renderer to evaluate an xpath to a frame and execute a // javascript: url in that frame's context. The message is completely // asynchronous and no corresponding response message is sent back. // // frame_xpath contains the modified xpath notation to identify an inner // subframe (starting from the root frame). It is a concatenation of // number of smaller xpaths delimited by '\n'. Each chunk in the string can // be evaluated to a frame in its parent-frame's context. // // Example: /html/body/iframe/\n/html/body/div/iframe/\n/frameset/frame[0] // can be broken into 3 xpaths // /html/body/iframe evaluates to an iframe within the root frame // /html/body/div/iframe evaluates to an iframe within the level-1 iframe // /frameset/frame[0] evaluates to first frame within the level-2 iframe // // jscript_url is the string containing the javascript: url to be executed // in the target frame's context. The string should start with "javascript:" // and continue with a valid JS text. IPC_MESSAGE_ROUTED2(ViewMsg_ScriptEvalRequest, std::wstring, /* frame_xpath */ std::wstring /* jscript_url */) // Log a message to the console of the target frame IPC_MESSAGE_ROUTED3(ViewMsg_AddMessageToConsole, std::wstring, /* frame_xpath */ std::wstring, /* msg */ ConsoleMessageLevel /* level */) // Initialize the V8 debugger in the renderer. IPC_MESSAGE_ROUTED0(ViewMsg_DebugAttach) // Shutdown the V8 debugger in the renderer. IPC_MESSAGE_ROUTED0(ViewMsg_DebugDetach) // Break V8 execution. IPC_MESSAGE_ROUTED1(ViewMsg_DebugBreak, bool /* force */) // Send a command to the V8 debugger. IPC_MESSAGE_ROUTED1(ViewMsg_DebugCommand, std::wstring /* cmd */) // RenderViewHostDelegate::RenderViewCreated method sends this message to a // new renderer to notify it that it will host developer tools UI and should // set up all neccessary bindings and create DevToolsClient instance that // will handle communication with inspected page DevToolsAgent. IPC_MESSAGE_ROUTED0(ViewMsg_SetupDevToolsClient) // Change the zoom level in the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_Zoom, int /* One of PageZoom::Function */) // Change encoding of page in the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding, std::wstring /*new encoding name*/) // Inspect the element at the specified coordinates IPC_MESSAGE_ROUTED2(ViewMsg_InspectElement, int /* x */, int /* y */) // Show the JavaScript console IPC_MESSAGE_ROUTED0(ViewMsg_ShowJavaScriptConsole) // Requests the renderer to reserve a range of page ids. IPC_MESSAGE_ROUTED1(ViewMsg_ReservePageIDRange, int /* size_of_range */) // Fill a form with data and optionally submit it IPC_MESSAGE_ROUTED1(ViewMsg_FormFill, FormData /* form */) // Fill a password form and prepare field autocomplete for multiple // matching logins. IPC_MESSAGE_ROUTED1(ViewMsg_FillPasswordForm, PasswordFormDomManager::FillData /* form_data */) // D&d drop target messages. IPC_MESSAGE_ROUTED3(ViewMsg_DragTargetDragEnter, WebDropData /* drop_data */, gfx::Point /* client_pt */, gfx::Point /* screen_pt */) IPC_MESSAGE_ROUTED2(ViewMsg_DragTargetDragOver, gfx::Point /* client_pt */, gfx::Point /* screen_pt */) IPC_MESSAGE_ROUTED0(ViewMsg_DragTargetDragLeave) IPC_MESSAGE_ROUTED2(ViewMsg_DragTargetDrop, gfx::Point /* client_pt */, gfx::Point /* screen_pt */) IPC_MESSAGE_ROUTED1(ViewMsg_UploadFile, ViewMsg_UploadFile_Params) // Notifies the renderer of updates in mouse position of an in-progress // drag. if |ended| is true, then the user has ended the drag operation. IPC_MESSAGE_ROUTED5(ViewMsg_DragSourceEndedOrMoved, int /* client_x */, int /* client_y */, int /* screen_x */, int /* screen_y */, bool /* ended */) // Notifies the renderer that the system DoDragDrop call has ended. IPC_MESSAGE_ROUTED0(ViewMsg_DragSourceSystemDragEnded) // Used to tell a render view whether it should expose various bindings // that allow JS content extended privileges. See BindingsPolicy for valid // flag values. IPC_MESSAGE_ROUTED1(ViewMsg_AllowBindings, int /* enabled_bindings_flags */) // Tell the renderer to add a property to the DOMUI binding object. This // only works if we allowed DOMUI bindings. IPC_MESSAGE_ROUTED2(ViewMsg_SetDOMUIProperty, std::string /* property_name */, std::string /* property_value_json */) // This message starts/stop monitoring the status of the focused edit // control of a renderer process. // Parameters // * is_active (bool) // Represents whether or not the IME is active in a browser process. // The possible actions when a renderer process receives this message are // listed below: // Value Action // true Start sending IPC messages, ViewHostMsg_ImeUpdateStatus // to notify the status of the focused edit control. // false Stop sending IPC messages, ViewHostMsg_ImeUpdateStatus. IPC_MESSAGE_ROUTED1(ViewMsg_ImeSetInputMode, bool /* is_active */) // This message sends a string being composed with IME. // Parameters // * string_type (int) // Represents the type of the 'ime_string' parameter. // Its possible values and description are listed below: // Value Description // -1 The parameter is not used. // 1 The parameter represents a result string. // 0 The parameter represents a composition string. // * cursor_position (int) // Represents the position of the cursor // * target_start (int) // Represents the position of the beginning of the selection // * target_end (int) // Represents the position of the end of the selection // * ime_string (std::wstring) // Represents the string retrieved from IME (Input Method Editor) IPC_MESSAGE_ROUTED5(ViewMsg_ImeSetComposition, int, /* string_type */ int, /* cursor_position */ int, /* target_start */ int, /* target_end */ std::wstring /* ime_string */ ) // This passes a set of webkit preferences down to the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences, WebPreferences) // Used to notify the render-view that the browser has received a reply for // the Find operation and is interested in receiving the next one. This is // used to prevent the renderer from spamming the browser process with // results. IPC_MESSAGE_ROUTED0(ViewMsg_FindReplyACK) // Used to notify the render-view that we have received a target URL. Used // to prevent target URLs spamming the browser. IPC_MESSAGE_ROUTED0(ViewMsg_UpdateTargetURL_ACK) // Sets the alternate error page URL (link doctor) for the renderer process. IPC_MESSAGE_ROUTED1(ViewMsg_SetAltErrorPageURL, GURL) // Install the first missing pluign. IPC_MESSAGE_ROUTED0(ViewMsg_InstallMissingPlugin) IPC_MESSAGE_ROUTED1(ViewMsg_RunFileChooserResponse, std::vector /* selected files */) // Used to instruct the RenderView to go into "view source" mode. IPC_MESSAGE_ROUTED0(ViewMsg_EnableViewSourceMode) IPC_MESSAGE_ROUTED2(ViewMsg_UpdateBackForwardListCount, int /* back_list_count */, int /* forward_list_count */) // Retreive information from the MSAA DOM subtree, for accessibility purposes. IPC_SYNC_MESSAGE_ROUTED1_1(ViewMsg_GetAccessibilityInfo, AccessibilityInParams /* input parameters */, AccessibilityOutParams /* output parameters */) // Requests the renderer to clear cashed accessibility information. Takes an // id to clear a specific hashmap entry, and a bool; true clears all, false // does not. IPC_MESSAGE_ROUTED2(ViewMsg_ClearAccessibilityInfo, int /* iaccessible_id */, bool /* clear_all */) // Get all savable resource links from current webpage, include main // frame and sub-frame. IPC_MESSAGE_ROUTED1(ViewMsg_GetAllSavableResourceLinksForCurrentPage, GURL /* url of page which is needed to save */) // Get html data by serializing all frames of current page with lists // which contain all resource links that have local copy. IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, std::vector /* urls that have local copy */, std::vector /* paths of local copy */, FilePath /* local directory path */) // Requests application info for the page. The renderer responds back with // ViewHostMsg_DidGetApplicationInfo. IPC_MESSAGE_ROUTED1(ViewMsg_GetApplicationInfo, int32 /*page_id*/) // Requests the renderer to download the specified image encode it as PNG // and send the PNG data back ala ViewHostMsg_DidDownloadImage. IPC_MESSAGE_ROUTED3(ViewMsg_DownloadImage, int /* identifier for the request */, GURL /* URL of the image */, int /* Size of the image. Normally 0, but set if you have a preferred image size to request, such as when downloading the favicon */) // When a renderer sends a ViewHostMsg_Focus to the browser process, // the browser has the option of sending a ViewMsg_CantFocus back to // the renderer. IPC_MESSAGE_ROUTED0(ViewMsg_CantFocus) // Instructs the renderer to invoke the frame's shouldClose method, which // runs the onbeforeunload event handler. Expects the result to be returned // via ViewHostMsg_ShouldClose. IPC_MESSAGE_ROUTED0(ViewMsg_ShouldClose) // Instructs the renderer to close the current page, including running the // onunload event handler. Expects a ClosePage_ACK message when finished. IPC_MESSAGE_ROUTED2(ViewMsg_ClosePage, int /* new_render_process_host_id */, int /* new_request_id */) // Asks the renderer to send back stats on the WebCore cache broken down by // resource types. IPC_MESSAGE_CONTROL0(ViewMsg_GetCacheResourceStats) // Asks the renderer to send back Histograms. IPC_MESSAGE_CONTROL0(ViewMsg_GetRendererHistograms) // Notifies the renderer about ui theme changes IPC_MESSAGE_ROUTED0(ViewMsg_ThemeChanged) // Notifies the renderer that a paint is to be generated for the rectangle // passed in. IPC_MESSAGE_ROUTED1(ViewMsg_Repaint, gfx::Size /* The view size to be repainted */) #ifdef CHROME_PERSONALIZATION IPC_MESSAGE_ROUTED2(ViewMsg_PersonalizationEvent, std::string /* event name */, std::string /* event arguments */) #endif // Posts a message to the renderer. IPC_MESSAGE_ROUTED3(ViewMsg_HandleMessageFromExternalHost, std::string /* The message */, std::string /* The origin */, std::string /* The target*/) // Sent to the renderer when a popup window should no longer count against // the current popup count (either because it's not a popup or because it was // a generated by a user action or because a constrained popup got turned // into a full window). IPC_MESSAGE_ROUTED0(ViewMsg_DisassociateFromPopupCount) // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the autofill // suggestions. IPC_MESSAGE_ROUTED4(ViewMsg_AutofillSuggestions, int64 /* id of the text input field */, int /* id of the request message */, std::vector /* suggestions */, int /* index of default suggestion */) // Sent by the Browser process to alert a window about whether a blocked // popup notification is visible. The renderer assumes every new window is a // blocked popup until notified otherwise. IPC_MESSAGE_ROUTED1(ViewMsg_PopupNotificationVisiblityChanged, bool /* Whether it is visible */) // Sent by AudioRendererHost to renderer to request an audio packet. IPC_MESSAGE_ROUTED1(ViewMsg_RequestAudioPacket, int /* stream id */) // Tell the renderer process that the audio stream has been created, renderer // process would be given a ShareMemoryHandle that it should write to from // then on. IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamCreated, int /* stream id */, base::SharedMemoryHandle /* handle */, int /* length */) // Notification message sent from AudioRendererHost to renderer for state // update after the renderer has requested a Create/Start/Close. IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamStateChanged, int /* stream id */, AudioOutputStream::State /* new state */, int /* additional information (e.g. platform specific error code*/) IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamVolume, int /* stream id */, double /* left channel */, double /* right channel */) // Notification that a move or resize renderer's containing window has // started. IPC_MESSAGE_ROUTED0(ViewMsg_MoveOrResizeStarted) IPC_END_MESSAGES(View) //----------------------------------------------------------------------------- // WebContents messages // These are messages sent from the renderer to the browser process. IPC_BEGIN_MESSAGES(ViewHost) // 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 // by the browser when a modal dialog is shown. IPC_SYNC_MESSAGE_CONTROL2_2(ViewHostMsg_CreateWindow, int /* opener_id */, bool /* user_gesture */, int /* route_id */, ModalDialogEvent /* modal_dialog_event */) // Similar to ViewHostMsg_CreateView, except used for sub-widgets, like //