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/size_constraints.h" | 11 #include "apps/size_constraints.h" |
12 #include "apps/ui/native_app_window.h" | 12 #include "apps/ui/native_app_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/web_contents_observer.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/base/accelerators/accelerator_manager.h" |
18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
19 | 20 |
20 namespace apps { | 21 namespace apps { |
21 class AppWindow; | 22 class AppWindow; |
22 } | 23 } |
23 | 24 |
24 class ExtensionKeybindingRegistryCocoa; | 25 class ExtensionKeybindingRegistryCocoa; |
25 class NativeAppWindowCocoa; | 26 class NativeAppWindowCocoa; |
26 @class ShellNSWindow; | 27 @class ShellNSWindow; |
27 class SkRegion; | 28 class SkRegion; |
28 | 29 |
29 // A window controller for a minimal window to host a web app view. Passes | 30 // A window controller for a minimal window to host a web app view. Passes |
30 // Objective-C notifications to the C++ bridge. | 31 // Objective-C notifications to the C++ bridge. |
31 @interface NativeAppWindowController : NSWindowController | 32 @interface NativeAppWindowController : NSWindowController |
32 <NSWindowDelegate, | 33 <NSWindowDelegate, |
33 BrowserCommandExecutor> { | 34 BrowserCommandExecutor> { |
34 @private | 35 @private |
35 NativeAppWindowCocoa* appWindow_; // Weak; owns self. | 36 NativeAppWindowCocoa* appWindow_; // Weak; owns self. |
36 } | 37 } |
37 | 38 |
38 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; | 39 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; |
39 | 40 |
40 // Consults the Command Registry to see if this |event| needs to be handled as | 41 // Consults the Command Registry to see if this |event| needs to be handled as |
41 // an extension command and returns YES if so (NO otherwise). | 42 // an extension command and returns YES if so (NO otherwise). |
42 - (BOOL)handledByExtensionCommand:(NSEvent*)event; | 43 // Only extensions with the given |priority| are considered. |
| 44 - (BOOL)handledByExtensionCommand:(NSEvent*)event |
| 45 priority:(ui::AcceleratorManager::HandlerPriority)priority; |
43 | 46 |
44 @end | 47 @end |
45 | 48 |
46 // Cocoa bridge to AppWindow. | 49 // Cocoa bridge to AppWindow. |
47 class NativeAppWindowCocoa : public apps::NativeAppWindow, | 50 class NativeAppWindowCocoa : public apps::NativeAppWindow, |
48 public content::WebContentsObserver { | 51 public content::WebContentsObserver { |
49 public: | 52 public: |
50 NativeAppWindowCocoa(apps::AppWindow* app_window, | 53 NativeAppWindowCocoa(apps::AppWindow* app_window, |
51 const apps::AppWindow::CreateParams& params); | 54 const apps::AppWindow::CreateParams& params); |
52 | 55 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Called when the window is zoomed (maximized or de-maximized). | 104 // Called when the window is zoomed (maximized or de-maximized). |
102 void WindowWillZoom(); | 105 void WindowWillZoom(); |
103 | 106 |
104 // Called when the window enters fullscreen. | 107 // Called when the window enters fullscreen. |
105 void WindowDidEnterFullscreen(); | 108 void WindowDidEnterFullscreen(); |
106 | 109 |
107 // Called when the window exits fullscreen. | 110 // Called when the window exits fullscreen. |
108 void WindowDidExitFullscreen(); | 111 void WindowDidExitFullscreen(); |
109 | 112 |
110 // Called to handle a key event. | 113 // Called to handle a key event. |
111 bool HandledByExtensionCommand(NSEvent* event); | 114 bool HandledByExtensionCommand( |
| 115 NSEvent* event, |
| 116 ui::AcceleratorManager::HandlerPriority priority); |
112 | 117 |
113 // Returns true if |point| in local Cocoa coordinate system falls within | 118 // Returns true if |point| in local Cocoa coordinate system falls within |
114 // the draggable region. | 119 // the draggable region. |
115 bool IsWithinDraggableRegion(NSPoint point) const; | 120 bool IsWithinDraggableRegion(NSPoint point) const; |
116 | 121 |
117 NSRect restored_bounds() const { return restored_bounds_; } | 122 NSRect restored_bounds() const { return restored_bounds_; } |
118 | 123 |
119 protected: | 124 protected: |
120 // NativeAppWindow implementation. | 125 // NativeAppWindow implementation. |
121 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; | 126 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 std::vector<extensions::DraggableRegion> draggable_regions_; | 216 std::vector<extensions::DraggableRegion> draggable_regions_; |
212 | 217 |
213 // The Extension Command Registry used to determine which keyboard events to | 218 // The Extension Command Registry used to determine which keyboard events to |
214 // handle. | 219 // handle. |
215 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; | 220 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; |
216 | 221 |
217 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); | 222 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); |
218 }; | 223 }; |
219 | 224 |
220 #endif // CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ | 225 #endif // CHROME_BROWSER_UI_COCOA_APPS_NATIVE_APP_WINDOW_COCOA_H_ |
OLD | NEW |