OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ |
7 | 7 |
8 #include "chrome/browser/ui/base_window.h" | 8 #include "chrome/browser/ui/base_window.h" |
9 #include "chrome/browser/ui/extensions/native_app_window.h" | 9 #include "chrome/browser/ui/extensions/native_app_window.h" |
10 #include "chrome/browser/ui/extensions/shell_window.h" | 10 #include "chrome/browser/ui/extensions/shell_window.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace views { | 29 namespace views { |
30 class WebView; | 30 class WebView; |
31 } | 31 } |
32 | 32 |
33 class NativeAppWindowViews : public NativeAppWindow, | 33 class NativeAppWindowViews : public NativeAppWindow, |
34 public views::WidgetDelegateView, | 34 public views::WidgetDelegateView, |
35 public views::WidgetObserver { | 35 public views::WidgetObserver { |
36 public: | 36 public: |
37 NativeAppWindowViews(ShellWindow* shell_window, | 37 NativeAppWindowViews(ShellWindow* shell_window, |
38 const ShellWindow::CreateParams& params); | 38 const ShellWindow::CreateParams& params); |
| 39 virtual ~NativeAppWindowViews(); |
39 | 40 |
40 bool frameless() const { return frameless_; } | 41 bool frameless() const { return frameless_; } |
41 SkRegion* draggable_region() { return draggable_region_.get(); } | 42 SkRegion* draggable_region() { return draggable_region_.get(); } |
42 | 43 |
| 44 private: |
| 45 void InitializeDefaultWindow(const ShellWindow::CreateParams& create_params); |
| 46 void InitializePanelWindow(const ShellWindow::CreateParams& create_params); |
| 47 void OnViewWasResized(); |
| 48 |
43 // BaseWindow implementation. | 49 // BaseWindow implementation. |
44 virtual bool IsActive() const OVERRIDE; | 50 virtual bool IsActive() const OVERRIDE; |
45 virtual bool IsMaximized() const OVERRIDE; | 51 virtual bool IsMaximized() const OVERRIDE; |
46 virtual bool IsMinimized() const OVERRIDE; | 52 virtual bool IsMinimized() const OVERRIDE; |
47 virtual bool IsFullscreen() const OVERRIDE; | 53 virtual bool IsFullscreen() const OVERRIDE; |
48 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 54 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
49 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | 55 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; |
50 virtual gfx::Rect GetBounds() const OVERRIDE; | 56 virtual gfx::Rect GetBounds() const OVERRIDE; |
51 virtual void Show() OVERRIDE; | 57 virtual void Show() OVERRIDE; |
52 virtual void ShowInactive() OVERRIDE; | 58 virtual void ShowInactive() OVERRIDE; |
53 virtual void Hide() OVERRIDE; | 59 virtual void Hide() OVERRIDE; |
54 virtual void Close() OVERRIDE; | 60 virtual void Close() OVERRIDE; |
55 virtual void Activate() OVERRIDE; | 61 virtual void Activate() OVERRIDE; |
56 virtual void Deactivate() OVERRIDE; | 62 virtual void Deactivate() OVERRIDE; |
57 virtual void Maximize() OVERRIDE; | 63 virtual void Maximize() OVERRIDE; |
58 virtual void Minimize() OVERRIDE; | 64 virtual void Minimize() OVERRIDE; |
59 virtual void Restore() OVERRIDE; | 65 virtual void Restore() OVERRIDE; |
60 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 66 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
61 virtual void FlashFrame(bool flash) OVERRIDE; | 67 virtual void FlashFrame(bool flash) OVERRIDE; |
62 virtual bool IsAlwaysOnTop() const OVERRIDE; | 68 virtual bool IsAlwaysOnTop() const OVERRIDE; |
63 | 69 |
64 // WidgetDelegate implementation. | 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 string16 GetWindowTitle() const OVERRIDE; |
| 76 virtual bool ShouldShowWindowTitle() const OVERRIDE; |
| 77 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; |
| 78 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; |
| 79 virtual void SaveWindowPlacement(const gfx::Rect& bounds, |
| 80 ui::WindowShowState show_state) OVERRIDE; |
| 81 virtual void DeleteDelegate() OVERRIDE; |
| 82 virtual views::Widget* GetWidget() OVERRIDE; |
| 83 virtual const views::Widget* GetWidget() const OVERRIDE; |
65 virtual views::View* GetContentsView() OVERRIDE; | 84 virtual views::View* GetContentsView() OVERRIDE; |
66 virtual views::NonClientFrameView* CreateNonClientFrameView( | 85 virtual views::NonClientFrameView* CreateNonClientFrameView( |
67 views::Widget* widget) OVERRIDE; | 86 views::Widget* widget) OVERRIDE; |
68 virtual bool CanResize() const OVERRIDE; | |
69 virtual bool CanMaximize() const OVERRIDE; | |
70 virtual views::Widget* GetWidget() OVERRIDE; | |
71 virtual const views::Widget* GetWidget() const OVERRIDE; | |
72 virtual string16 GetWindowTitle() const OVERRIDE; | |
73 virtual void DeleteDelegate() OVERRIDE; | |
74 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | |
75 virtual bool ShouldDescendIntoChildForEventHandling( | 87 virtual bool ShouldDescendIntoChildForEventHandling( |
76 gfx::NativeView child, | 88 gfx::NativeView child, |
77 const gfx::Point& location) OVERRIDE; | 89 const gfx::Point& location) OVERRIDE; |
78 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; | |
79 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; | |
80 virtual bool ShouldShowWindowTitle() const OVERRIDE; | |
81 virtual void OnWidgetMove() OVERRIDE; | |
82 | 90 |
83 // WidgetObserver implementation. | 91 // WidgetObserver implementation. |
84 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | 92 virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
85 bool visible) OVERRIDE; | 93 bool visible) OVERRIDE; |
86 virtual void OnWidgetActivationChanged(views::Widget* widget, | 94 virtual void OnWidgetActivationChanged(views::Widget* widget, |
87 bool active) OVERRIDE; | 95 bool active) OVERRIDE; |
88 | 96 |
89 protected: | |
90 // views::View implementation. | 97 // views::View implementation. |
91 virtual void Layout() OVERRIDE; | 98 virtual void Layout() OVERRIDE; |
92 virtual void ViewHierarchyChanged( | 99 virtual void ViewHierarchyChanged( |
93 bool is_add, views::View *parent, views::View *child) OVERRIDE; | 100 bool is_add, views::View *parent, views::View *child) OVERRIDE; |
| 101 virtual gfx::Size GetPreferredSize() OVERRIDE; |
94 virtual gfx::Size GetMinimumSize() OVERRIDE; | 102 virtual gfx::Size GetMinimumSize() OVERRIDE; |
95 virtual gfx::Size GetMaximumSize() OVERRIDE; | 103 virtual gfx::Size GetMaximumSize() OVERRIDE; |
96 virtual void OnFocus() OVERRIDE; | 104 virtual void OnFocus() OVERRIDE; |
97 | 105 |
98 Profile* profile() { return shell_window_->profile(); } | |
99 content::WebContents* web_contents() { | |
100 return shell_window_->web_contents(); | |
101 } | |
102 const extensions::Extension* extension() { | |
103 return shell_window_->extension(); | |
104 } | |
105 | |
106 // views::WidgetDelegate implementation. | |
107 virtual void SaveWindowPlacement(const gfx::Rect& bounds, | |
108 ui::WindowShowState show_state) OVERRIDE; | |
109 | |
110 private: | |
111 friend class ShellWindowFrameView; | |
112 | |
113 virtual ~NativeAppWindowViews(); | |
114 | |
115 // NativeAppWindow implementation. | 106 // NativeAppWindow implementation. |
116 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | 107 virtual void SetFullscreen(bool fullscreen) OVERRIDE; |
117 virtual bool IsFullscreenOrPending() const OVERRIDE; | 108 virtual bool IsFullscreenOrPending() const OVERRIDE; |
118 virtual void UpdateWindowIcon() OVERRIDE; | 109 virtual void UpdateWindowIcon() OVERRIDE; |
119 virtual void UpdateWindowTitle() OVERRIDE; | 110 virtual void UpdateWindowTitle() OVERRIDE; |
120 virtual void UpdateDraggableRegions( | 111 virtual void UpdateDraggableRegions( |
121 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 112 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
122 virtual void HandleKeyboardEvent( | 113 virtual void HandleKeyboardEvent( |
123 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 114 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
124 virtual void RenderViewHostChanged() OVERRIDE; | 115 virtual void RenderViewHostChanged() OVERRIDE; |
125 | 116 |
126 void OnViewWasResized(); | 117 Profile* profile() { return shell_window_->profile(); } |
| 118 content::WebContents* web_contents() { |
| 119 return shell_window_->web_contents(); |
| 120 } |
| 121 const extensions::Extension* extension() { |
| 122 return shell_window_->extension(); |
| 123 } |
127 | 124 |
128 ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. | 125 ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. |
129 | |
130 views::WebView* web_view_; | 126 views::WebView* web_view_; |
131 views::Widget* window_; | 127 views::Widget* window_; |
132 bool is_fullscreen_; | 128 bool is_fullscreen_; |
133 | 129 |
134 scoped_ptr<SkRegion> draggable_region_; | 130 scoped_ptr<SkRegion> draggable_region_; |
135 | 131 |
136 bool frameless_; | 132 bool frameless_; |
137 gfx::Size minimum_size_; | 133 gfx::Size minimum_size_; |
138 gfx::Size maximum_size_; | 134 gfx::Size maximum_size_; |
| 135 gfx::Size preferred_size_; |
139 | 136 |
140 // The class that registers for keyboard shortcuts for extension commands. | 137 // The class that registers for keyboard shortcuts for extension commands. |
141 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | 138 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; |
142 | 139 |
143 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 140 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
144 | 141 |
145 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); | 142 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); |
146 }; | 143 }; |
147 | 144 |
148 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | 145 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ |
OLD | NEW |