Home | History | Annotate | Download | only in renderer_host
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
      7 
      8 #include <map>
      9 #include <set>
     10 #include <string>
     11 #include <vector>
     12 
     13 #include "base/callback.h"
     14 #include "base/gtest_prod_util.h"
     15 #include "base/memory/linked_ptr.h"
     16 #include "base/memory/ref_counted.h"
     17 #include "base/memory/scoped_ptr.h"
     18 #include "base/memory/weak_ptr.h"
     19 #include "content/browser/accessibility/browser_accessibility_manager.h"
     20 #include "content/browser/compositor/delegated_frame_host.h"
     21 #include "content/browser/compositor/image_transport_factory.h"
     22 #include "content/browser/compositor/owned_mailbox.h"
     23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
     24 #include "content/common/content_export.h"
     25 #include "content/common/cursors/webcursor.h"
     26 #include "third_party/skia/include/core/SkRegion.h"
     27 #include "ui/aura/client/cursor_client_observer.h"
     28 #include "ui/aura/client/focus_change_observer.h"
     29 #include "ui/aura/window_delegate.h"
     30 #include "ui/aura/window_tree_host_observer.h"
     31 #include "ui/base/ime/text_input_client.h"
     32 #include "ui/gfx/display_observer.h"
     33 #include "ui/gfx/insets.h"
     34 #include "ui/gfx/rect.h"
     35 #include "ui/wm/public/activation_change_observer.h"
     36 #include "ui/wm/public/activation_delegate.h"
     37 
     38 namespace aura {
     39 class WindowTracker;
     40 namespace client {
     41 class ScopedTooltipDisabler;
     42 }
     43 }
     44 
     45 namespace cc {
     46 class CopyOutputRequest;
     47 class CopyOutputResult;
     48 class DelegatedFrameData;
     49 }
     50 
     51 namespace gfx {
     52 class Canvas;
     53 class Display;
     54 }
     55 
     56 namespace gpu {
     57 struct Mailbox;
     58 }
     59 
     60 namespace ui {
     61 class CompositorLock;
     62 class InputMethod;
     63 class LocatedEvent;
     64 class Texture;
     65 }
     66 
     67 namespace content {
     68 #if defined(OS_WIN)
     69 class LegacyRenderWidgetHostHWND;
     70 #endif
     71 
     72 class OverscrollController;
     73 class RenderFrameHostImpl;
     74 class RenderWidgetHostImpl;
     75 class RenderWidgetHostView;
     76 
     77 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
     78 class CONTENT_EXPORT RenderWidgetHostViewAura
     79     : public RenderWidgetHostViewBase,
     80       public DelegatedFrameHostClient,
     81       public ui::TextInputClient,
     82       public gfx::DisplayObserver,
     83       public aura::WindowTreeHostObserver,
     84       public aura::WindowDelegate,
     85       public aura::client::ActivationDelegate,
     86       public aura::client::ActivationChangeObserver,
     87       public aura::client::FocusChangeObserver,
     88       public aura::client::CursorClientObserver,
     89       public base::SupportsWeakPtr<RenderWidgetHostViewAura> {
     90  public:
     91   // Displays and controls touch editing elements such as selection handles.
     92   class TouchEditingClient {
     93    public:
     94     TouchEditingClient() {}
     95 
     96     // Tells the client to start showing touch editing handles.
     97     virtual void StartTouchEditing() = 0;
     98 
     99     // Notifies the client that touch editing is no longer needed. |quick|
    100     // determines whether the handles should fade out quickly or slowly.
    101     virtual void EndTouchEditing(bool quick) = 0;
    102 
    103     // Notifies the client that the selection bounds need to be updated.
    104     virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor,
    105                                             const gfx::Rect& focus) = 0;
    106 
    107     // Notifies the client that the current text input type as changed.
    108     virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0;
    109 
    110     // Notifies the client that an input event is about to be sent to the
    111     // renderer. Returns true if the client wants to stop event propagation.
    112     virtual bool HandleInputEvent(const ui::Event* event) = 0;
    113 
    114     // Notifies the client that a gesture event ack was received.
    115     virtual void GestureEventAck(int gesture_event_type) = 0;
    116 
    117     // Notifies the client that the fling has ended, so it can activate touch
    118     // editing if needed.
    119     virtual void DidStopFlinging() = 0;
    120 
    121     // This is called when the view is destroyed, so that the client can
    122     // perform any necessary clean-up.
    123     virtual void OnViewDestroyed() = 0;
    124 
    125    protected:
    126     virtual ~TouchEditingClient() {}
    127   };
    128 
    129   void set_touch_editing_client(TouchEditingClient* client) {
    130     touch_editing_client_ = client;
    131   }
    132 
    133   explicit RenderWidgetHostViewAura(RenderWidgetHost* host);
    134 
    135   // RenderWidgetHostView implementation.
    136   virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
    137   virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
    138   virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
    139   virtual void SetSize(const gfx::Size& size) OVERRIDE;
    140   virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
    141   virtual gfx::Vector2dF GetLastScrollOffset() const OVERRIDE;
    142   virtual gfx::NativeView GetNativeView() const OVERRIDE;
    143   virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
    144   virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
    145   virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
    146   virtual bool HasFocus() const OVERRIDE;
    147   virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
    148   virtual void Show() OVERRIDE;
    149   virtual void Hide() OVERRIDE;
    150   virtual bool IsShowing() OVERRIDE;
    151   virtual gfx::Rect GetViewBounds() const OVERRIDE;
    152   virtual void SetBackgroundOpaque(bool opaque) OVERRIDE;
    153   virtual gfx::Size GetVisibleViewportSize() const OVERRIDE;
    154   virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
    155 
    156   // Overridden from RenderWidgetHostViewBase:
    157   virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
    158                            const gfx::Rect& pos) OVERRIDE;
    159   virtual void InitAsFullscreen(
    160       RenderWidgetHostView* reference_host_view) OVERRIDE;
    161   virtual void WasShown() OVERRIDE;
    162   virtual void WasHidden() OVERRIDE;
    163   virtual void MovePluginWindows(
    164       const std::vector<WebPluginGeometry>& moves) OVERRIDE;
    165   virtual void Focus() OVERRIDE;
    166   virtual void Blur() OVERRIDE;
    167   virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE;
    168   virtual void SetIsLoading(bool is_loading) OVERRIDE;
    169   virtual void TextInputTypeChanged(ui::TextInputType type,
    170                                     ui::TextInputMode input_mode,
    171                                     bool can_compose_inline) OVERRIDE;
    172   virtual void ImeCancelComposition() OVERRIDE;
    173   virtual void ImeCompositionRangeChanged(
    174       const gfx::Range& range,
    175       const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
    176   virtual void RenderProcessGone(base::TerminationStatus status,
    177                                  int error_code) OVERRIDE;
    178   virtual void Destroy() OVERRIDE;
    179   virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE;
    180   virtual void SelectionChanged(const base::string16& text,
    181                                 size_t offset,
    182                                 const gfx::Range& range) OVERRIDE;
    183   virtual gfx::Size GetRequestedRendererSize() const OVERRIDE;
    184   virtual void SelectionBoundsChanged(
    185       const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE;
    186   virtual void CopyFromCompositingSurface(
    187       const gfx::Rect& src_subrect,
    188       const gfx::Size& dst_size,
    189       CopyFromCompositingSurfaceCallback& callback,
    190       const SkColorType color_type) OVERRIDE;
    191   virtual void CopyFromCompositingSurfaceToVideoFrame(
    192       const gfx::Rect& src_subrect,
    193       const scoped_refptr<media::VideoFrame>& target,
    194       const base::Callback<void(bool)>& callback) OVERRIDE;
    195   virtual bool CanCopyToVideoFrame() const OVERRIDE;
    196   virtual bool CanSubscribeFrame() const OVERRIDE;
    197   virtual void BeginFrameSubscription(
    198       scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
    199   virtual void EndFrameSubscription() OVERRIDE;
    200   virtual void AcceleratedSurfaceInitialized(int host_id,
    201                                              int route_id) OVERRIDE;
    202   virtual void AcceleratedSurfaceBuffersSwapped(
    203       const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
    204       int gpu_host_id) OVERRIDE;
    205   virtual void AcceleratedSurfacePostSubBuffer(
    206       const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
    207       int gpu_host_id) OVERRIDE;
    208   virtual void AcceleratedSurfaceSuspend() OVERRIDE;
    209   virtual void AcceleratedSurfaceRelease() OVERRIDE;
    210   virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
    211   virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE;
    212   virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
    213   virtual void WheelEventAck(const blink::WebMouseWheelEvent& event,
    214                              InputEventAckState ack_result) OVERRIDE;
    215   virtual void GestureEventAck(const blink::WebGestureEvent& event,
    216                                InputEventAckState ack_result) OVERRIDE;
    217   virtual void ProcessAckedTouchEvent(
    218       const TouchEventWithLatencyInfo& touch,
    219       InputEventAckState ack_result) OVERRIDE;
    220   virtual scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget()
    221       OVERRIDE;
    222   virtual InputEventAckState FilterInputEvent(
    223       const blink::WebInputEvent& input_event) OVERRIDE;
    224   virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
    225   virtual BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
    226       BrowserAccessibilityDelegate* delegate) OVERRIDE;
    227   virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() OVERRIDE;
    228   virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible()
    229       OVERRIDE;
    230   virtual void ShowDisambiguationPopup(const gfx::Rect& rect_pixels,
    231                                        const SkBitmap& zoomed_bitmap) OVERRIDE;
    232   virtual bool LockMouse() OVERRIDE;
    233   virtual void UnlockMouse() OVERRIDE;
    234   virtual void OnSwapCompositorFrame(
    235       uint32 output_surface_id,
    236       scoped_ptr<cc::CompositorFrame> frame) OVERRIDE;
    237   virtual void DidStopFlinging() OVERRIDE;
    238 
    239 #if defined(OS_WIN)
    240   virtual void SetParentNativeViewAccessible(
    241       gfx::NativeViewAccessible accessible_parent) OVERRIDE;
    242   virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE;
    243 #endif
    244 
    245   // Overridden from ui::TextInputClient:
    246   virtual void SetCompositionText(
    247       const ui::CompositionText& composition) OVERRIDE;
    248   virtual void ConfirmCompositionText() OVERRIDE;
    249   virtual void ClearCompositionText() OVERRIDE;
    250   virtual void InsertText(const base::string16& text) OVERRIDE;
    251   virtual void InsertChar(base::char16 ch, int flags) OVERRIDE;
    252   virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE;
    253   virtual ui::TextInputType GetTextInputType() const OVERRIDE;
    254   virtual ui::TextInputMode GetTextInputMode() const OVERRIDE;
    255   virtual bool CanComposeInline() const OVERRIDE;
    256   virtual gfx::Rect GetCaretBounds() const OVERRIDE;
    257   virtual bool GetCompositionCharacterBounds(uint32 index,
    258                                              gfx::Rect* rect) const OVERRIDE;
    259   virtual bool HasCompositionText() const OVERRIDE;
    260   virtual bool GetTextRange(gfx::Range* range) const OVERRIDE;
    261   virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE;
    262   virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE;
    263   virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE;
    264   virtual bool DeleteRange(const gfx::Range& range) OVERRIDE;
    265   virtual bool GetTextFromRange(const gfx::Range& range,
    266                                 base::string16* text) const OVERRIDE;
    267   virtual void OnInputMethodChanged() OVERRIDE;
    268   virtual bool ChangeTextDirectionAndLayoutAlignment(
    269       base::i18n::TextDirection direction) OVERRIDE;
    270   virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE;
    271   virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE;
    272   virtual void OnCandidateWindowShown() OVERRIDE;
    273   virtual void OnCandidateWindowUpdated() OVERRIDE;
    274   virtual void OnCandidateWindowHidden() OVERRIDE;
    275   virtual bool IsEditingCommandEnabled(int command_id) OVERRIDE;
    276   virtual void ExecuteEditingCommand(int command_id) OVERRIDE;
    277 
    278   // Overridden from gfx::DisplayObserver:
    279   virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
    280   virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
    281   virtual void OnDisplayMetricsChanged(const gfx::Display& display,
    282                                        uint32_t metrics) OVERRIDE;
    283 
    284   // Overridden from aura::WindowDelegate:
    285   virtual gfx::Size GetMinimumSize() const OVERRIDE;
    286   virtual gfx::Size GetMaximumSize() const OVERRIDE;
    287   virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
    288                                const gfx::Rect& new_bounds) OVERRIDE;
    289   virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
    290   virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
    291   virtual bool ShouldDescendIntoChildForEventHandling(
    292       aura::Window* child,
    293       const gfx::Point& location) OVERRIDE;
    294   virtual bool CanFocus() OVERRIDE;
    295   virtual void OnCaptureLost() OVERRIDE;
    296   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
    297   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
    298   virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
    299   virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
    300   virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
    301   virtual bool HasHitTestMask() const OVERRIDE;
    302   virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
    303 
    304   // Overridden from ui::EventHandler:
    305   virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
    306   virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
    307   virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
    308   virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
    309   virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
    310 
    311   // Overridden from aura::client::ActivationDelegate:
    312   virtual bool ShouldActivate() const OVERRIDE;
    313 
    314   // Overridden from aura::client::ActivationChangeObserver:
    315   virtual void OnWindowActivated(aura::Window* gained_activation,
    316                                  aura::Window* lost_activation) OVERRIDE;
    317 
    318   // Overridden from aura::client::CursorClientObserver:
    319   virtual void OnCursorVisibilityChanged(bool is_visible) OVERRIDE;
    320 
    321   // Overridden from aura::client::FocusChangeObserver:
    322   virtual void OnWindowFocused(aura::Window* gained_focus,
    323                                aura::Window* lost_focus) OVERRIDE;
    324 
    325   // Overridden from aura::WindowTreeHostObserver:
    326   virtual void OnHostMoved(const aura::WindowTreeHost* host,
    327                            const gfx::Point& new_origin) OVERRIDE;
    328 
    329   void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params);
    330 
    331 #if defined(OS_WIN)
    332   // Sets the cutout rects from constrained windows. These are rectangles that
    333   // windowed NPAPI plugins shouldn't paint in. Overwrites any previous cutout
    334   // rects.
    335   void UpdateConstrainedWindowRects(const std::vector<gfx::Rect>& rects);
    336 
    337   // Updates the cursor clip region. Used for mouse locking.
    338   void UpdateMouseLockRegion();
    339 
    340   // Notification that the LegacyRenderWidgetHostHWND was destroyed.
    341   void OnLegacyWindowDestroyed();
    342 #endif
    343 
    344   void DisambiguationPopupRendered(bool success, const SkBitmap& result);
    345 
    346   void HideDisambiguationPopup();
    347 
    348   void ProcessDisambiguationGesture(ui::GestureEvent* event);
    349 
    350   void ProcessDisambiguationMouse(ui::MouseEvent* event);
    351 
    352   // Method to indicate if this instance is shutting down or closing.
    353   // TODO(shrikant): Discuss around to see if it makes sense to add this method
    354   // as part of RenderWidgetHostView.
    355   bool IsClosing() const { return in_shutdown_; }
    356 
    357   // Sets whether the overscroll controller should be enabled for this page.
    358   void SetOverscrollControllerEnabled(bool enabled);
    359 
    360   void SnapToPhysicalPixelBoundary();
    361 
    362   OverscrollController* overscroll_controller() const {
    363     return overscroll_controller_.get();
    364   }
    365 
    366  protected:
    367   virtual ~RenderWidgetHostViewAura();
    368 
    369   // Exposed for tests.
    370   aura::Window* window() { return window_; }
    371   virtual SkColorType PreferredReadbackFormat() OVERRIDE;
    372   virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE;
    373 
    374  private:
    375   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SetCompositionText);
    376   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventState);
    377   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    378                            TouchEventPositionsArentRounded);
    379   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventSyncAsync);
    380   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SwapNotifiesWindow);
    381   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    382                            SkippedDelegatedFrames);
    383   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange);
    384   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    385                            DiscardDelegatedFrames);
    386   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    387                            DiscardDelegatedFramesWithLocking);
    388   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SoftwareDPIChange);
    389   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    390                            UpdateCursorIfOverSelf);
    391   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest,
    392                            DestroyedAfterCopyRequest);
    393   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    394                            VisibleViewportTest);
    395   FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
    396                            OverscrollResetsOnBlur);
    397   FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest,
    398                            WebContentsViewReparent);
    399 
    400   class WindowObserver;
    401   friend class WindowObserver;
    402 
    403   void UpdateCursorIfOverSelf();
    404 
    405   // Tracks whether SnapToPhysicalPixelBoundary() has been called.
    406   bool has_snapped_to_boundary() { return has_snapped_to_boundary_; }
    407   void ResetHasSnappedToBoundary() { has_snapped_to_boundary_ = false; }
    408 
    409   // Set the bounds of the window and handle size changes.  Assumes the caller
    410   // has already adjusted the origin of |rect| to conform to whatever coordinate
    411   // space is required by the aura::Window.
    412   void InternalSetBounds(const gfx::Rect& rect);
    413 
    414 #if defined(OS_WIN)
    415   bool UsesNativeWindowFrame() const;
    416 #endif
    417 
    418   ui::InputMethod* GetInputMethod() const;
    419 
    420   // Returns whether the widget needs an input grab to work properly.
    421   bool NeedsInputGrab();
    422 
    423   // Confirm existing composition text in the webpage and ask the input method
    424   // to cancel its ongoing composition session.
    425   void FinishImeCompositionSession();
    426 
    427   // This method computes movementX/Y and keeps track of mouse location for
    428   // mouse lock on all mouse move events.
    429   void ModifyEventMovementAndCoords(blink::WebMouseEvent* event);
    430 
    431   // Sends an IPC to the renderer process to communicate whether or not
    432   // the mouse cursor is visible anywhere on the screen.
    433   void NotifyRendererOfCursorVisibilityState(bool is_visible);
    434 
    435   // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty
    436   // SchedulePaint() is invoked for |rect|.
    437   void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip);
    438 
    439   // Helper method to determine if, in mouse locked mode, the cursor should be
    440   // moved to center.
    441   bool ShouldMoveToCenter();
    442 
    443   // Called after |window_| is parented to a WindowEventDispatcher.
    444   void AddedToRootWindow();
    445 
    446   // Called prior to removing |window_| from a WindowEventDispatcher.
    447   void RemovingFromRootWindow();
    448 
    449   // DelegatedFrameHostClient implementation.
    450   virtual ui::Compositor* GetCompositor() const OVERRIDE;
    451   virtual ui::Layer* GetLayer() OVERRIDE;
    452   virtual RenderWidgetHostImpl* GetHost() OVERRIDE;
    453   virtual bool IsVisible() OVERRIDE;
    454   virtual scoped_ptr<ResizeLock> CreateResizeLock(
    455       bool defer_compositor_lock) OVERRIDE;
    456   virtual gfx::Size DesiredFrameSize() OVERRIDE;
    457   virtual float CurrentDeviceScaleFactor() OVERRIDE;
    458   virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE;
    459 
    460   // Detaches |this| from the input method object.
    461   void DetachFromInputMethod();
    462 
    463   // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method
    464   // calls our keybindings handler against the event and send matched
    465   // edit commands to renderer instead.
    466   void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event);
    467 
    468   // Dismisses a Web Popup on a mouse or touch press outside the popup and its
    469   // parent.
    470   void ApplyEventFilterForPopupExit(ui::LocatedEvent* event);
    471 
    472   // Converts |rect| from window coordinate to screen coordinate.
    473   gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const;
    474 
    475   // Converts |rect| from screen coordinate to window coordinate.
    476   gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const;
    477 
    478   // Helper function to set keyboard focus to the main window.
    479   void SetKeyboardFocus();
    480 
    481   RenderFrameHostImpl* GetFocusedFrame();
    482 
    483   // The model object.
    484   RenderWidgetHostImpl* host_;
    485 
    486   aura::Window* window_;
    487 
    488   scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
    489 
    490   scoped_ptr<WindowObserver> window_observer_;
    491 
    492   // Are we in the process of closing?  Tracked so fullscreen views can avoid
    493   // sending a second shutdown request to the host when they lose the focus
    494   // after requesting shutdown for another reason (e.g. Escape key).
    495   bool in_shutdown_;
    496 
    497   // True if in the process of handling a window bounds changed notification.
    498   bool in_bounds_changed_;
    499 
    500   // Is this a fullscreen view?
    501   bool is_fullscreen_;
    502 
    503   // Our parent host view, if this is a popup.  NULL otherwise.
    504   RenderWidgetHostViewAura* popup_parent_host_view_;
    505 
    506   // Our child popup host. NULL if we do not have a child popup.
    507   RenderWidgetHostViewAura* popup_child_host_view_;
    508 
    509   class EventFilterForPopupExit;
    510   friend class EventFilterForPopupExit;
    511   scoped_ptr<ui::EventHandler> event_filter_for_popup_exit_;
    512 
    513   // True when content is being loaded. Used to show an hourglass cursor.
    514   bool is_loading_;
    515 
    516   // The cursor for the page. This is passed up from the renderer.
    517   WebCursor current_cursor_;
    518 
    519   // The touch-event. Its touch-points are updated as necessary. A new
    520   // touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is
    521   // removed from the list on an ET_TOUCH_RELEASED event.
    522   blink::WebTouchEvent touch_event_;
    523 
    524   // The current text input type.
    525   ui::TextInputType text_input_type_;
    526   // The current text input mode corresponding to HTML5 inputmode attribute.
    527   ui::TextInputMode text_input_mode_;
    528   bool can_compose_inline_;
    529 
    530   // Rectangles for the selection anchor and focus.
    531   gfx::Rect selection_anchor_rect_;
    532   gfx::Rect selection_focus_rect_;
    533 
    534   // The current composition character bounds.
    535   std::vector<gfx::Rect> composition_character_bounds_;
    536 
    537   // Indicates if there is onging composition text.
    538   bool has_composition_text_;
    539 
    540   // Whether return characters should be passed on to the RenderWidgetHostImpl.
    541   bool accept_return_character_;
    542 
    543   // Current tooltip text.
    544   base::string16 tooltip_;
    545 
    546   // The size and scale of the last software compositing frame that was swapped.
    547   gfx::Size last_swapped_software_frame_size_;
    548   float last_swapped_software_frame_scale_factor_;
    549 
    550   // If non-NULL we're in OnPaint() and this is the supplied canvas.
    551   gfx::Canvas* paint_canvas_;
    552 
    553   // Used to record the last position of the mouse.
    554   // While the mouse is locked, they store the last known position just as mouse
    555   // lock was entered.
    556   // Relative to the upper-left corner of the view.
    557   gfx::Point unlocked_mouse_position_;
    558   // Relative to the upper-left corner of the screen.
    559   gfx::Point unlocked_global_mouse_position_;
    560   // Last cursor position relative to screen. Used to compute movementX/Y.
    561   gfx::Point global_mouse_position_;
    562   // In mouse locked mode, we synthetically move the mouse cursor to the center
    563   // of the window when it reaches the window borders to avoid it going outside.
    564   // This flag is used to differentiate between these synthetic mouse move
    565   // events vs. normal mouse move events.
    566   bool synthetic_move_sent_;
    567 
    568   // Used to track the state of the window we're created from. Only used when
    569   // created fullscreen.
    570   scoped_ptr<aura::WindowTracker> host_tracker_;
    571 
    572   // Used to track the last cursor visibility update that was sent to the
    573   // renderer via NotifyRendererOfCursorVisibilityState().
    574   enum CursorVisibilityState {
    575     UNKNOWN,
    576     VISIBLE,
    577     NOT_VISIBLE,
    578   };
    579   CursorVisibilityState cursor_visibility_state_in_renderer_;
    580 
    581 #if defined(OS_WIN)
    582   // The list of rectangles from constrained windows over this view. Windowed
    583   // NPAPI plugins shouldn't draw over them.
    584   std::vector<gfx::Rect> constrained_rects_;
    585 
    586   typedef std::map<HWND, WebPluginGeometry> PluginWindowMoves;
    587   // Contains information about each windowed plugin's clip and cutout rects (
    588   // from the renderer). This is needed because when the transient windows
    589   // over this view changes, we need this information in order to create a new
    590   // region for the HWND.
    591   PluginWindowMoves plugin_window_moves_;
    592 
    593   // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used
    594   // for accessibility, as the container for windowless plugins like
    595   // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads,
    596   // etc.
    597   // The LegacyRenderWidgetHostHWND instance is created during the first call
    598   // to RenderWidgetHostViewAura::InternalSetBounds. The instance is destroyed
    599   // when the LegacyRenderWidgetHostHWND hwnd is destroyed.
    600   content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_;
    601 
    602   // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed
    603   // by Windows. This could happen if the browser window was destroyed by
    604   // DestroyWindow for e.g. This flag helps ensure that we don't try to create
    605   // the LegacyRenderWidgetHostHWND instance again as that would be a futile
    606   // exercise.
    607   bool legacy_window_destroyed_;
    608 #endif
    609 
    610   bool has_snapped_to_boundary_;
    611 
    612   TouchEditingClient* touch_editing_client_;
    613 
    614   scoped_ptr<OverscrollController> overscroll_controller_;
    615 
    616   // The last scroll offset of the view.
    617   gfx::Vector2dF last_scroll_offset_;
    618 
    619   gfx::Insets insets_;
    620 
    621   std::vector<ui::LatencyInfo> software_latency_info_;
    622 
    623   scoped_ptr<aura::client::ScopedTooltipDisabler> tooltip_disabler_;
    624 
    625   base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_;
    626 
    627   gfx::Rect disambiguation_target_rect_;
    628 
    629   // The last scroll offset when we start to render the link disambiguation
    630   // view, so we can ensure the window hasn't moved between copying from the
    631   // compositing surface and showing the disambiguation popup.
    632   gfx::Vector2dF disambiguation_scroll_offset_;
    633 
    634   DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura);
    635 };
    636 
    637 }  // namespace content
    638 
    639 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
    640