OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SHELL_WINDOW_VIEWS_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SHELL_WINDOW_VIEWS_H_ | |
7 | |
8 #include "chrome/browser/ui/base_window.h" | |
9 #include "chrome/browser/ui/extensions/native_shell_window.h" | |
10 #include "chrome/browser/ui/extensions/shell_window.h" | |
11 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" | |
12 #include "third_party/skia/include/core/SkRegion.h" | |
13 #include "ui/gfx/image/image_skia.h" | |
14 #include "ui/gfx/rect.h" | |
15 #include "ui/views/widget/widget_delegate.h" | |
16 #include "ui/views/widget/widget_observer.h" | |
17 | |
18 class ExtensionKeybindingRegistryViews; | |
19 class Profile; | |
20 | |
21 namespace content { | |
22 class WebContents; | |
23 } | |
24 | |
25 namespace extensions { | |
26 class Extension; | |
27 } | |
28 | |
29 namespace views { | |
30 class WebView; | |
31 } | |
32 | |
33 class ShellWindowViews : public NativeShellWindow, | |
34 public views::WidgetDelegateView, | |
35 public views::WidgetObserver { | |
36 public: | |
37 ShellWindowViews(ShellWindow* shell_window, | |
38 const ShellWindow::CreateParams& params); | |
39 | |
40 bool frameless() const { return frameless_; } | |
41 SkRegion* draggable_region() { return draggable_region_.get(); } | |
42 | |
43 // BaseWindow implementation. | |
44 virtual bool IsActive() const OVERRIDE; | |
45 virtual bool IsMaximized() const OVERRIDE; | |
46 virtual bool IsMinimized() const OVERRIDE; | |
47 virtual bool IsFullscreen() const OVERRIDE; | |
48 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | |
49 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
50 virtual gfx::Rect GetBounds() const OVERRIDE; | |
51 virtual void Show() OVERRIDE; | |
52 virtual void ShowInactive() OVERRIDE; | |
53 virtual void Hide() OVERRIDE; | |
54 virtual void Close() OVERRIDE; | |
55 virtual void Activate() OVERRIDE; | |
56 virtual void Deactivate() OVERRIDE; | |
57 virtual void Maximize() OVERRIDE; | |
58 virtual void Minimize() OVERRIDE; | |
59 virtual void Restore() OVERRIDE; | |
60 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
61 virtual void FlashFrame(bool flash) OVERRIDE; | |
62 virtual bool IsAlwaysOnTop() const OVERRIDE; | |
63 | |
64 // WidgetDelegate implementation. | |
65 virtual views::View* GetContentsView() OVERRIDE; | |
66 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
67 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( | |
76 gfx::NativeView child, | |
77 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 | |
83 // WidgetObserver implementation. | |
84 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | |
85 bool visible) OVERRIDE; | |
86 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
87 bool active) OVERRIDE; | |
88 | |
89 protected: | |
90 // views::View implementation. | |
91 virtual void Layout() OVERRIDE; | |
92 virtual void ViewHierarchyChanged( | |
93 bool is_add, views::View *parent, views::View *child) OVERRIDE; | |
94 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
95 virtual gfx::Size GetMaximumSize() OVERRIDE; | |
96 virtual void OnFocus() OVERRIDE; | |
97 | |
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 ~ShellWindowViews(); | |
114 | |
115 // NativeShellWindow implementation. | |
116 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
117 virtual bool IsFullscreenOrPending() const OVERRIDE; | |
118 virtual void UpdateWindowIcon() OVERRIDE; | |
119 virtual void UpdateWindowTitle() OVERRIDE; | |
120 virtual void UpdateDraggableRegions( | |
121 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | |
122 virtual void HandleKeyboardEvent( | |
123 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
124 virtual void RenderViewHostChanged() OVERRIDE; | |
125 | |
126 void OnViewWasResized(); | |
127 | |
128 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow. | |
129 | |
130 views::WebView* web_view_; | |
131 views::Widget* window_; | |
132 bool is_fullscreen_; | |
133 | |
134 scoped_ptr<SkRegion> draggable_region_; | |
135 | |
136 bool frameless_; | |
137 gfx::Size minimum_size_; | |
138 gfx::Size maximum_size_; | |
139 | |
140 // The class that registers for keyboard shortcuts for extension commands. | |
141 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | |
142 | |
143 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | |
144 | |
145 DISALLOW_COPY_AND_ASSIGN(ShellWindowViews); | |
146 }; | |
147 | |
148 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SHELL_WINDOW_VIEWS_H_ | |
OLD | NEW |