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_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_NATIVE_APP_WINDOW_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_NATIVE_APP_WINDOW_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/ui/extensions/native_shell_window.h" | 11 #include "chrome/browser/ui/extensions/native_app_window.h" |
12 #include "chrome/browser/ui/extensions/shell_window.h" | 12 #include "chrome/browser/ui/extensions/shell_window.h" |
13 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 13 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
14 #include "third_party/skia/include/core/SkRegion.h" | 14 #include "third_party/skia/include/core/SkRegion.h" |
15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
16 #include "ui/base/x/active_window_watcher_x_observer.h" | 16 #include "ui/base/x/active_window_watcher_x_observer.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 | 18 |
19 class ExtensionKeybindingRegistryGtk; | 19 class ExtensionKeybindingRegistryGtk; |
20 class Profile; | 20 class Profile; |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 class Extension; | 23 class Extension; |
24 } | 24 } |
25 | 25 |
26 class ShellWindowGtk : public NativeShellWindow, | 26 class NativeAppWindowGtk : public NativeAppWindow, |
27 public ExtensionViewGtk::Container, | 27 public ExtensionViewGtk::Container, |
28 public ui::ActiveWindowWatcherXObserver { | 28 public ui::ActiveWindowWatcherXObserver { |
29 public: | 29 public: |
30 ShellWindowGtk(ShellWindow* shell_window, | 30 NativeAppWindowGtk(ShellWindow* shell_window, |
31 const ShellWindow::CreateParams& params); | 31 const ShellWindow::CreateParams& params); |
32 | 32 |
33 // BaseWindow implementation. | 33 // BaseWindow implementation. |
34 virtual bool IsActive() const OVERRIDE; | 34 virtual bool IsActive() const OVERRIDE; |
35 virtual bool IsMaximized() const OVERRIDE; | 35 virtual bool IsMaximized() const OVERRIDE; |
36 virtual bool IsMinimized() const OVERRIDE; | 36 virtual bool IsMinimized() const OVERRIDE; |
37 virtual bool IsFullscreen() const OVERRIDE; | 37 virtual bool IsFullscreen() const OVERRIDE; |
38 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 38 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
39 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | 39 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; |
40 virtual gfx::Rect GetBounds() const OVERRIDE; | 40 virtual gfx::Rect GetBounds() const OVERRIDE; |
41 virtual void Show() OVERRIDE; | 41 virtual void Show() OVERRIDE; |
42 virtual void ShowInactive() OVERRIDE; | 42 virtual void ShowInactive() OVERRIDE; |
43 virtual void Hide() OVERRIDE; | 43 virtual void Hide() OVERRIDE; |
44 virtual void Close() OVERRIDE; | 44 virtual void Close() OVERRIDE; |
45 virtual void Activate() OVERRIDE; | 45 virtual void Activate() OVERRIDE; |
46 virtual void Deactivate() OVERRIDE; | 46 virtual void Deactivate() OVERRIDE; |
47 virtual void Maximize() OVERRIDE; | 47 virtual void Maximize() OVERRIDE; |
48 virtual void Minimize() OVERRIDE; | 48 virtual void Minimize() OVERRIDE; |
49 virtual void Restore() OVERRIDE; | 49 virtual void Restore() OVERRIDE; |
50 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 50 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
51 virtual void FlashFrame(bool flash) OVERRIDE; | 51 virtual void FlashFrame(bool flash) OVERRIDE; |
52 virtual bool IsAlwaysOnTop() const OVERRIDE; | 52 virtual bool IsAlwaysOnTop() const OVERRIDE; |
53 | 53 |
54 // ActiveWindowWatcherXObserver implementation. | 54 // ActiveWindowWatcherXObserver implementation. |
55 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; | 55 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; |
56 | 56 |
57 private: | 57 private: |
58 // NativeShellWindow implementation. | 58 // NativeAppWindow implementation. |
59 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | 59 virtual void SetFullscreen(bool fullscreen) OVERRIDE; |
60 virtual bool IsFullscreenOrPending() const OVERRIDE; | 60 virtual bool IsFullscreenOrPending() const OVERRIDE; |
61 virtual void UpdateWindowIcon() OVERRIDE; | 61 virtual void UpdateWindowIcon() OVERRIDE; |
62 virtual void UpdateWindowTitle() OVERRIDE; | 62 virtual void UpdateWindowTitle() OVERRIDE; |
63 virtual void HandleKeyboardEvent( | 63 virtual void HandleKeyboardEvent( |
64 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 64 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
65 virtual void UpdateDraggableRegions( | 65 virtual void UpdateDraggableRegions( |
66 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 66 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
67 virtual void RenderViewHostChanged() OVERRIDE {} | 67 virtual void RenderViewHostChanged() OVERRIDE {} |
68 | 68 |
69 content::WebContents* web_contents() const { | 69 content::WebContents* web_contents() const { |
70 return shell_window_->web_contents(); | 70 return shell_window_->web_contents(); |
71 } | 71 } |
72 const extensions::Extension* extension() const { | 72 const extensions::Extension* extension() const { |
73 return shell_window_->extension(); | 73 return shell_window_->extension(); |
74 } | 74 } |
75 | 75 |
76 virtual ~ShellWindowGtk(); | 76 virtual ~NativeAppWindowGtk(); |
77 | 77 |
78 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnMainWindowDeleteEvent, | 78 CHROMEGTK_CALLBACK_1(NativeAppWindowGtk, gboolean, OnMainWindowDeleteEvent, |
79 GdkEvent*); | 79 GdkEvent*); |
80 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnConfigure, | 80 CHROMEGTK_CALLBACK_1(NativeAppWindowGtk, gboolean, OnConfigure, |
81 GdkEventConfigure*); | 81 GdkEventConfigure*); |
82 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnWindowState, | 82 CHROMEGTK_CALLBACK_1(NativeAppWindowGtk, gboolean, OnWindowState, |
83 GdkEventWindowState*); | 83 GdkEventWindowState*); |
84 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnButtonPress, | 84 CHROMEGTK_CALLBACK_1(NativeAppWindowGtk, gboolean, OnButtonPress, |
85 GdkEventButton*); | 85 GdkEventButton*); |
86 | 86 |
87 void OnDebouncedBoundsChanged(); | 87 void OnDebouncedBoundsChanged(); |
88 | 88 |
89 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow. | 89 ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. |
90 | 90 |
91 GtkWindow* window_; | 91 GtkWindow* window_; |
92 GdkWindowState state_; | 92 GdkWindowState state_; |
93 | 93 |
94 // True if the window manager thinks the window is active. Not all window | 94 // True if the window manager thinks the window is active. Not all window |
95 // managers keep track of this state (_NET_ACTIVE_WINDOW), in which case | 95 // managers keep track of this state (_NET_ACTIVE_WINDOW), in which case |
96 // this will always be true. | 96 // this will always be true. |
97 bool is_active_; | 97 bool is_active_; |
98 | 98 |
99 // The position and size of the current window. | 99 // The position and size of the current window. |
(...skipping 11 matching lines...) Expand all Loading... |
111 scoped_ptr<SkRegion> draggable_region_; | 111 scoped_ptr<SkRegion> draggable_region_; |
112 | 112 |
113 // If true, don't call gdk_window_raise() when we get a click in the title | 113 // If true, don't call gdk_window_raise() when we get a click in the title |
114 // bar or window border. This is to work around a compiz bug. | 114 // bar or window border. This is to work around a compiz bug. |
115 bool suppress_window_raise_; | 115 bool suppress_window_raise_; |
116 | 116 |
117 // True if the window shows without frame. | 117 // True if the window shows without frame. |
118 bool frameless_; | 118 bool frameless_; |
119 | 119 |
120 // The timer used to save the window position for session restore. | 120 // The timer used to save the window position for session restore. |
121 base::OneShotTimer<ShellWindowGtk> window_configure_debounce_timer_; | 121 base::OneShotTimer<NativeAppWindowGtk> window_configure_debounce_timer_; |
122 | 122 |
123 // The Extension Keybinding Registry responsible for registering listeners for | 123 // The Extension Keybinding Registry responsible for registering listeners for |
124 // accelerators that are sent to the window, that are destined to be turned | 124 // accelerators that are sent to the window, that are destined to be turned |
125 // into events and sent to the extension. | 125 // into events and sent to the extension. |
126 scoped_ptr<ExtensionKeybindingRegistryGtk> extension_keybinding_registry_; | 126 scoped_ptr<ExtensionKeybindingRegistryGtk> extension_keybinding_registry_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(ShellWindowGtk); | 128 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowGtk); |
129 }; | 129 }; |
130 | 130 |
131 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | 131 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_NATIVE_APP_WINDOW_GTK_H_ |
OLD | NEW |