| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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_NATIVE_APP_WINDOW_VIEWS_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_APPS_NATIVE_APP_WINDOW_VIEWS_H_ | |
| 7 | |
| 8 #include "apps/ui/views/base_native_app_window_views.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "ui/views/context_menu_controller.h" | |
| 11 | |
| 12 #if defined(USE_ASH) | |
| 13 namespace ash { | |
| 14 class ImmersiveFullscreenController; | |
| 15 } | |
| 16 #endif | |
| 17 | |
| 18 class ExtensionKeybindingRegistryViews; | |
| 19 | |
| 20 namespace views { | |
| 21 class MenuRunner; | |
| 22 } | |
| 23 | |
| 24 class NativeAppWindowViews : public BaseNativeAppWindowViews, | |
| 25 public views::ContextMenuController { | |
| 26 public: | |
| 27 NativeAppWindowViews(); | |
| 28 virtual ~NativeAppWindowViews(); | |
| 29 | |
| 30 SkRegion* shape() { return shape_.get(); } | |
| 31 | |
| 32 protected: | |
| 33 // Called before views::Widget::Init() to allow subclasses to customize | |
| 34 // the InitParams that would be passed. | |
| 35 virtual void OnBeforeWidgetInit(views::Widget::InitParams* init_params, | |
| 36 views::Widget* widget); | |
| 37 | |
| 38 virtual void InitializeDefaultWindow( | |
| 39 const apps::AppWindow::CreateParams& create_params); | |
| 40 virtual void InitializePanelWindow( | |
| 41 const apps::AppWindow::CreateParams& create_params); | |
| 42 | |
| 43 private: | |
| 44 FRIEND_TEST_ALL_PREFIXES(ShapedAppWindowTargeterTest, | |
| 45 ResizeInsetsWithinBounds); | |
| 46 | |
| 47 bool ShouldUseNativeFrame() const; | |
| 48 | |
| 49 // Installs an EasyResizeWindowTargeter on the containing window, which | |
| 50 // allows the window to be resized from within |kResizeInsideBoundsSize| | |
| 51 // pixels inside the window bounds. | |
| 52 void InstallEasyResizeTargeterOnContainer() const; | |
| 53 | |
| 54 // Caller owns the returned object. | |
| 55 apps::AppWindowFrameView* CreateAppWindowFrameView(); | |
| 56 | |
| 57 // ui::BaseWindow implementation. | |
| 58 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; | |
| 59 virtual bool IsAlwaysOnTop() const OVERRIDE; | |
| 60 | |
| 61 // Overridden from views::ContextMenuController: | |
| 62 virtual void ShowContextMenuForView(views::View* source, | |
| 63 const gfx::Point& p, | |
| 64 ui::MenuSourceType source_type) OVERRIDE; | |
| 65 | |
| 66 // WidgetDelegate implementation. | |
| 67 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; | |
| 68 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; | |
| 69 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
| 70 views::Widget* widget) OVERRIDE; | |
| 71 virtual bool WidgetHasHitTestMask() const OVERRIDE; | |
| 72 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; | |
| 73 | |
| 74 // views::View implementation. | |
| 75 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 76 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 77 | |
| 78 // NativeAppWindow implementation. | |
| 79 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; | |
| 80 virtual bool IsFullscreenOrPending() const OVERRIDE; | |
| 81 virtual bool IsDetached() const OVERRIDE; | |
| 82 virtual void UpdateBadgeIcon() OVERRIDE; | |
| 83 virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; | |
| 84 virtual bool HasFrameColor() const OVERRIDE; | |
| 85 virtual SkColor FrameColor() const OVERRIDE; | |
| 86 | |
| 87 // BaseNativeAppWindowViews implementation. | |
| 88 virtual void InitializeWindow( | |
| 89 apps::AppWindow* app_window, | |
| 90 const apps::AppWindow::CreateParams& create_params) OVERRIDE; | |
| 91 | |
| 92 // True if the window is fullscreen or fullscreen is pending. | |
| 93 bool is_fullscreen_; | |
| 94 | |
| 95 // Custom shape of the window. If this is not set then the window has a | |
| 96 // default shape, usually rectangular. | |
| 97 scoped_ptr<SkRegion> shape_; | |
| 98 | |
| 99 bool has_frame_color_; | |
| 100 SkColor 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(NativeAppWindowViews); | |
| 119 }; | |
| 120 | |
| 121 #endif // CHROME_BROWSER_UI_VIEWS_APPS_NATIVE_APP_WINDOW_VIEWS_H_ | |
| OLD | NEW |