| 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_NATIVE_APP_WINDOW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_NATIVE_APP_WINDOW_COCOA_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_NATIVE_APP_WINDOW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_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 "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | 13 #import "chrome/browser/ui/cocoa/browser_command_executor.h" |
| 14 #include "chrome/browser/ui/extensions/native_app_window.h" | 14 #include "chrome/browser/ui/extensions/native_app_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 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" |
| 17 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 18 | 20 |
| 19 class ExtensionKeybindingRegistryCocoa; | 21 class ExtensionKeybindingRegistryCocoa; |
| 20 class Profile; | 22 class Profile; |
| 21 class NativeAppWindowCocoa; | 23 class NativeAppWindowCocoa; |
| 22 @class ShellNSWindow; | 24 @class ShellNSWindow; |
| 23 class SkRegion; | 25 class SkRegion; |
| 24 | 26 |
| 25 // A window controller for a minimal window to host a web app view. Passes | 27 // A window controller for a minimal window to host a web app view. Passes |
| 26 // Objective-C notifications to the C++ bridge. | 28 // Objective-C notifications to the C++ bridge. |
| 27 @interface NativeAppWindowController : NSWindowController | 29 @interface NativeAppWindowController : NSWindowController |
| 28 <NSWindowDelegate, | 30 <NSWindowDelegate, |
| 29 BrowserCommandExecutor> { | 31 BrowserCommandExecutor> { |
| 30 @private | 32 @private |
| 31 NativeAppWindowCocoa* appWindow_; // Weak; owns self. | 33 NativeAppWindowCocoa* appWindow_; // Weak; owns self. |
| 32 } | 34 } |
| 33 | 35 |
| 34 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; | 36 @property(assign, nonatomic) NativeAppWindowCocoa* appWindow; |
| 35 | 37 |
| 36 // Consults the Command Registry to see if this |event| needs to be handled as | 38 // Consults the Command Registry to see if this |event| needs to be handled as |
| 37 // an extension command and returns YES if so (NO otherwise). | 39 // an extension command and returns YES if so (NO otherwise). |
| 38 - (BOOL)handledByExtensionCommand:(NSEvent*)event; | 40 - (BOOL)handledByExtensionCommand:(NSEvent*)event; |
| 39 | 41 |
| 40 @end | 42 @end |
| 41 | 43 |
| 42 // Cocoa bridge to AppWindow. | 44 // Cocoa bridge to AppWindow. |
| 43 class NativeAppWindowCocoa : public NativeAppWindow { | 45 class NativeAppWindowCocoa : public NativeAppWindow, |
| 46 public content::NotificationObserver { |
| 44 public: | 47 public: |
| 45 NativeAppWindowCocoa(ShellWindow* shell_window, | 48 NativeAppWindowCocoa(ShellWindow* shell_window, |
| 46 const ShellWindow::CreateParams& params); | 49 const ShellWindow::CreateParams& params); |
| 47 | 50 |
| 48 // BaseWindow implementation. | 51 // BaseWindow implementation. |
| 49 virtual bool IsActive() const OVERRIDE; | 52 virtual bool IsActive() const OVERRIDE; |
| 50 virtual bool IsMaximized() const OVERRIDE; | 53 virtual bool IsMaximized() const OVERRIDE; |
| 51 virtual bool IsMinimized() const OVERRIDE; | 54 virtual bool IsMinimized() const OVERRIDE; |
| 52 virtual bool IsFullscreen() const OVERRIDE; | 55 virtual bool IsFullscreen() const OVERRIDE; |
| 53 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 56 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 129 |
| 127 void InstallView(); | 130 void InstallView(); |
| 128 void UninstallView(); | 131 void UninstallView(); |
| 129 void InstallDraggableRegionViews(); | 132 void InstallDraggableRegionViews(); |
| 130 void UpdateDraggableRegionsForSystemDrag( | 133 void UpdateDraggableRegionsForSystemDrag( |
| 131 const std::vector<extensions::DraggableRegion>& regions, | 134 const std::vector<extensions::DraggableRegion>& regions, |
| 132 const extensions::DraggableRegion* draggable_area); | 135 const extensions::DraggableRegion* draggable_area); |
| 133 void UpdateDraggableRegionsForCustomDrag( | 136 void UpdateDraggableRegionsForCustomDrag( |
| 134 const std::vector<extensions::DraggableRegion>& regions); | 137 const std::vector<extensions::DraggableRegion>& regions); |
| 135 | 138 |
| 139 // Overridden from content::NotificationObserver: |
| 140 virtual void Observe(int type, |
| 141 const content::NotificationSource& source, |
| 142 const content::NotificationDetails& details) OVERRIDE; |
| 143 |
| 136 ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. | 144 ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. |
| 137 | 145 |
| 138 bool has_frame_; | 146 bool has_frame_; |
| 139 | 147 |
| 140 bool is_fullscreen_; | 148 bool is_fullscreen_; |
| 141 NSRect restored_bounds_; | 149 NSRect restored_bounds_; |
| 142 | 150 |
| 143 gfx::Size min_size_; | 151 gfx::Size min_size_; |
| 144 gfx::Size max_size_; | 152 gfx::Size max_size_; |
| 145 | 153 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 159 scoped_ptr<SkRegion> draggable_region_; // used in custom drag. | 167 scoped_ptr<SkRegion> draggable_region_; // used in custom drag. |
| 160 | 168 |
| 161 // Mouse location since the last mouse event, in screen coordinates. This is | 169 // Mouse location since the last mouse event, in screen coordinates. This is |
| 162 // used in custom drag to compute the window movement. | 170 // used in custom drag to compute the window movement. |
| 163 NSPoint last_mouse_location_; | 171 NSPoint last_mouse_location_; |
| 164 | 172 |
| 165 // The Extension Command Registry used to determine which keyboard events to | 173 // The Extension Command Registry used to determine which keyboard events to |
| 166 // handle. | 174 // handle. |
| 167 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; | 175 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; |
| 168 | 176 |
| 177 content::NotificationRegistrar registrar_; |
| 178 |
| 169 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); | 179 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoa); |
| 170 }; | 180 }; |
| 171 | 181 |
| 172 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_NATIVE_APP_WINDOW_COCOA_H_ | 182 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_NATIVE_APP_WINDOW_COCOA_H_ |
| OLD | NEW |