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_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <deque>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <list>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <queue>
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <utility>
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/callback.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/gtest_prod_util.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h"
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/observer_list.h"
21a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "base/process/kill.h"
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
23eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
24eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/timer/timer.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h"
260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "cc/resources/shared_bitmap.h"
275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "content/browser/accessibility/browser_accessibility_manager.h"
28010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/browser/renderer_host/event_with_latency_info.h"
2958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "content/browser/renderer_host/input/input_ack_handler.h"
30ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/browser/renderer_host/input/input_router_client.h"
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/synthetic_gesture.h"
32a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "content/browser/renderer_host/input/touch_emulator_client.h"
33010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/common/input/input_event_ack_state.h"
34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/common/input/synthetic_gesture_packet.h"
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/view_message_enums.h"
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/render_widget_host.h"
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/page_zoom.h"
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_listener.h"
397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "ui/base/ime/text_input_mode.h"
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/ime/text_input_type.h"
4168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "ui/events/latency_info.h"
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct AcceleratedSurfaceMsg_BufferPresented_Params;
45effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochstruct ViewHostMsg_BeginSmoothScroll_Params;
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)struct ViewHostMsg_CompositorSurfaceBuffersSwapped_Params;
47effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochstruct ViewHostMsg_SelectionBounds_Params;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ViewHostMsg_TextInputState_Params;
49effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochstruct ViewHostMsg_UpdateRect_Params;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TimeTicks;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc {
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class CompositorFrame;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class CompositorFrameAck;
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace gfx {
6158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class Range;
6258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
6358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class KeyEvent;
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
68f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace blink {
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebInputEvent;
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebMouseEvent;
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct WebCompositionUnderline;
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct WebScreenInfo;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
76f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace blink {
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebLayer;
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
82ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochclass InputRouter;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class MockRenderWidgetHost;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderWidgetHostDelegate;
85010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)class RenderWidgetHostViewBase;
86424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class SyntheticGestureController;
87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class TimeoutMonitor;
88a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass TouchEmulator;
8923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)class WebCursor;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct EditCommand;
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This implements the RenderWidgetHost interface that is exposed to
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// embedders of content, and adds things only visible to content.
945c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuclass CONTENT_EXPORT RenderWidgetHostImpl
955c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    : virtual public RenderWidgetHost,
965c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      public InputRouterClient,
975c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      public InputAckHandler,
985c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      public TouchEmulatorClient,
995c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      public IPC::Listener,
1005c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      public BrowserAccessibilityDelegate {
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // routing_id can be MSG_ROUTING_NONE, in which case the next available
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // routing id is taken from the RenderProcessHost.
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this object outlives |delegate|, DetachDelegate() must be called when
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |delegate| goes away.
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       RenderProcessHost* process,
1083551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                       int routing_id,
1093551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                       bool hidden);
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~RenderWidgetHostImpl();
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
112eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Similar to RenderWidgetHost::FromID, but returning the Impl object.
113eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  static RenderWidgetHostImpl* FromID(int32 process_id, int32 routing_id);
114eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
1157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Returns all RenderWidgetHosts including swapped out ones for
1167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // internal use. The public interface
1177dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // RendgerWidgetHost::GetRenderWidgetHosts only returns active ones.
11858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  static scoped_ptr<RenderWidgetHostIterator> GetAllRenderWidgetHosts();
1197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Use RenderWidgetHostImpl::From(rwh) to downcast a
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderWidgetHost to a RenderWidgetHostImpl.  Internally, this
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // uses RenderWidgetHost::AsRenderWidgetHostImpl().
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static RenderWidgetHostImpl* From(RenderWidgetHost* rwh);
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void set_hung_renderer_delay_ms(const base::TimeDelta& timeout) {
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    hung_renderer_delay_ms_ = timeout.InMilliseconds();
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderWidgetHost implementation.
130f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void UpdateTextDirection(blink::WebTextDirection direction) OVERRIDE;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyTextDirection() OVERRIDE;
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void Focus() OVERRIDE;
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Blur() OVERRIDE;
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetActive(bool active) OVERRIDE;
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void CopyFromBackingStore(
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Rect& src_rect,
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Size& accelerated_dst_size,
138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const base::Callback<void(bool, const SkBitmap&)>& callback,
139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const SkBitmap::Config& bitmap_config) OVERRIDE;
14023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  virtual bool CanCopyFromBackingStore() OVERRIDE;
14123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#if defined(OS_ANDROID)
14223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  virtual void LockBackingStore() OVERRIDE;
14323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  virtual void UnlockBackingStore() OVERRIDE;
14423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#endif
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EnableFullAccessibilityMode() OVERRIDE;
146effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual bool IsFullAccessibilityModeForTesting() OVERRIDE;
147effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE;
148effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual bool IsTreeOnlyAccessibilityModeForTesting() OVERRIDE;
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ForwardMouseEvent(
150f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebMouseEvent& mouse_event) OVERRIDE;
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ForwardWheelEvent(
152f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebMouseWheelEvent& wheel_event) OVERRIDE;
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ForwardKeyboardEvent(
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const NativeWebKeyboardEvent& key_event) OVERRIDE;
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE;
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual RenderProcessHost* GetProcess() const OVERRIDE;
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetRoutingID() const OVERRIDE;
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual RenderWidgetHostView* GetView() const OVERRIDE;
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsLoading() const OVERRIDE;
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsRenderView() const OVERRIDE;
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE;
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RestartHangMonitorTimeout() OVERRIDE;
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Stop() OVERRIDE;
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WasResized() OVERRIDE;
166424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void AddKeyPressEventCallback(
167424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      const KeyPressEventCallback& callback) OVERRIDE;
168424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void RemoveKeyPressEventCallback(
169424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      const KeyPressEventCallback& callback) OVERRIDE;
170424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void AddMouseEventCallback(
171424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      const MouseEventCallback& callback) OVERRIDE;
172424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void RemoveMouseEventCallback(
173424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      const MouseEventCallback& callback) OVERRIDE;
174f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE;
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE;
177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1785c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // BrowserAccessibilityDelegate
1795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE;
1805c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE;
1815c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE;
182c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void AccessibilityScrollToMakeVisible(
183c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      int acc_obj_id, gfx::Rect subfocus) OVERRIDE;
184c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void AccessibilityScrollToPoint(
185c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      int acc_obj_id, gfx::Point point) OVERRIDE;
186c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void AccessibilitySetTextSelection(
187c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      int acc_obj_id, int start_offset, int end_offset) OVERRIDE;
1885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual bool AccessibilityViewHasFocus() const OVERRIDE;
1895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE;
1905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds)
1915c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      const OVERRIDE;
192cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE;
1935c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual void AccessibilityFatalError() OVERRIDE;
194c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
195c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const NativeWebKeyboardEvent* GetLastKeyboardEvent() const;
196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the screen info has changed.
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void NotifyScreenInfoChanged();
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
200a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  // Invalidates the cached screen info so that next resize request
201a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  // will carry the up to date screen info. Unlike
202a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  // |NotifyScreenInfoChanged|, this doesn't send a message to the renderer.
203a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  void InvalidateScreenInfo();
204a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the View of this RenderWidgetHost.
206010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void SetView(RenderWidgetHostViewBase* view);
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int surface_id() const { return surface_id_; }
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool empty() const { return current_size_.IsEmpty(); }
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a renderer object already been created for this host, and we
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // just need to be attached to it. Used for window.open, <select> dropdown
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // menus, and other times when the renderer initiates creating an object.
215424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void Init();
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the renderer to die and then calls Destroy().
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Shutdown();
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IPC::Listener
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sends a message to the corresponding object in the renderer.
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Send(IPC::Message* msg) OVERRIDE;
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to notify the RenderWidget that it has been hidden or restored from
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // having been hidden.
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WasHidden();
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WasShown();
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the RenderWidget is hidden.
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_hidden() const { return is_hidden_; }
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Called to notify the RenderWidget that its associated native window
2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // got/lost focused.
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void GotFocus();
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostCapture();
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to notify the RenderWidget that it has lost the mouse lock.
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostMouseLock();
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
242c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Noifies the RenderWidget of the current mouse cursor visibility state.
243c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SendCursorVisibilityState(bool is_visible);
244c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the RenderWidgetHost that the View was destroyed.
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ViewDestroyed();
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates if the page has finished loading.
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetIsLoading(bool is_loading);
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
25123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Pause for a moment to wait for pending repaint or resize messages sent to
25223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // the renderer to arrive. If pending resize messages are for an old window
25323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // size, then also pump through a new resize message if there is time.
25423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  void PauseForPendingResizeOrRepaints();
25523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
256c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  // Whether pausing may be useful.
257c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  bool CanPauseForPendingResizeOrRepaints();
258c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
2590529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Wait for a surface matching the size of the widget's view, possibly
2600529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // blocking until the renderer sends a new frame.
2610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void WaitForSurface();
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GPU accelerated version of GetBackingStore function. This will
2643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // trigger a re-composite to the view. It may fail if a resize is pending, or
2653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // if a composite has already been requested and not acked yet.
2663551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  bool ScheduleComposite();
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Starts a hang monitor timeout. If there's already a hang monitor timeout
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the new one will only fire if it has a shorter delay than the time
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // left on the existing timeouts.
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StartHangMonitorTimeout(base::TimeDelta delay);
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Stops all existing hang monitor timeouts and assumes the renderer is
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // responsive.
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StopHangMonitorTimeout();
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Forwards the given message to the renderer. These are called by the view
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when it has received a message.
279eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void ForwardGestureEventWithLatencyInfo(
280f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebGestureEvent& gesture_event,
281eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      const ui::LatencyInfo& ui_latency);
282ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  void ForwardTouchEventWithLatencyInfo(
283f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebTouchEvent& touch_event,
2847d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      const ui::LatencyInfo& ui_latency);
285ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  void ForwardMouseEventWithLatencyInfo(
2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const blink::WebMouseEvent& mouse_event,
2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const ui::LatencyInfo& ui_latency);
288ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  void ForwardWheelEventWithLatencyInfo(
2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const blink::WebMouseWheelEvent& wheel_event,
2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const ui::LatencyInfo& ui_latency);
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
292a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // TouchEmulatorClient overrides.
293a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  virtual void ForwardGestureEvent(
294a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch      const blink::WebGestureEvent& gesture_event) OVERRIDE;
295a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  virtual void ForwardTouchEvent(
296a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch      const blink::WebTouchEvent& touch_event) OVERRIDE;
297a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  virtual void SetCursor(const WebCursor& cursor) OVERRIDE;
298d7582f30d3b217d8144db8429955efdca442508fBo Liu  virtual void ShowContextMenuAtPoint(const gfx::Point& point) OVERRIDE;
299a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
300a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Queues a synthetic gesture for testing purposes.  Invokes the on_complete
301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // callback when the gesture is finished running.
302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void QueueSyntheticGesture(
303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      scoped_ptr<SyntheticGesture> synthetic_gesture,
304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const base::Callback<void(SyntheticGesture::Result)>& on_complete);
305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CancelUpdateTextDirection();
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a mouse click/gesture tap activates the renderer.
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPointerEventActivate();
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the renderer whether or not the input method attached to this
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process is activated.
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When the input method is activated, a renderer process sends IPC messages
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to notify the status of its composition node. (This message is mainly used
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for notifying the position of the input cursor so that the browser can
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // display input method windows under the cursor.)
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetInputMethodActive(bool activate);
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
319a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Notifies the renderer changes of IME candidate window state.
320a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void CandidateWindowShown();
321a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void CandidateWindowUpdated();
322a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void CandidateWindowHidden();
323a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update the composition node of the renderer (or WebKit).
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WebKit has a special node (a composition node) for input method to change
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // its text without affecting any other DOM nodes. When the input method
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (attached to the browser) updates its text, the browser sends IPC messages
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to update the composition node of the renderer.
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (Read the comments of each function for its detail.)
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the text of the composition node.
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This function can also update the cursor position and mark the specified
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // range in the composition node.
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A browser should call this function:
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when it receives a WM_IME_COMPOSITION message with a GCS_COMPSTR flag
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   (on Windows);
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when it receives a "preedit_changed" signal of GtkIMContext (on Linux);
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when markedText of NSTextInput is called (on Mac).
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ImeSetComposition(
340a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& text,
341f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const std::vector<blink::WebCompositionUnderline>& underlines,
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int selection_start,
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int selection_end);
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finishes an ongoing composition with the specified text.
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A browser should call this function:
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when it receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR flag
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   (on Windows);
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when it receives a "commit" signal of GtkIMContext (on Linux);
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // * when insertText of NSTextInput is called (on Mac).
351a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void ImeConfirmComposition(const base::string16& text,
35258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                             const gfx::Range& replacement_range,
3537dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch                             bool keep_selection);
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Cancels an ongoing composition.
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ImeCancelComposition();
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is for derived classes to give us access to the resizer rect.
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // And to also expose it to the RenderWidgetHostView.
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetRootWindowResizerRect() const;
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ignore_input_events() const {
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return ignore_input_events_;
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3667d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool input_method_active() const {
3677d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return input_method_active_;
3687d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  }
3697d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
370ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Whether forwarded WebInputEvents should be ignored.  True if either
371ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // |ignore_input_events_| or |process_->IgnoreInputEvents()| is true.
372ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  bool IgnoreInputEvents() const;
373ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
374ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Event queries delegated to the |input_router_|.
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ShouldForwardTouchEvent() const;
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_touch_handler() const { return has_touch_handler_; }
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the user has made some kind of input that could
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // perform an action. See OnUserGesture for more details.
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StartUserGesture();
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
383cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Set the RenderView background transparency.
384cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void SetBackgroundOpaque(bool opaque);
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the renderer that the next key event is bound to one or more
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // pre-defined edit commands
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetEditCommandsForNextKeyEvent(
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<EditCommand>& commands);
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Gets the accessibility mode.
3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AccessibilityMode accessibility_mode() const {
3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return accessibility_mode_;
3942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Adds the given accessibility mode to the current accessibility mode bitmap.
3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void AddAccessibilityMode(AccessibilityMode mode);
3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Removes the given accessibility mode from the current accessibility mode
4005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // bitmap, managing the bits that are shared with other modes such that a
4015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // bit will only be turned off when all modes that depend on it have been
4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // removed.
4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void RemoveAccessibilityMode(AccessibilityMode mode);
4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Resets the accessibility mode to the default setting in
4065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // BrowserStateAccessibilityImpl.
4075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void ResetAccessibilityMode();
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(OS_WIN)
41090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void SetParentNativeViewAccessible(
41190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      gfx::NativeViewAccessible accessible_parent);
412c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  gfx::NativeViewAccessible GetParentNativeViewAccessible() const;
413c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
414c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Executes the edit command on the RenderView.
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ExecuteEditCommand(const std::string& command,
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const std::string& value);
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the renderer to scroll the currently focused node into rect only if
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the currently focused node is a Text node (textfield, text area or content
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // editable divs).
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Requests the renderer to move the caret selection towards the point.
4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void MoveCaret(const gfx::Point& point);
4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the reponse to a pending mouse lock request has arrived.
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |allowed| is true and the mouse has been successfully
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // locked.
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GotResponseToLockMouseRequest(bool allowed);
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the RenderWidget about the latest vsync parameters.
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: Make sure the timebase was obtained using
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // base::TimeTicks::HighResNow. Using the non-high res timer will result in
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // incorrect synchronization across processes.
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateVSyncParameters(base::TimeTicks timebase,
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                     base::TimeDelta interval);
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called by the view in response to AcceleratedSurfaceBuffersSwapped or
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // AcceleratedSurfacePostSubBuffer.
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void AcknowledgeBufferPresent(
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int32 route_id,
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int gpu_host_id,
4442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const AcceleratedSurfaceMsg_BufferPresented_Params& params);
4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Called by the view in response to OnSwapCompositorFrame.
4472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static void SendSwapCompositorFrameAck(
448ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      int32 route_id,
449ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      uint32 output_surface_id,
450ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      int renderer_host_id,
451ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      const cc::CompositorFrameAck& ack);
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
453d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Called by the view to return resources to the compositor.
454d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  static void SendReclaimCompositorResources(int32 route_id,
455d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                                             uint32 output_surface_id,
456d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                                             int renderer_host_id,
457d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                                             const cc::CompositorFrameAck& ack);
458d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_allow_privileged_mouse_lock(bool allow) {
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    allow_privileged_mouse_lock_ = allow;
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Resets state variables related to tracking pending size and painting.
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We need to reset these flags when we want to repaint the contents of
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // browser plugin in this RWH. Resetting these flags will ensure we ignore
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // any previous pending acks that are not relevant upon repaint.
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ResetSizeAndRepaintPendingFlags();
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DetachDelegate();
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update the renderer's cache of the screen rect of the view and window.
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SendScreenRects();
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Suppreses future char events until a keydown. See
4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // suppress_next_char_events_.
4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SuppressNextCharEvents();
4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
47968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Called by RenderWidgetHostView in response to OnSetNeedsFlushInput.
48068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  void FlushInput();
48168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
482f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // InputRouterClient
483f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void SetNeedsFlush() OVERRIDE;
484f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
485b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // Indicates whether the renderer drives the RenderWidgetHosts's size or the
486b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // other way around.
487b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  bool should_auto_resize() { return should_auto_resize_; }
488b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
489eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void ComputeTouchLatency(const ui::LatencyInfo& latency_info);
49090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void FrameSwapped(const ui::LatencyInfo& latency_info);
4917dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void DidReceiveRendererFrame();
492b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
493b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // Returns the ID that uniquely describes this component to the latency
494b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // subsystem.
495b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  int64 GetLatencyComponentId();
496b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
4975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static void CompositorFrameDrawn(
4985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::vector<ui::LatencyInfo>& latency_info);
499868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
500868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Don't check whether we expected a resize ack during layout tests.
501868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static void DisableResizeAckCheckForTesting();
502868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void WindowSnapshotAsyncCallback(
5045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      int routing_id,
5055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      int snapshot_id,
5065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      gfx::Size snapshot_size,
5075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      scoped_refptr<base::RefCountedBytes> png_data);
5085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // LatencyComponents generated in the renderer must have component IDs
5105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // provided to them by the browser process. This function adds the correct
5115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // component ID where necessary.
5125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info);
5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
514effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  InputRouter* input_router() { return input_router_.get(); }
515effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE;
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT
5207dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // component if it is not already in |original|. And if |original| is
5217dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // not NULL, it is also merged into the resulting LatencyInfo.
5227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  ui::LatencyInfo CreateRWHLatencyInfoIfNotExist(
5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const ui::LatencyInfo* original, blink::WebInputEvent::Type type);
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when we receive a notification indicating that the renderer
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process has gone. This will reset our state so that our state will be
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // consistent if a new renderer is created.
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RendererExited(base::TerminationStatus status, int exit_code);
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Retrieves an id the renderer can use to refer to its view.
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is used for various IPC messages, including plugins.
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::NativeViewId GetNativeViewId() const;
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Retrieves an id for the surface that the renderer can draw to
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when accelerated compositing is enabled.
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::GLSurfaceHandle GetCompositingSurface();
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ---------------------------------------------------------------------------
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The following methods are overridden by RenderViewHost to send upwards to
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // its delegate.
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a mousewheel event was not processed by the renderer.
543f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void UnhandledWheelEvent(const blink::WebMouseWheelEvent& event) {}
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the user has made some kind of input that could
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // perform an action. The gestures that count are 1) any mouse down
5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // event and 2) enter or space key presses.
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnUserGesture() {}
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Callbacks for notification when the renderer becomes unresponsive to user
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // input events, and subsequently responsive again.
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyRendererUnresponsive() {}
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyRendererResponsive() {}
5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when auto-resize resulted in the renderer size changing.
5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnRenderAutoResized(const gfx::Size& new_size) {}
5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ---------------------------------------------------------------------------
5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderViewHost overrides this method to impose further restrictions on when
5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to allow mouse lock.
5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Once the request is approved or rejected, GotResponseToLockMouseRequest()
5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // will be called.
5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestToLockMouse(bool user_gesture,
5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  bool last_unlocked_by_target);
5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RejectMouseLockOrUnlockIfNecessary();
5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool IsMouseLocked() const;
5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderViewHost overrides this method to report when in fullscreen mode.
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsFullscreen() const;
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates if the render widget host should track the render widget's size
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as opposed to visa versa.
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetShouldAutoResize(bool enable);
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Expose increment/decrement of the in-flight event count, so
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderViewHostImpl can account for in-flight beforeunload/unload events.
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int increment_in_flight_event_count() { return ++in_flight_event_count_; }
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int decrement_in_flight_event_count() { return --in_flight_event_count_; }
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The View associated with the RenderViewHost. The lifetime of this object
5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is associated with the lifetime of the Render process. If the Renderer
5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // crashes, its View is destroyed and this pointer becomes NULL, even though
5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // render_view_host_ lives on to load another URL (creating a new View while
5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // doing so).
587010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  RenderWidgetHostViewBase* view_;
5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // true if a renderer has once been valid. We use this flag to display a sad
5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab only when we lose our renderer and not if a paint occurs during
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // initialization.
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool renderer_initialized_;
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This value indicates how long to wait before we consider a renderer hung.
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int hung_renderer_delay_ms_;
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class MockRenderWidgetHost;
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tell this object to destroy itself.
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Destroy();
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
603a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called by |hang_timeout_monitor_| on delayed response from the renderer.
604a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void RendererIsUnresponsive();
6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called if we know the renderer is responsive. When we currently think the
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // renderer is unresponsive, this will clear that state and call
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NotifyRendererResponsive.
6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RendererIsResponsive();
6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IPC message handlers
6122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRenderViewReady();
6137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void OnRenderProcessGone(int status, int error_code);
6142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnClose();
6152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnUpdateScreenRectsAck();
6162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRequestMove(const gfx::Rect& pos);
617a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void OnSetTooltipText(const base::string16& tooltip_text,
618f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                        blink::WebTextDirection text_direction_hint);
6197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#if defined(OS_MACOSX)
62090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void OnCompositorSurfaceBuffersSwapped(
62190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params);
6227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
6232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool OnSwapCompositorFrame(const IPC::Message& message);
6245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void OnFlingingStopped();
6252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params);
626f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet);
6272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnFocus();
6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnBlur();
6292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnSetCursor(const WebCursor& cursor);
630a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  void OnSetTouchEventEmulationEnabled(bool enabled, bool allow_pinch);
631f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  void OnTextInputStateChanged(
632f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      const ViewHostMsg_TextInputState_Params& params);
633f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
634a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#if defined(OS_MACOSX) || defined(USE_AURA)
6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnImeCompositionRangeChanged(
63658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)      const gfx::Range& range,
6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<gfx::Rect>& character_bounds);
6387dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
6392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnImeCancelComposition();
6402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnLockMouse(bool user_gesture,
6412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                   bool last_unlocked_by_target,
6422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                   bool privileged);
6432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnUnlockMouse();
6442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnShowDisambiguationPopup(const gfx::Rect& rect,
6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                 const gfx::Size& size,
6460529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                 const cc::SharedBitmapId& id);
6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnWindowlessPluginDummyWindowCreated(
6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      gfx::NativeViewId dummy_activation_window);
6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnWindowlessPluginDummyWindowDestroyed(
6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      gfx::NativeViewId dummy_activation_window);
6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
653effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  void OnSelectionChanged(const base::string16& text,
654effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                          size_t offset,
655effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                          const gfx::Range& range);
656effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  void OnSelectionBoundsChanged(
657effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      const ViewHostMsg_SelectionBounds_Params& params);
6582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnSnapshot(bool success, const SkBitmap& bitmap);
6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called (either immediately or asynchronously) after we're done with our
6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // BackingStore and can send an ACK to the renderer so it can paint onto it
6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // again.
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DidUpdateBackingStore(const ViewHostMsg_UpdateRect_Params& params,
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             const base::TimeTicks& paint_start);
6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Give key press listeners a chance to handle this key press. This allow
6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // widgets that don't have focus to still handle key presses.
6682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool KeyPressListenersHandleEvent(const NativeWebKeyboardEvent& event);
6692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
670ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // InputRouterClient
671ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual InputEventAckState FilterInputEvent(
672f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebInputEvent& event,
673ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      const ui::LatencyInfo& latency_info) OVERRIDE;
674ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual void IncrementInFlightEventCount() OVERRIDE;
675ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual void DecrementInFlightEventCount() OVERRIDE;
676ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual void OnHasTouchEventHandlers(bool has_handlers) OVERRIDE;
67758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual void DidFlush() OVERRIDE;
678cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void DidOverscroll(const DidOverscrollParams& params) OVERRIDE;
67958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
68058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // InputAckHandler
681ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event,
682ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                                  InputEventAckState ack_result) OVERRIDE;
6834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnWheelEventAck(const MouseWheelEventWithLatencyInfo& event,
684ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                               InputEventAckState ack_result) OVERRIDE;
685ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
686ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                               InputEventAckState ack_result) OVERRIDE;
6874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnGestureEventAck(const GestureEventWithLatencyInfo& event,
688ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                                 InputEventAckState ack_result) OVERRIDE;
68958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE;
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
691a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void OnSyntheticGestureCompleted(SyntheticGesture::Result result);
692a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when there is a new auto resize (using a post to avoid a stack
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // which may get in recursive loops).
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DelayedAutoResized();
6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void WindowSnapshotReachedScreen(int snapshot_id);
69868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
6995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Send a message to the renderer process to change the accessibility mode.
7005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetAccessibilityMode(AccessibilityMode AccessibilityMode);
7015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Our delegate, which wants to know mainly about keyboard events.
7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It will remain non-NULL until DetachDelegate() is called.
7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RenderWidgetHostDelegate* delegate_;
7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Created during construction but initialized during Init*(). Therefore, it
7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is guaranteed never to be NULL, but its channel may be NULL if the
7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // renderer crashed, so you must always check that.
7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RenderProcessHost* process_;
7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The ID of the corresponding object in the Renderer Instance.
7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int routing_id_;
7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The ID of the surface corresponding to this render widget.
7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int surface_id_;
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates whether a page is loading or not.
7185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_loading_;
7195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
720929504d64b38e05de7355e162311d6791ad6f54dBo Liu  // Indicates whether a page is hidden or not. It has to stay in sync with the
721929504d64b38e05de7355e162311d6791ad6f54dBo Liu  // most recent call to process_->WidgetRestored() / WidgetHidden().
7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_hidden_;
7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates whether a page is fullscreen or not.
7255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_fullscreen_;
7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set if we are waiting for a repaint ack for the view.
7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool repaint_ack_pending_;
7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True when waiting for RESIZE_ACK.
7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool resize_ack_pending_;
7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
73390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Cached copy of the screen info so that it doesn't need to be updated every
73490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // time the window is resized.
735f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  scoped_ptr<blink::WebScreenInfo> screen_info_;
73690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
73790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Set if screen_info_ may have changed and should be recomputed and force a
73890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // resize message.
73990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  bool screen_info_out_of_date_;
74090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The current size of the RenderWidget.
7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Size current_size_;
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The size of the view's backing surface in non-DPI-adjusted pixels.
7452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size physical_backing_size_;
7462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The height of the physical backing surface that is overdrawn opaquely in
7482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels).
7492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float overdraw_bottom_height_;
7502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7515c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // The size of the visible viewport, which may be smaller than the view if the
7525c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // view is partially occluded (e.g. by a virtual keyboard).  The size is in
7535c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // DPI-adjusted pixels.
7545c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  gfx::Size visible_viewport_size_;
7555c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The size we last sent as requested size to the renderer. |current_size_|
7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is only updated once the resize message has been ack'd. This on the other
7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // hand is updated when the resize message is sent. This is very similar to
7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |resize_ack_pending_|, but the latter is not set if the new size has width
7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // or height zero, which is why we need this too.
7617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  gfx::Size last_requested_size_;
7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The next auto resize to send.
7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Size new_auto_size_;
7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the render widget host should track the render widget's size as
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // opposed to visa versa.
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool should_auto_resize_;
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool waiting_for_screen_rects_ack_;
7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect last_view_screen_rect_;
7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect last_window_screen_rect_;
7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AccessibilityMode accessibility_mode_;
7752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Keyboard event listeners.
777424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  std::vector<KeyPressEventCallback> key_press_event_callbacks_;
778424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
779424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Mouse event callbacks.
780424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  std::vector<MouseEventCallback> mouse_event_callbacks_;
7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If true, then we should repaint when restoring even if we have a
7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // backingstore.  This flag is set to true if we receive a paint message
7845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // while is_hidden_ to true.  Even though we tell the render widget to hide
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // itself, a paint message could already be in flight at that point.
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool needs_repainting_on_restore_;
7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is true if the renderer is currently unresponsive.
7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_unresponsive_;
7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The following value indicates a time in the future when we would consider
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the renderer hung if it does not generate an appropriate response message.
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::Time time_when_considered_hung_;
7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This value denotes the number of input events yet to be acknowledged
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by the renderer.
7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int in_flight_event_count_;
7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This timer runs to check if time_when_considered_hung_ has past.
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::OneShotTimer<RenderWidgetHostImpl> hung_renderer_timer_;
8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Flag to detect recursive calls to GetBackingStore().
8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool in_get_backing_store_;
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used for UMA histogram logging to measure the time for a repaint view
8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // operation to finish.
8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::TimeTicks repaint_start_time_;
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set to true if we shouldn't send input events from the render widget.
8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ignore_input_events_;
8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Indicates whether IME is active.
8137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool input_method_active_;
8147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set when we update the text direction of the selected input element.
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool text_direction_updated_;
817f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebTextDirection text_direction_;
8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set when we cancel updating the text direction.
8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This flag also ignores succeeding update requests until we call
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NotifyTextDirection().
8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool text_direction_canceled_;
8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates if the next sequence of Char events should be suppressed or not.
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // System may translate a RawKeyDown event into zero or more Char events,
8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // usually we send them to the renderer directly in sequence. However, If a
8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RawKeyDown event was not handled by the renderer but was handled by
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // our UnhandledKeyboardEvent() method, e.g. as an accelerator key, then we
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // shall not send the following sequence of Char events, which was generated
8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by this RawKeyDown event, to the renderer. Otherwise the renderer may
8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handle the Char events and cause unexpected behavior.
8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For example, pressing alt-2 may let the browser switch to the second tab,
8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // but the Char event generated by alt-2 may also activate a HTML element
8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if its accesskey happens to be "2", then the user may get confused when
8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // switching back to the original tab, because the content may already be
8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // changed.
8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool suppress_next_char_events_;
8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The last scroll offset of the render widget.
8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Vector2d last_scroll_offset_;
8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool pending_mouse_lock_request_;
8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool allow_privileged_mouse_lock_;
8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Keeps track of whether the webpage has any touch event handler. If it does,
8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // then touch events are sent to the renderer. Otherwise, the touch events are
8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not sent to the renderer.
8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_touch_handler_;
8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_;
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
852f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_;
853ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
854a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  scoped_ptr<TouchEmulator> touch_emulator_;
855a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
856ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Receives and handles all input events.
857ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  scoped_ptr<InputRouter> input_router_;
858ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
859a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  scoped_ptr<TimeoutMonitor> hang_monitor_timeout_;
860a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::list<HWND> dummy_windows_for_activation_;
8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  int64 last_input_number_;
866b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl);
8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
873