Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / views / controls / native / native_view_host_aura.h
1 // Copyright (c) 2011 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 UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/aura/window.h"
11 #include "ui/aura/window_observer.h"
12 #include "ui/views/controls/native/native_view_host_wrapper.h"
13 #include "ui/views/views_export.h"
14
15 namespace views {
16
17 class NativeViewHost;
18
19 // Aura implementation of NativeViewHostWrapper.
20 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper,
21                                         public aura::WindowObserver {
22  public:
23   explicit NativeViewHostAura(NativeViewHost* host);
24   ~NativeViewHostAura() override;
25
26   // Overridden from NativeViewHostWrapper:
27   void AttachNativeView() override;
28   void NativeViewDetaching(bool destroyed) override;
29   void AddedToWidget() override;
30   void RemovedFromWidget() override;
31   void InstallClip(int x, int y, int w, int h) override;
32   bool HasInstalledClip() override;
33   void UninstallClip() override;
34   void ShowWidget(int x, int y, int w, int h) override;
35   void HideWidget() override;
36   void SetFocus() override;
37   gfx::NativeViewAccessible GetNativeViewAccessible() override;
38   gfx::NativeCursor GetCursor(int x, int y) override;
39
40  private:
41   friend class NativeViewHostAuraTest;
42
43   class ClippingWindowDelegate;
44
45   // Overridden from aura::WindowObserver:
46   void OnWindowDestroying(aura::Window* window) override;
47   void OnWindowDestroyed(aura::Window* window) override;
48
49   // Reparents the native view with the clipping window existing between it and
50   // its old parent, so that the fast resize path works.
51   void AddClippingWindow();
52
53   // If the native view has been reparented via AddClippingWindow, this call
54   // undoes it.
55   void RemoveClippingWindow();
56
57   // Our associated NativeViewHost.
58   NativeViewHost* host_;
59
60   scoped_ptr<ClippingWindowDelegate> clipping_window_delegate_;
61
62   // Window that exists between the native view and the parent that allows for
63   // clipping to occur. This is positioned in the coordinate space of
64   // host_->GetWidget().
65   aura::Window clipping_window_;
66   scoped_ptr<gfx::Rect> clip_rect_;
67
68   DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura);
69 };
70
71 }  // namespace views
72
73 #endif  // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_