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.
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_
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"
13 class AppWindowFrameView;
18 class ImmersiveFullscreenController;
22 class ExtensionKeybindingRegistryViews;
28 class ChromeNativeAppWindowViews
29 : public native_app_window::NativeAppWindowViews,
30 public views::ContextMenuController {
32 ChromeNativeAppWindowViews();
33 virtual ~ChromeNativeAppWindowViews();
35 SkRegion* shape() { return shape_.get(); }
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);
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();
50 FRIEND_TEST_ALL_PREFIXES(ShapedAppWindowTargeterTest,
51 ResizeInsetsWithinBounds);
53 apps::AppWindowFrameView* CreateNonStandardAppFrame();
55 // ui::BaseWindow implementation.
56 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
57 virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
58 virtual bool IsAlwaysOnTop() const OVERRIDE;
60 // Overridden from views::ContextMenuController:
61 virtual void ShowContextMenuForView(views::View* source,
63 ui::MenuSourceType source_type) OVERRIDE;
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;
73 // views::View implementation.
74 virtual gfx::Size GetPreferredSize() const OVERRIDE;
75 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
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;
86 // NativeAppWindowViews implementation.
87 virtual void InitializeWindow(
88 extensions::AppWindow* app_window,
89 const extensions::AppWindow::CreateParams& create_params) OVERRIDE;
91 // True if the window is fullscreen or fullscreen is pending.
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_;
98 bool has_frame_color_;
99 SkColor active_frame_color_;
100 SkColor inactive_frame_color_;
101 gfx::Size preferred_size_;
103 // The class that registers for keyboard shortcuts for extension commands.
104 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_;
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
111 scoped_ptr<ash::ImmersiveFullscreenController>
112 immersive_fullscreen_controller_;
113 #endif // defined(USE_ASH)
115 // Used to show the system menu.
116 scoped_ptr<views::MenuRunner> menu_runner_;
118 DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViews);
121 #endif // CHROME_BROWSER_UI_VIEWS_APPS_CHROME_NATIVE_APP_WINDOW_VIEWS_H_