OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "apps/native_app_window.h" | 11 #include "apps/native_app_window.h" |
12 #include "apps/shell_window.h" | 12 #include "apps/shell_window.h" |
13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | 15 #import "chrome/browser/ui/cocoa/browser_command_executor.h" |
16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "extensions/common/draggable_region.h" | 17 #include "extensions/common/draggable_region.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 | 19 |
20 class ExtensionKeybindingRegistryCocoa; | 20 class ExtensionKeybindingRegistryCocoa; |
21 class Profile; | 21 class Profile; |
22 class NativeAppWindowCocoa; | 22 class NativeAppWindowCocoa; |
23 @class ShellNSWindow; | 23 @class ShellNSWindow; |
24 class SkRegion; | 24 class SkRegion; |
25 | 25 |
26 // A window controller for a minimal window to host a web app view. Passes | 26 // A window controller for a minimal window to host a web app view. Passes |
27 // Objective-C notifications to the C++ bridge. | 27 // Objective-C notifications to the C++ bridge. |
28 @interface NativeAppWindowController : NSWindowController | 28 @interface NativeAppWindowController : NSWindowController |
29 <NSWindowDelegate, | 29 <NSWindowDelegate, |
30 BrowserCommandExecutor> { | 30 BrowserCommandExecutor> { |
31 @private | 31 @private |
32 NativeAppWindowCocoa* appWindow_; // Weak; owns self. | 32 NativeAppWindowCocoa* appWindow_; // Weak; owns self. |
33 } | 33 } |
34 | 34 |
35 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; | 35 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; |
36 | 36 |
37 // Consults the Command Registry to see if this |event| needs to be handled as | 37 // Consults the Command Registry to see if this |event| needs to be handled as |
38 // an extension command and returns YES if so (NO otherwise). | 38 // an extension command and returns YES if so (NO otherwise). |
39 - (BOOL)handledByExtensionCommand:(NSEvent*)event; | 39 - (BOOL)handledByExtensionCommand:(NSEvent*)event; |
40 | 40 |
41 @end | 41 @end |
42 | 42 |
43 // Cocoa bridge to AppWindow. | 43 // Cocoa bridge to AppWindow. |
44 class NativeAppWindowCocoa : public apps::NativeAppWindow { | 44 class NativeAppWindowCocoa : public apps::NativeAppWindow, |
| 45 public content::WebContentsObserver { |
45 public: | 46 public: |
46 NativeAppWindowCocoa(apps::ShellWindow* shell_window, | 47 NativeAppWindowCocoa(apps::ShellWindow* shell_window, |
47 const apps::ShellWindow::CreateParams& params); | 48 const apps::ShellWindow::CreateParams& params); |
48 | 49 |
49 // ui::BaseWindow implementation. | 50 // ui::BaseWindow implementation. |
50 virtual bool IsActive() const OVERRIDE; | 51 virtual bool IsActive() const OVERRIDE; |
51 virtual bool IsMaximized() const OVERRIDE; | 52 virtual bool IsMaximized() const OVERRIDE; |
52 virtual bool IsMinimized() const OVERRIDE; | 53 virtual bool IsMinimized() const OVERRIDE; |
53 virtual bool IsFullscreen() const OVERRIDE; | 54 virtual bool IsFullscreen() const OVERRIDE; |
54 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 55 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | 116 virtual void SetFullscreen(bool fullscreen) OVERRIDE; |
116 virtual bool IsFullscreenOrPending() const OVERRIDE; | 117 virtual bool IsFullscreenOrPending() const OVERRIDE; |
117 virtual bool IsDetached() const OVERRIDE; | 118 virtual bool IsDetached() const OVERRIDE; |
118 virtual void UpdateWindowIcon() OVERRIDE; | 119 virtual void UpdateWindowIcon() OVERRIDE; |
119 virtual void UpdateWindowTitle() OVERRIDE; | 120 virtual void UpdateWindowTitle() OVERRIDE; |
120 virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE; | 121 virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE; |
121 virtual void UpdateDraggableRegions( | 122 virtual void UpdateDraggableRegions( |
122 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 123 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
123 virtual void HandleKeyboardEvent( | 124 virtual void HandleKeyboardEvent( |
124 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 125 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
125 virtual void RenderViewHostChanged() OVERRIDE; | |
126 virtual gfx::Insets GetFrameInsets() const OVERRIDE; | 126 virtual gfx::Insets GetFrameInsets() const OVERRIDE; |
127 | 127 |
| 128 // WebContentsObserver implementation. |
| 129 virtual void RenderViewHostChanged( |
| 130 content::RenderViewHost* old_host, |
| 131 content::RenderViewHost* new_host) OVERRIDE; |
| 132 |
128 // These are used to simulate Mac-style hide/show. Since windows can be hidden | 133 // These are used to simulate Mac-style hide/show. Since windows can be hidden |
129 // and shown using the app.window API, this sets is_hidden_with_app_ to | 134 // and shown using the app.window API, this sets is_hidden_with_app_ to |
130 // differentiate the reason a window was hidden. | 135 // differentiate the reason a window was hidden. |
131 virtual void ShowWithApp() OVERRIDE; | 136 virtual void ShowWithApp() OVERRIDE; |
132 virtual void HideWithApp() OVERRIDE; | 137 virtual void HideWithApp() OVERRIDE; |
133 | 138 |
134 // WebContentsModalDialogHost implementation. | 139 // WebContentsModalDialogHost implementation. |
135 virtual gfx::NativeView GetHostView() const OVERRIDE; | 140 virtual gfx::NativeView GetHostView() const OVERRIDE; |
136 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; | 141 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; |
137 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; | 142 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 NSPoint last_mouse_location_; | 217 NSPoint last_mouse_location_; |
213 | 218 |
214 // The Extension Command Registry used to determine which keyboard events to | 219 // The Extension Command Registry used to determine which keyboard events to |
215 // handle. | 220 // handle. |
216 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; | 221 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; |
217 | 222 |
218 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); | 223 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); |
219 }; | 224 }; |
220 | 225 |
221 #endif // CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ | 226 #endif // CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ |
OLD | NEW |