Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / apps / chrome_native_app_window_views.h
1 // Copyright 2014 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 CHROME_BROWSER_UI_VIEWS_APPS_CHROME_NATIVE_APP_WINDOW_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_APPS_CHROME_NATIVE_APP_WINDOW_VIEWS_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "components/native_app_window/native_app_window_views.h"
10 #include "ui/views/context_menu_controller.h"
11
12 namespace apps {
13 class AppWindowFrameView;
14 }
15
16 #if defined(USE_ASH)
17 namespace ash {
18 class ImmersiveFullscreenController;
19 }
20 #endif
21
22 class ExtensionKeybindingRegistryViews;
23
24 namespace views {
25 class MenuRunner;
26 }
27
28 class ChromeNativeAppWindowViews
29     : public native_app_window::NativeAppWindowViews,
30       public views::ContextMenuController {
31  public:
32   ChromeNativeAppWindowViews();
33   virtual ~ChromeNativeAppWindowViews();
34
35   SkRegion* shape() { return shape_.get(); }
36
37  protected:
38   // Called before views::Widget::Init() to allow subclasses to customize
39   // the InitParams that would be passed.
40   virtual void OnBeforeWidgetInit(views::Widget::InitParams* init_params,
41                                   views::Widget* widget);
42
43   virtual void InitializeDefaultWindow(
44       const extensions::AppWindow::CreateParams& create_params);
45   virtual void InitializePanelWindow(
46       const extensions::AppWindow::CreateParams& create_params);
47   virtual views::NonClientFrameView* CreateStandardDesktopAppFrame();
48
49  private:
50   FRIEND_TEST_ALL_PREFIXES(ShapedAppWindowTargeterTest,
51                            ResizeInsetsWithinBounds);
52
53   apps::AppWindowFrameView* CreateNonStandardAppFrame();
54
55   // ui::BaseWindow implementation.
56   virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
57   virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
58   virtual bool IsAlwaysOnTop() const OVERRIDE;
59
60   // Overridden from views::ContextMenuController:
61   virtual void ShowContextMenuForView(views::View* source,
62                                       const gfx::Point& p,
63                                       ui::MenuSourceType source_type) OVERRIDE;
64
65   // WidgetDelegate implementation.
66   virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
67   virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
68   virtual views::NonClientFrameView* CreateNonClientFrameView(
69       views::Widget* widget) OVERRIDE;
70   virtual bool WidgetHasHitTestMask() const OVERRIDE;
71   virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
72
73   // views::View implementation.
74   virtual gfx::Size GetPreferredSize() const OVERRIDE;
75   virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
76
77   // NativeAppWindow implementation.
78   virtual void SetFullscreen(int fullscreen_types) OVERRIDE;
79   virtual bool IsFullscreenOrPending() const OVERRIDE;
80   virtual void UpdateBadgeIcon() OVERRIDE;
81   virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE;
82   virtual bool HasFrameColor() const OVERRIDE;
83   virtual SkColor ActiveFrameColor() const OVERRIDE;
84   virtual SkColor InactiveFrameColor() const OVERRIDE;
85
86   // NativeAppWindowViews implementation.
87   virtual void InitializeWindow(
88       extensions::AppWindow* app_window,
89       const extensions::AppWindow::CreateParams& create_params) OVERRIDE;
90
91   // True if the window is fullscreen or fullscreen is pending.
92   bool is_fullscreen_;
93
94   // Custom shape of the window. If this is not set then the window has a
95   // default shape, usually rectangular.
96   scoped_ptr<SkRegion> shape_;
97
98   bool has_frame_color_;
99   SkColor active_frame_color_;
100   SkColor inactive_frame_color_;
101   gfx::Size preferred_size_;
102
103   // The class that registers for keyboard shortcuts for extension commands.
104   scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_;
105
106 #if defined(USE_ASH)
107   // Used to put non-frameless windows into immersive fullscreen on ChromeOS. In
108   // immersive fullscreen, the window header (title bar and window controls)
109   // slides onscreen as an overlay when the mouse is hovered at the top of the
110   // screen.
111   scoped_ptr<ash::ImmersiveFullscreenController>
112       immersive_fullscreen_controller_;
113 #endif  // defined(USE_ASH)
114
115   // Used to show the system menu.
116   scoped_ptr<views::MenuRunner> menu_runner_;
117
118   DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViews);
119 };
120
121 #endif  // CHROME_BROWSER_UI_VIEWS_APPS_CHROME_NATIVE_APP_WINDOW_VIEWS_H_