| 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 #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/cocoa/constrained_window_mac.h" | 14 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 15 #include "chrome/browser/ui/extensions/native_shell_window.h" | 15 #include "chrome/browser/ui/extensions/native_shell_window.h" |
| 16 #include "chrome/browser/ui/extensions/shell_window.h" | 16 #include "chrome/browser/ui/extensions/shell_window.h" |
| 17 #include "chrome/common/extensions/draggable_region.h" | 17 #include "chrome/common/extensions/draggable_region.h" |
| 18 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 18 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
| 19 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 20 | 20 |
| 21 class ExtensionKeybindingRegistryCocoa; | 21 class ExtensionKeybindingRegistryCocoa; |
| 22 class Profile; | 22 class Profile; |
| 23 class ShellWindowCocoa; | 23 class ShellWindowCocoa; |
| 24 @class ShellNSWindow; | 24 @class ShellNSWindow; |
| 25 class SkRegion; | |
| 26 | 25 |
| 27 // 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 |
| 28 // Objective-C notifications to the C++ bridge. | 27 // Objective-C notifications to the C++ bridge. |
| 29 @interface ShellWindowController : NSWindowController | 28 @interface ShellWindowController : NSWindowController |
| 30 <NSWindowDelegate, | 29 <NSWindowDelegate, |
| 31 GTMWindowSheetControllerDelegate, | 30 GTMWindowSheetControllerDelegate, |
| 32 ConstrainedWindowSupport, | 31 ConstrainedWindowSupport, |
| 33 BrowserCommandExecutor> { | 32 BrowserCommandExecutor> { |
| 34 @private | 33 @private |
| 35 ShellWindowCocoa* shellWindow_; // Weak; owns self. | 34 ShellWindowCocoa* shellWindow_; // Weak; owns self. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Called when the window is moved. | 85 // Called when the window is moved. |
| 87 void WindowDidMove(); | 86 void WindowDidMove(); |
| 88 | 87 |
| 89 // Called to handle a key event. | 88 // Called to handle a key event. |
| 90 bool HandledByExtensionCommand(NSEvent* event); | 89 bool HandledByExtensionCommand(NSEvent* event); |
| 91 | 90 |
| 92 // Called to handle a mouse event. | 91 // Called to handle a mouse event. |
| 93 void HandleMouseEvent(NSEvent* event); | 92 void HandleMouseEvent(NSEvent* event); |
| 94 | 93 |
| 95 bool use_system_drag() const { return use_system_drag_; } | 94 bool use_system_drag() const { return use_system_drag_; } |
| 96 SkRegion* draggable_region() const { return draggable_region_.get(); } | |
| 97 | 95 |
| 98 protected: | 96 protected: |
| 99 // NativeShellWindow implementation. | 97 // NativeShellWindow implementation. |
| 100 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | 98 virtual void SetFullscreen(bool fullscreen) OVERRIDE; |
| 101 virtual bool IsFullscreenOrPending() const OVERRIDE; | 99 virtual bool IsFullscreenOrPending() const OVERRIDE; |
| 102 virtual void UpdateWindowIcon() OVERRIDE; | 100 virtual void UpdateWindowIcon() OVERRIDE; |
| 103 virtual void UpdateWindowTitle() OVERRIDE; | 101 virtual void UpdateWindowTitle() OVERRIDE; |
| 104 virtual void UpdateDraggableRegions( | 102 virtual void UpdateDraggableRegions( |
| 105 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 103 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; |
| 106 virtual void UpdateLegacyDraggableRegions( | |
| 107 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | |
| 108 virtual void HandleKeyboardEvent( | 104 virtual void HandleKeyboardEvent( |
| 109 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 105 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 110 | 106 |
| 111 private: | 107 private: |
| 112 virtual ~ShellWindowCocoa(); | 108 virtual ~ShellWindowCocoa(); |
| 113 | 109 |
| 114 ShellNSWindow* window() const; | 110 ShellNSWindow* window() const; |
| 115 | 111 |
| 116 content::WebContents* web_contents() const { | 112 content::WebContents* web_contents() const { |
| 117 return shell_window_->web_contents(); | 113 return shell_window_->web_contents(); |
| 118 } | 114 } |
| 119 const extensions::Extension* extension() const { | 115 const extensions::Extension* extension() const { |
| 120 return shell_window_->extension(); | 116 return shell_window_->extension(); |
| 121 } | 117 } |
| 122 | 118 |
| 123 void InstallView(); | 119 void InstallView(); |
| 124 void UninstallView(); | 120 void UninstallView(); |
| 125 void InstallDraggableRegionViews(); | 121 void InstallDraggableRegionViews(); |
| 126 void UpdateDraggableRegionsForSystemDrag( | 122 void UpdateDraggableRegionsForSystemDrag( |
| 127 const std::vector<extensions::DraggableRegion>& regions, | 123 const std::vector<extensions::DraggableRegion>& regions, |
| 128 const extensions::DraggableRegion* draggable_area); | 124 const extensions::DraggableRegion* draggable_area); |
| 129 void UpdateDraggableRegionsForCustomDrag( | 125 void UpdateDraggableRegionsForCustomDrag( |
| 130 const std::vector<extensions::DraggableRegion>& regions); | 126 const std::vector<extensions::DraggableRegion>& regions); |
| 131 | 127 |
| 132 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow. | 128 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow. |
| 133 | 129 |
| 134 bool has_frame_; | |
| 135 | |
| 136 bool is_fullscreen_; | 130 bool is_fullscreen_; |
| 137 NSRect restored_bounds_; | 131 NSRect restored_bounds_; |
| 138 | 132 |
| 139 scoped_nsobject<ShellWindowController> window_controller_; | 133 scoped_nsobject<ShellWindowController> window_controller_; |
| 140 NSInteger attention_request_id_; // identifier from requestUserAttention | 134 NSInteger attention_request_id_; // identifier from requestUserAttention |
| 141 | 135 |
| 142 // Indicates whether system drag or custom drag should be used, depending on | 136 // Indicates whether system drag or custom drag should be used, depending on |
| 143 // the complexity of draggable regions. | 137 // the complexity of draggable regions. |
| 144 bool use_system_drag_; | 138 bool use_system_drag_; |
| 145 | 139 |
| 146 // For system drag, the whole window is draggable and the non-draggable areas | 140 // For system drag, the whole window is draggable and the non-draggable areas |
| 147 // have to been explicitly excluded. | 141 // have to been explicitly excluded. |
| 148 std::vector<gfx::Rect> system_drag_exclude_areas_; | 142 std::vector<gfx::Rect> system_drag_exclude_areas_; |
| 149 | 143 |
| 150 // For custom drag, the whole window is non-draggable and the draggable region | |
| 151 // has to been explicitly provided. | |
| 152 scoped_ptr<SkRegion> draggable_region_; // used in custom drag. | |
| 153 | |
| 154 // Mouse location since the last mouse event, in screen coordinates. This is | 144 // Mouse location since the last mouse event, in screen coordinates. This is |
| 155 // used in custom drag to compute the window movement. | 145 // used in custom drag to compute the window movement. |
| 156 NSPoint last_mouse_location_; | 146 NSPoint last_mouse_location_; |
| 157 | 147 |
| 158 // The Extension Command Registry used to determine which keyboard events to | 148 // The Extension Command Registry used to determine which keyboard events to |
| 159 // handle. | 149 // handle. |
| 160 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; | 150 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_; |
| 161 | 151 |
| 162 DISALLOW_COPY_AND_ASSIGN(ShellWindowCocoa); | 152 DISALLOW_COPY_AND_ASSIGN(ShellWindowCocoa); |
| 163 }; | 153 }; |
| 164 | 154 |
| 165 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ | 155 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_ |
| OLD | NEW |