15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/callback.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/native_web_keyboard_event.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_channel.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_sender.h" 137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebInputEvent.h" 147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebTextDirection.h" 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "third_party/skia/include/core/SkBitmap.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/size.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/surface/transport_dib.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 19a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#if defined(OS_MACOSX) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "skia/ext/platform_device.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SkBitmap; 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace gfx { 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Rect; 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace blink { 30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class WebMouseEvent; 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct WebScreenInfo; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderProcessHost; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderWidgetHostImpl; 3858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class RenderWidgetHostIterator; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderWidgetHostView; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A RenderWidgetHost manages the browser side of a browser<->renderer 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// HWND connection. The HWND lives in the browser process, and 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// windows events are sent over IPC to the corresponding object in the 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// renderer. The renderer paints into shared memory, which we 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// transfer to a backing store and blit to the screen when Windows 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sends us a WM_PAINT message. 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// How Shutdown Works 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// There are two situations in which this object, a RenderWidgetHost, can be 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// instantiated: 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1. By a WebContents as the communication conduit for a rendered web page. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The WebContents instantiates a derived class: RenderViewHost. 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2. By a WebContents as the communication conduit for a select widget. The 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WebContents instantiates the RenderWidgetHost directly. 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// For every WebContents there are several objects in play that need to be 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// properly destroyed or cleaned up when certain events occur. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// - WebContents - the WebContents itself, and its associated HWND. 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// - RenderViewHost - representing the communication conduit with the child 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// process. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// - RenderWidgetHostView - the view of the web page content, message handler, 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and plugin root. 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Normally, the WebContents contains a child RenderWidgetHostView that renders 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the contents of the loaded page. It has a WS_CLIPCHILDREN style so that it 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// does no painting of its own. 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The lifetime of the RenderWidgetHostView is tied to the render process. If 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the render process dies, the RenderWidgetHostView goes away and all 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// references to it must become NULL. 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// RenderViewHost (a RenderWidgetHost subclass) is the conduit used to 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// communicate with the RenderView and is owned by the WebContents. If the 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// render process crashes, the RenderViewHost remains and restarts the render 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// process if needed to continue navigation. 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Some examples of how shutdown works: 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// For a WebContents, its Destroy method tells the RenderViewHost to 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// shut down the render process and die. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When the render process is destroyed it destroys the View: the 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// RenderWidgetHostView, which destroys its HWND and deletes that object. 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// For select popups, the situation is a little different. The RenderWidgetHost 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// associated with the select popup owns the view and itself (is responsible 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// for destroying itself when the view is closed). The WebContents's only 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// responsibility is to select popups is to create them when it is told to. When 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the View is destroyed via an IPC message (for when WebCore destroys the 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// popup, e.g. if the user selects one of the options), or because 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WM_CANCELMODE is received by the view, the View schedules the destruction of 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the render process. However in this case since there's no WebContents 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// container, when the render process is destroyed, the RenderWidgetHost just 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// deletes itself, which is safe because no one else should have any references 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to it (the WebContents does not). 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// It should be noted that the RenderViewHost, not the RenderWidgetHost, 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// handles IPC messages relating to the render process going away, since the 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// way a RenderViewHost (WebContents) handles the process dying is different to 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the way a select popup does. As such the RenderWidgetHostView handles these 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// messages for select popups. This placement is more out of convenience than 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// anything else. When the view is live, these messages are forwarded to it by 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the RenderWidgetHost's IPC message map. 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT RenderWidgetHost : public IPC::Sender { 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 109eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Returns the RenderWidgetHost given its ID and the ID of its render process. 110eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Returns NULL if the IDs do not correspond to a live RenderWidgetHost. 111eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch static RenderWidgetHost* FromID(int32 process_id, int32 routing_id); 112eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 11358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns an iterator to iterate over the global list of active render widget 11458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // hosts. 11558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) static scoped_ptr<RenderWidgetHostIterator> GetRenderWidgetHosts(); 116eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~RenderWidgetHost() {} 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Update the text direction of the focused input element and notify it to a 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // renderer process. 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These functions have two usage scenarios: changing the text direction 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // from a menu (as Safari does), and; changing the text direction when a user 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // presses a set of keys (as IE and Firefox do). 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1. Change the text direction from a menu. 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // In this scenario, we receive a menu event only once and we should update 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the text direction immediately when a user chooses a menu item. So, we 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // should call both functions at once as listed in the following snippet. 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // void RenderViewHost::SetTextDirection(WebTextDirection direction) { 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UpdateTextDirection(direction); 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyTextDirection(); 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // } 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 2. Change the text direction when pressing a set of keys. 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Because of auto-repeat, we may receive the same key-press event many 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // times while we presses the keys and it is nonsense to send the same IPC 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // message every time when we receive a key-press event. 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // To suppress the number of IPC messages, we just update the text direction 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // when receiving a key-press event and send an IPC message when we release 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the keys as listed in the following snippet. 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if (key_event.type == WebKeyboardEvent::KEY_DOWN) { 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if (key_event.windows_key_code == 'A' && 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) { 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UpdateTextDirection(dir); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // } else { 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // CancelUpdateTextDirection(); 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // } 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyTextDirection(); 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // } 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Once we cancel updating the text direction, we have to ignore all 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // succeeding UpdateTextDirection() requests until calling 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyTextDirection(). (We may receive keydown events even after we 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // canceled updating the text direction because of auto-repeat.) 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: we cannot undo this change for compatibility with Firefox and IE. 154f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void UpdateTextDirection(blink::WebTextDirection direction) = 0; 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void NotifyTextDirection() = 0; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void Focus() = 0; 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Blur() = 0; 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Sets whether the renderer should show controls in an active state. On all 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // platforms except mac, that's the same as focused. On mac, the frontmost 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // window will show active controls even if the focus is not in the web 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // contents, but e.g. in the omnibox. 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetActive(bool active) = 0; 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Copies the given subset of the backing store, and passes the result as a 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // bitmap to a callback. 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // If |src_rect| is empty, the whole contents is copied. If non empty 1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |accelerated_dst_size| is given and accelerated compositing is active, the 1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // content is shrunk so that it fits in |accelerated_dst_size|. If 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |accelerated_dst_size| is larger than the content size, the content is not 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // resized. If |accelerated_dst_size| is empty, the size copied from the 1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // source contents is used. |callback| is invoked with true on success, false 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // otherwise, along with a SkBitmap containing the copied pixel data. 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: |callback| is called synchronously if the backing store is available. 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // When accelerated compositing is active, |callback| may be called 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // asynchronously. 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void CopyFromBackingStore( 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Rect& src_rect, 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Size& accelerated_dst_size, 183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const base::Callback<void(bool, const SkBitmap&)>& callback, 184116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const SkColorType color_type) = 0; 18523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // Ensures that the view does not drop the backing store even when hidden. 18623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) virtual bool CanCopyFromBackingStore() = 0; 18723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#if defined(OS_ANDROID) 18823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) virtual void LockBackingStore() = 0; 18923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) virtual void UnlockBackingStore() = 0; 19023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#endif 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Forwards the given message to the renderer. These are called by 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the view when it has received a message. 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ForwardMouseEvent( 195f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const blink::WebMouseEvent& mouse_event) = 0; 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ForwardWheelEvent( 197f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const blink::WebMouseWheelEvent& wheel_event) = 0; 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ForwardKeyboardEvent( 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NativeWebKeyboardEvent& key_event) = 0; 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual RenderProcessHost* GetProcess() const = 0; 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetRoutingID() const = 0; 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the View of this RenderWidgetHost. Can be NULL, e.g. if the 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderWidget is being destroyed or the render process crashed. You should 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // never cache this pointer since it can become NULL if the renderer crashes, 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // instead you should always ask for it using the accessor. 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual RenderWidgetHostView* GetView() const = 0; 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the renderer is loading, false if not. 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsLoading() const = 0; 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this is a RenderViewHost, false if not. 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsRenderView() const = 0; 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to notify the RenderWidget that the resize rect has changed without 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the size of the RenderWidget itself changing. 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ResizeRectChanged(const gfx::Rect& new_rect) = 0; 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Restart the active hang monitor timeout. Clears all existing timeouts and 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // starts with a new one. This can be because the renderer has become 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // active, the tab is being hidden, or the user has chosen to wait some more 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to give the tab a chance to become active and we don't want to display a 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // warning too soon. 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void RestartHangMonitorTimeout() = 0; 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to notify the RenderWidget that it has been resized. 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WasResized() = 0; 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Access to the implementation's IPC::Listener::OnMessageReceived. Intended 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // only for test code. 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 236424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // Add/remove a callback that can handle key presses without requiring focus. 237424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) typedef base::Callback<bool(const NativeWebKeyboardEvent&)> 238424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) KeyPressEventCallback; 239424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void AddKeyPressEventCallback( 240424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const KeyPressEventCallback& callback) = 0; 241424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void RemoveKeyPressEventCallback( 242424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const KeyPressEventCallback& callback) = 0; 243424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 244424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // Add/remove a callback that can handle all kinds of mouse events. 245f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) typedef base::Callback<bool(const blink::WebMouseEvent&)> MouseEventCallback; 246424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void AddMouseEventCallback(const MouseEventCallback& callback) = 0; 247424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void RemoveMouseEventCallback(const MouseEventCallback& callback) = 0; 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Get the screen info corresponding to this render widget. 250f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void GetWebScreenInfo(blink::WebScreenInfo* result) = 0; 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 252116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual SkColorType PreferredReadbackFormat() = 0; 253a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class RenderWidgetHostImpl; 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Retrieves the implementation class. Intended only for code 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // within content/. This method is necessary because 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderWidgetHost is the root of a diamond inheritance pattern, so 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // subclasses inherit it virtually, which removes our ability to 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // static_cast to the subclass. 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() = 0; 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ 268