Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h

Issue 11280173: Rename ShellWindow* classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fix Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_
7
8 #import <Cocoa/Cocoa.h>
9 #include <vector>
10
11 #include "base/memory/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
13 #import "chrome/browser/ui/cocoa/browser_command_executor.h"
14 #include "chrome/browser/ui/cocoa/constrained_window_mac.h"
15 #include "chrome/browser/ui/extensions/native_shell_window.h"
16 #include "chrome/browser/ui/extensions/shell_window.h"
17 #include "chrome/common/extensions/draggable_region.h"
18 #import "third_party/GTM/AppKit/GTMWindowSheetController.h"
19 #include "ui/gfx/rect.h"
20
21 class ExtensionKeybindingRegistryCocoa;
22 class Profile;
23 class ShellWindowCocoa;
24 @class ShellNSWindow;
25 class SkRegion;
26
27 // A window controller for a minimal window to host a web app view. Passes
28 // Objective-C notifications to the C++ bridge.
29 @interface ShellWindowController : NSWindowController
30 <NSWindowDelegate,
31 GTMWindowSheetControllerDelegate,
32 ConstrainedWindowSupport,
33 BrowserCommandExecutor> {
34 @private
35 ShellWindowCocoa* shellWindow_; // Weak; owns self.
36 // Manages per-window sheets.
37 scoped_nsobject<GTMWindowSheetController> sheetController_;
38 }
39
40 @property(assign, nonatomic) ShellWindowCocoa* shellWindow;
41
42 // Consults the Command Registry to see if this |event| needs to be handled as
43 // an extension command and returns YES if so (NO otherwise).
44 - (BOOL)handledByExtensionCommand:(NSEvent*)event;
45
46 @end
47
48 // Cocoa bridge to ShellWindow.
49 class ShellWindowCocoa : public NativeShellWindow {
50 public:
51 ShellWindowCocoa(ShellWindow* shell_window,
52 const ShellWindow::CreateParams& params);
53
54 // BaseWindow implementation.
55 virtual bool IsActive() const OVERRIDE;
56 virtual bool IsMaximized() const OVERRIDE;
57 virtual bool IsMinimized() const OVERRIDE;
58 virtual bool IsFullscreen() const OVERRIDE;
59 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
60 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
61 virtual gfx::Rect GetBounds() const OVERRIDE;
62 virtual void Show() OVERRIDE;
63 virtual void ShowInactive() OVERRIDE;
64 virtual void Hide() OVERRIDE;
65 virtual void Close() OVERRIDE;
66 virtual void Activate() OVERRIDE;
67 virtual void Deactivate() OVERRIDE;
68 virtual void Maximize() OVERRIDE;
69 virtual void Minimize() OVERRIDE;
70 virtual void Restore() OVERRIDE;
71 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
72 virtual void FlashFrame(bool flash) OVERRIDE;
73 virtual bool IsAlwaysOnTop() const OVERRIDE;
74
75 // Called when the window is about to be closed.
76 void WindowWillClose();
77
78 // Called when the window is focused.
79 void WindowDidBecomeKey();
80
81 // Called when the window is defocused.
82 void WindowDidResignKey();
83
84 // Called when the window is resized.
85 void WindowDidResize();
86
87 // Called when the window is moved.
88 void WindowDidMove();
89
90 // Called to handle a key event.
91 bool HandledByExtensionCommand(NSEvent* event);
92
93 // Called to handle a mouse event.
94 void HandleMouseEvent(NSEvent* event);
95
96 // Returns true if |point| in local Cocoa coordinate system falls within
97 // the draggable region.
98 bool IsWithinDraggableRegion(NSPoint point) const;
99
100 bool use_system_drag() const { return use_system_drag_; }
101
102 protected:
103 // NativeShellWindow implementation.
104 virtual void SetFullscreen(bool fullscreen) OVERRIDE;
105 virtual bool IsFullscreenOrPending() const OVERRIDE;
106 virtual void UpdateWindowIcon() OVERRIDE;
107 virtual void UpdateWindowTitle() OVERRIDE;
108 virtual void UpdateDraggableRegions(
109 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
110 virtual void HandleKeyboardEvent(
111 const content::NativeWebKeyboardEvent& event) OVERRIDE;
112 virtual void RenderViewHostChanged() OVERRIDE {}
113
114 private:
115 virtual ~ShellWindowCocoa();
116
117 ShellNSWindow* window() const;
118
119 content::WebContents* web_contents() const {
120 return shell_window_->web_contents();
121 }
122 const extensions::Extension* extension() const {
123 return shell_window_->extension();
124 }
125
126 void InstallView();
127 void UninstallView();
128 void InstallDraggableRegionViews();
129 void UpdateDraggableRegionsForSystemDrag(
130 const std::vector<extensions::DraggableRegion>& regions,
131 const extensions::DraggableRegion* draggable_area);
132 void UpdateDraggableRegionsForCustomDrag(
133 const std::vector<extensions::DraggableRegion>& regions);
134
135 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow.
136
137 bool has_frame_;
138
139 bool is_fullscreen_;
140 NSRect restored_bounds_;
141
142 gfx::Size min_size_;
143 gfx::Size max_size_;
144
145 scoped_nsobject<ShellWindowController> window_controller_;
146 NSInteger attention_request_id_; // identifier from requestUserAttention
147
148 // Indicates whether system drag or custom drag should be used, depending on
149 // the complexity of draggable regions.
150 bool use_system_drag_;
151
152 // For system drag, the whole window is draggable and the non-draggable areas
153 // have to been explicitly excluded.
154 std::vector<gfx::Rect> system_drag_exclude_areas_;
155
156 // For custom drag, the whole window is non-draggable and the draggable region
157 // has to been explicitly provided.
158 scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
159
160 // Mouse location since the last mouse event, in screen coordinates. This is
161 // used in custom drag to compute the window movement.
162 NSPoint last_mouse_location_;
163
164 // The Extension Command Registry used to determine which keyboard events to
165 // handle.
166 scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_;
167
168 DISALLOW_COPY_AND_ASSIGN(ShellWindowCocoa);
169 };
170
171 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_SHELL_WINDOW_COCOA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698