OLD | NEW |
(Empty) | |
| 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 APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_ |
| 6 #define APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_ |
| 7 |
| 8 #include "apps/ui/native_app_window.h" |
| 9 #include "base/observer_list.h" |
| 10 #include "ui/views/widget/widget_delegate.h" |
| 11 #include "ui/views/widget/widget_observer.h" |
| 12 |
| 13 namespace views { |
| 14 class WebView; |
| 15 class Widget; |
| 16 } |
| 17 |
| 18 namespace apps { |
| 19 |
| 20 class AppWindowFrameView; |
| 21 |
| 22 // A simple views-based native app window implementation for app_shell. It is |
| 23 // frameless and is permanently in the "restored" state (not maximized or |
| 24 // fullscreen). |
| 25 class ShellNativeAppWindow : public NativeAppWindow, |
| 26 public views::WidgetDelegateView, |
| 27 public views::WidgetObserver { |
| 28 public: |
| 29 ShellNativeAppWindow(); |
| 30 virtual ~ShellNativeAppWindow(); |
| 31 |
| 32 void Init(AppWindow* app_window, const gfx::Rect& window_bounds); |
| 33 |
| 34 private: |
| 35 // Initializes |window_| to center it on the screen. |
| 36 void InitializeWindow(const gfx::Rect& window_bounds); |
| 37 |
| 38 // Informs observers of the size of the view (initially and on update). |
| 39 void OnViewWasResized(); |
| 40 |
| 41 // Returns this app's extension. |
| 42 const extensions::Extension* GetExtension(); |
| 43 |
| 44 // Returns the WebContents for the app. |
| 45 content::WebContents* GetWebContents(); |
| 46 |
| 47 // ui::BaseWindow implementation. |
| 48 virtual bool IsActive() const OVERRIDE; |
| 49 virtual bool IsMaximized() const OVERRIDE; |
| 50 virtual bool IsMinimized() const OVERRIDE; |
| 51 virtual bool IsFullscreen() const OVERRIDE; |
| 52 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 53 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; |
| 54 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; |
| 55 virtual gfx::Rect GetBounds() const OVERRIDE; |
| 56 virtual void Show() OVERRIDE; |
| 57 virtual void ShowInactive() OVERRIDE; |
| 58 virtual void Hide() OVERRIDE; |
| 59 virtual void Close() OVERRIDE; |
| 60 virtual void Activate() OVERRIDE; |
| 61 virtual void Deactivate() OVERRIDE; |
| 62 virtual void Maximize() OVERRIDE; |
| 63 virtual void Minimize() OVERRIDE; |
| 64 virtual void Restore() OVERRIDE; |
| 65 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
| 66 virtual void FlashFrame(bool flash) OVERRIDE; |
| 67 virtual bool IsAlwaysOnTop() const OVERRIDE; |
| 68 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; |
| 69 |
| 70 // WidgetDelegate implementation. |
| 71 virtual void OnWidgetMove() OVERRIDE; |
| 72 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 73 virtual bool CanResize() const OVERRIDE; |
| 74 virtual bool CanMaximize() const OVERRIDE; |
| 75 virtual base::string16 GetWindowTitle() const OVERRIDE; |
| 76 virtual bool ShouldShowWindowTitle() const OVERRIDE; |
| 77 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; |
| 78 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; |
| 79 virtual bool ShouldShowWindowIcon() const OVERRIDE; |
| 80 virtual void SaveWindowPlacement(const gfx::Rect& bounds, |
| 81 ui::WindowShowState show_state) OVERRIDE; |
| 82 virtual void DeleteDelegate() OVERRIDE; |
| 83 virtual views::Widget* GetWidget() OVERRIDE; |
| 84 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 85 virtual views::View* GetContentsView() OVERRIDE; |
| 86 virtual views::NonClientFrameView* CreateNonClientFrameView( |
| 87 views::Widget* widget) OVERRIDE; |
| 88 virtual bool WidgetHasHitTestMask() const OVERRIDE; |
| 89 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; |
| 90 virtual bool ShouldDescendIntoChildForEventHandling( |
| 91 gfx::NativeView child, |
| 92 const gfx::Point& location) OVERRIDE; |
| 93 |
| 94 // WidgetObserver implementation. |
| 95 virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
| 96 bool visible) OVERRIDE; |
| 97 virtual void OnWidgetActivationChanged(views::Widget* widget, |
| 98 bool active) OVERRIDE; |
| 99 |
| 100 // views::View implementation. |
| 101 virtual void Layout() OVERRIDE; |
| 102 virtual void ViewHierarchyChanged( |
| 103 const ViewHierarchyChangedDetails& details) OVERRIDE; |
| 104 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 105 virtual gfx::Size GetMaximumSize() OVERRIDE; |
| 106 virtual void OnFocus() OVERRIDE; |
| 107 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 108 |
| 109 // NativeAppWindow implementation. |
| 110 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; |
| 111 virtual bool IsFullscreenOrPending() const OVERRIDE; |
| 112 virtual bool IsDetached() const OVERRIDE; |
| 113 virtual void UpdateWindowIcon() OVERRIDE; |
| 114 virtual void UpdateWindowTitle() OVERRIDE; |
| 115 virtual void UpdateBadgeIcon() OVERRIDE; |
| 116 virtual void UpdateDraggableRegions( |
| 117 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
| 118 virtual SkRegion* GetDraggableRegion() OVERRIDE; |
| 119 virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; |
| 120 virtual void HandleKeyboardEvent( |
| 121 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 122 virtual bool IsFrameless() const OVERRIDE; |
| 123 virtual gfx::Insets GetFrameInsets() const OVERRIDE; |
| 124 virtual void HideWithApp() OVERRIDE; |
| 125 virtual void ShowWithApp() OVERRIDE; |
| 126 virtual void UpdateWindowMinMaxSize() OVERRIDE; |
| 127 |
| 128 // web_modal::WebContentsModalDialogHost implementation. |
| 129 virtual gfx::NativeView GetHostView() const OVERRIDE; |
| 130 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; |
| 131 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; |
| 132 virtual void AddObserver( |
| 133 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 134 virtual void RemoveObserver( |
| 135 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 136 |
| 137 AppWindow* shell_window_; // Not owned. |
| 138 views::WebView* web_view_; |
| 139 views::Widget* window_; |
| 140 |
| 141 ObserverList<web_modal::ModalDialogHostObserver> observer_list_; |
| 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(ShellNativeAppWindow); |
| 144 }; |
| 145 |
| 146 } // namespace apps |
| 147 |
| 148 #endif // APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_ |
OLD | NEW |