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_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_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 "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
12 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | 12 #import "chrome/browser/ui/cocoa/browser_command_executor.h" |
13 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" | 13 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
14 #include "chrome/browser/ui/extensions/native_shell_window.h" | 14 #include "chrome/browser/ui/extensions/native_shell_window.h" |
15 #include "chrome/browser/ui/extensions/shell_window.h" | 15 #include "chrome/browser/ui/extensions/shell_window.h" |
16 #include "chrome/common/extensions/draggable_region.h" | 16 #include "chrome/common/extensions/draggable_region.h" |
17 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 17 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 | 19 |
| 20 class ExtensionKeybindingRegistryCocoa; |
20 class Profile; | 21 class Profile; |
21 class ShellWindowCocoa; | 22 class ShellWindowCocoa; |
22 @class ShellNSWindow; | 23 @class ShellNSWindow; |
23 | 24 |
24 // A window controller for a minimal window to host a web app view. Passes | 25 // A window controller for a minimal window to host a web app view. Passes |
25 // Objective-C notifications to the C++ bridge. | 26 // Objective-C notifications to the C++ bridge. |
26 @interface ShellWindowController : NSWindowController | 27 @interface ShellWindowController : NSWindowController |
27 <NSWindowDelegate, | 28 <NSWindowDelegate, |
28 GTMWindowSheetControllerDelegate, | 29 GTMWindowSheetControllerDelegate, |
29 ConstrainedWindowSupport, | 30 ConstrainedWindowSupport, |
30 BrowserCommandExecutor> { | 31 BrowserCommandExecutor> { |
31 @private | 32 @private |
32 ShellWindowCocoa* shellWindow_; // Weak; owns self. | 33 ShellWindowCocoa* shellWindow_; // Weak; owns self. |
33 // Manages per-window sheets. | 34 // Manages per-window sheets. |
34 scoped_nsobject<GTMWindowSheetController> sheetController_; | 35 scoped_nsobject<GTMWindowSheetController> sheetController_; |
35 } | 36 } |
36 | 37 |
37 @property(assign, nonatomic) ShellWindowCocoa* shellWindow; | 38 @property(assign, nonatomic) ShellWindowCocoa* shellWindow; |
38 | 39 |
| 40 // 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 - (BOOL)handledByExtensionCommand:(NSEvent*)event; |
| 43 |
39 @end | 44 @end |
40 | 45 |
41 // Cocoa bridge to ShellWindow. | 46 // Cocoa bridge to ShellWindow. |
42 class ShellWindowCocoa : public NativeShellWindow { | 47 class ShellWindowCocoa : public NativeShellWindow { |
43 public: | 48 public: |
44 ShellWindowCocoa(ShellWindow* shell_window, | 49 ShellWindowCocoa(ShellWindow* shell_window, |
45 const ShellWindow::CreateParams& params); | 50 const ShellWindow::CreateParams& params); |
46 | 51 |
47 // BaseWindow implementation. | 52 // BaseWindow implementation. |
48 virtual bool IsActive() const OVERRIDE; | 53 virtual bool IsActive() const OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
66 | 71 |
67 // Called when the window is about to be closed. | 72 // Called when the window is about to be closed. |
68 void WindowWillClose(); | 73 void WindowWillClose(); |
69 | 74 |
70 // Called when the window is focused. | 75 // Called when the window is focused. |
71 void WindowDidBecomeKey(); | 76 void WindowDidBecomeKey(); |
72 | 77 |
73 // Called when the window is defocused. | 78 // Called when the window is defocused. |
74 void WindowDidResignKey(); | 79 void WindowDidResignKey(); |
75 | 80 |
| 81 // Called to handle a key event. |
| 82 bool HandledByExtensionCommand(NSEvent* event); |
| 83 |
76 protected: | 84 protected: |
77 // NativeShellWindow implementation. | 85 // NativeShellWindow implementation. |
78 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | 86 virtual void SetFullscreen(bool fullscreen) OVERRIDE; |
79 virtual bool IsFullscreenOrPending() const OVERRIDE; | 87 virtual bool IsFullscreenOrPending() const OVERRIDE; |
80 virtual void UpdateWindowTitle() OVERRIDE; | 88 virtual void UpdateWindowTitle() OVERRIDE; |
81 virtual void UpdateDraggableRegions( | 89 virtual void UpdateDraggableRegions( |
82 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 90 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
83 virtual void HandleKeyboardEvent( | 91 virtual void HandleKeyboardEvent( |
84 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 92 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
85 | 93 |
(...skipping 18 matching lines...) Expand all Loading... |
104 bool has_frame_; | 112 bool has_frame_; |
105 | 113 |
106 bool is_fullscreen_; | 114 bool is_fullscreen_; |
107 NSRect restored_bounds_; | 115 NSRect restored_bounds_; |
108 | 116 |
109 scoped_nsobject<ShellWindowController> window_controller_; | 117 scoped_nsobject<ShellWindowController> window_controller_; |
110 NSInteger attention_request_id_; // identifier from requestUserAttention | 118 NSInteger attention_request_id_; // identifier from requestUserAttention |
111 | 119 |
112 std::vector<extensions::DraggableRegion> draggable_regions_; | 120 std::vector<extensions::DraggableRegion> draggable_regions_; |
113 | 121 |
| 122 // The Extension Command Registry used to determine which keyboard events to |
| 123 // handle. |
| 124 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; |
| 125 |
114 DISALLOW_COPY_AND_ASSIGN(ShellWindowCocoa); | 126 DISALLOW_COPY_AND_ASSIGN(ShellWindowCocoa); |
115 }; | 127 }; |
116 | 128 |
117 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ | 129 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ |
OLD | NEW |