chrome_native_app_window_views.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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 "apps/ui/views/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) 13namespace ash { 14class ImmersiveFullscreenController; 15} 16#endif 17 18class ExtensionKeybindingRegistryViews; 19 20namespace views { 21class MenuRunner; 22} 23 24class ChromeNativeAppWindowViews : public apps::NativeAppWindowViews, 25 public views::ContextMenuController { 26 public: 27 ChromeNativeAppWindowViews(); 28 virtual ~ChromeNativeAppWindowViews(); 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 virtual views::NonClientFrameView* CreateStandardDesktopAppFrame(); 43 44 private: 45 FRIEND_TEST_ALL_PREFIXES(ShapedAppWindowTargeterTest, 46 ResizeInsetsWithinBounds); 47 48 apps::AppWindowFrameView* CreateNonStandardAppFrame(); 49 50 // ui::BaseWindow implementation. 51 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; 52 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; 53 virtual bool IsAlwaysOnTop() const OVERRIDE; 54 55 // Overridden from views::ContextMenuController: 56 virtual void ShowContextMenuForView(views::View* source, 57 const gfx::Point& p, 58 ui::MenuSourceType source_type) OVERRIDE; 59 60 // WidgetDelegate implementation. 61 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; 62 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 63 virtual views::NonClientFrameView* CreateNonClientFrameView( 64 views::Widget* widget) OVERRIDE; 65 virtual bool WidgetHasHitTestMask() const OVERRIDE; 66 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; 67 68 // views::View implementation. 69 virtual gfx::Size GetPreferredSize() const OVERRIDE; 70 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 71 72 // NativeAppWindow implementation. 73 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; 74 virtual bool IsFullscreenOrPending() const OVERRIDE; 75 virtual bool IsDetached() const OVERRIDE; 76 virtual void UpdateBadgeIcon() OVERRIDE; 77 virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; 78 virtual bool HasFrameColor() const OVERRIDE; 79 virtual SkColor ActiveFrameColor() const OVERRIDE; 80 virtual SkColor InactiveFrameColor() const OVERRIDE; 81 82 // NativeAppWindowViews implementation. 83 virtual void InitializeWindow( 84 apps::AppWindow* app_window, 85 const apps::AppWindow::CreateParams& create_params) OVERRIDE; 86 87 // True if the window is fullscreen or fullscreen is pending. 88 bool is_fullscreen_; 89 90 // Custom shape of the window. If this is not set then the window has a 91 // default shape, usually rectangular. 92 scoped_ptr<SkRegion> shape_; 93 94 bool has_frame_color_; 95 SkColor active_frame_color_; 96 SkColor inactive_frame_color_; 97 gfx::Size preferred_size_; 98 99 // The class that registers for keyboard shortcuts for extension commands. 100 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; 101 102#if defined(USE_ASH) 103 // Used to put non-frameless windows into immersive fullscreen on ChromeOS. In 104 // immersive fullscreen, the window header (title bar and window controls) 105 // slides onscreen as an overlay when the mouse is hovered at the top of the 106 // screen. 107 scoped_ptr<ash::ImmersiveFullscreenController> 108 immersive_fullscreen_controller_; 109#endif // defined(USE_ASH) 110 111 // Used to show the system menu. 112 scoped_ptr<views::MenuRunner> menu_runner_; 113 114 DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViews); 115}; 116 117#endif // CHROME_BROWSER_UI_VIEWS_APPS_CHROME_NATIVE_APP_WINDOW_VIEWS_H_ 118