Home | History | Annotate | Download | only in desktop_aura
      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 UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_H_
      6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "ui/aura/window_event_dispatcher.h"
     10 #include "ui/base/ui_base_types.h"
     11 #include "ui/views/views_export.h"
     12 #include "ui/views/widget/widget.h"
     13 
     14 namespace aura {
     15 class WindowTreeHost;
     16 class Window;
     17 
     18 namespace client {
     19 class DragDropClient;
     20 }
     21 }
     22 
     23 namespace gfx {
     24 class ImageSkia;
     25 class Rect;
     26 }
     27 
     28 namespace ui {
     29 class NativeTheme;
     30 }
     31 
     32 namespace views {
     33 namespace corewm {
     34 class Tooltip;
     35 }
     36 
     37 namespace internal {
     38 class NativeWidgetDelegate;
     39 }
     40 
     41 class DesktopNativeCursorManager;
     42 class DesktopNativeWidgetAura;
     43 
     44 class VIEWS_EXPORT DesktopWindowTreeHost {
     45  public:
     46   virtual ~DesktopWindowTreeHost() {}
     47 
     48   static DesktopWindowTreeHost* Create(
     49       internal::NativeWidgetDelegate* native_widget_delegate,
     50       DesktopNativeWidgetAura* desktop_native_widget_aura);
     51 
     52   // Return the NativeTheme to use for |window|. WARNING: |window| may be NULL.
     53   static ui::NativeTheme* GetNativeTheme(aura::Window* window);
     54 
     55   // Sets up resources needed before the WindowEventDispatcher has been created.
     56   virtual void Init(aura::Window* content_window,
     57                     const Widget::InitParams& params) = 0;
     58 
     59   // Invoked once the DesktopNativeWidgetAura has been created.
     60   virtual void OnNativeWidgetCreated(const Widget::InitParams& params) = 0;
     61 
     62   // Creates and returns the Tooltip implementation to use. Return value is
     63   // owned by DesktopNativeWidgetAura and lives as long as
     64   // DesktopWindowTreeHost.
     65   virtual scoped_ptr<corewm::Tooltip> CreateTooltip() = 0;
     66 
     67   // Creates and returns the DragDropClient implementation to use. Return value
     68   // is owned by DesktopNativeWidgetAura and lives as long as
     69   // DesktopWindowTreeHost.
     70   virtual scoped_ptr<aura::client::DragDropClient> CreateDragDropClient(
     71       DesktopNativeCursorManager* cursor_manager) = 0;
     72 
     73   virtual void Close() = 0;
     74   virtual void CloseNow() = 0;
     75 
     76   virtual aura::WindowTreeHost* AsWindowTreeHost() = 0;
     77 
     78   virtual void ShowWindowWithState(ui::WindowShowState show_state) = 0;
     79   virtual void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) = 0;
     80 
     81   virtual bool IsVisible() const = 0;
     82 
     83   virtual void SetSize(const gfx::Size& size) = 0;
     84   virtual void StackAtTop() = 0;
     85   virtual void CenterWindow(const gfx::Size& size) = 0;
     86   virtual void GetWindowPlacement(gfx::Rect* bounds,
     87                                   ui::WindowShowState* show_state) const = 0;
     88   virtual gfx::Rect GetWindowBoundsInScreen() const = 0;
     89   virtual gfx::Rect GetClientAreaBoundsInScreen() const = 0;
     90   virtual gfx::Rect GetRestoredBounds() const = 0;
     91 
     92   virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0;
     93 
     94   // Sets the shape of the root window. If |native_region| is NULL then the
     95   // window reverts to rectangular. Takes ownership of |native_region|.
     96   virtual void SetShape(gfx::NativeRegion native_region) = 0;
     97 
     98   virtual void Activate() = 0;
     99   virtual void Deactivate() = 0;
    100   virtual bool IsActive() const = 0;
    101   virtual void Maximize() = 0;
    102   virtual void Minimize() = 0;
    103   virtual void Restore() = 0;
    104   virtual bool IsMaximized() const = 0;
    105   virtual bool IsMinimized() const = 0;
    106 
    107   virtual bool HasCapture() const = 0;
    108 
    109   virtual void SetAlwaysOnTop(bool always_on_top) = 0;
    110   virtual bool IsAlwaysOnTop() const = 0;
    111 
    112   virtual void SetVisibleOnAllWorkspaces(bool always_visible) = 0;
    113 
    114   // Returns true if the title changed.
    115   virtual bool SetWindowTitle(const base::string16& title) = 0;
    116 
    117   virtual void ClearNativeFocus() = 0;
    118 
    119   virtual Widget::MoveLoopResult RunMoveLoop(
    120       const gfx::Vector2d& drag_offset,
    121       Widget::MoveLoopSource source,
    122       Widget::MoveLoopEscapeBehavior escape_behavior) = 0;
    123   virtual void EndMoveLoop() = 0;
    124 
    125   virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0;
    126 
    127   // Determines whether the window should use native title bar and borders.
    128   virtual bool ShouldUseNativeFrame() const = 0;
    129   // Determines whether the window contents should be rendered transparently
    130   // (for example, so that they can overhang onto the window title bar).
    131   virtual bool ShouldWindowContentsBeTransparent() const = 0;
    132   virtual void FrameTypeChanged() = 0;
    133 
    134   virtual void SetFullscreen(bool fullscreen) = 0;
    135   virtual bool IsFullscreen() const = 0;
    136 
    137   virtual void SetOpacity(unsigned char opacity) = 0;
    138 
    139   virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
    140                               const gfx::ImageSkia& app_icon) = 0;
    141 
    142   virtual void InitModalType(ui::ModalType modal_type) = 0;
    143 
    144   virtual void FlashFrame(bool flash_frame) = 0;
    145 
    146   virtual void OnRootViewLayout() const = 0;
    147 
    148   // Called when the DesktopNativeWidgetAura's aura::Window is focused and
    149   // blurred.
    150   virtual void OnNativeWidgetFocus() = 0;
    151   virtual void OnNativeWidgetBlur() = 0;
    152 
    153   // Returns true if the Widget was closed but is still showing because of
    154   // animations.
    155   virtual bool IsAnimatingClosed() const = 0;
    156 
    157   // Returns true if the Widget supports translucency.
    158   virtual bool IsTranslucentWindowOpacitySupported() const = 0;
    159 };
    160 
    161 }  // namespace views
    162 
    163 #endif  // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_H_
    164