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 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 - (void)setColor:(NSColor*)color | 239 - (void)setColor:(NSColor*)color |
240 inactiveColor:(NSColor*)inactiveColor { | 240 inactiveColor:(NSColor*)inactiveColor { |
241 color_.reset([color retain]); | 241 color_.reset([color retain]); |
242 inactiveColor_.reset([inactiveColor retain]); | 242 inactiveColor_.reset([inactiveColor retain]); |
243 } | 243 } |
244 | 244 |
245 @end | 245 @end |
246 | 246 |
247 // TODO(jamescook): Should these be AppNSWindow to match AppWindow? | 247 // TODO(jamescook): Should these be AppNSWindow to match AppWindow? |
248 // http://crbug.com/344082 | 248 // http://crbug.com/344082 |
249 @interface ShellNSWindow : ChromeEventProcessingWindow | 249 @interface AppNSWindow : ChromeEventProcessingWindow |
250 @end | 250 @end |
251 | 251 |
252 @implementation ShellNSWindow | 252 @implementation AppNSWindow |
253 | 253 |
254 // Similar to ChromeBrowserWindow, don't draw the title, but allow it to be seen | 254 // Similar to ChromeBrowserWindow, don't draw the title, but allow it to be seen |
255 // in menus, Expose, etc. | 255 // in menus, Expose, etc. |
256 - (BOOL)_isTitleHidden { | 256 - (BOOL)_isTitleHidden { |
257 return YES; | 257 return YES; |
258 } | 258 } |
259 | 259 |
260 @end | 260 @end |
261 | 261 |
262 @interface ShellFramelessNSWindow : ShellNSWindow | 262 @interface AppFramelessNSWindow : AppNSWindow |
263 @end | 263 @end |
264 | 264 |
265 @implementation ShellFramelessNSWindow | 265 @implementation AppFramelessNSWindow |
266 | 266 |
267 + (NSRect)frameRectForContentRect:(NSRect)contentRect | 267 + (NSRect)frameRectForContentRect:(NSRect)contentRect |
268 styleMask:(NSUInteger)mask { | 268 styleMask:(NSUInteger)mask { |
269 return contentRect; | 269 return contentRect; |
270 } | 270 } |
271 | 271 |
272 + (NSRect)contentRectForFrameRect:(NSRect)frameRect | 272 + (NSRect)contentRectForFrameRect:(NSRect)frameRect |
273 styleMask:(NSUInteger)mask { | 273 styleMask:(NSUInteger)mask { |
274 return frameRect; | 274 return frameRect; |
275 } | 275 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 is_resizable_(params.resizable), | 314 is_resizable_(params.resizable), |
315 shows_resize_controls_(true), | 315 shows_resize_controls_(true), |
316 shows_fullscreen_controls_(true), | 316 shows_fullscreen_controls_(true), |
317 has_frame_color_(params.has_frame_color), | 317 has_frame_color_(params.has_frame_color), |
318 active_frame_color_(params.active_frame_color), | 318 active_frame_color_(params.active_frame_color), |
319 inactive_frame_color_(params.inactive_frame_color) { | 319 inactive_frame_color_(params.inactive_frame_color) { |
320 Observe(WebContents()); | 320 Observe(WebContents()); |
321 | 321 |
322 base::scoped_nsobject<NSWindow> window; | 322 base::scoped_nsobject<NSWindow> window; |
323 Class window_class = has_frame_ ? | 323 Class window_class = has_frame_ ? |
324 [ShellNSWindow class] : [ShellFramelessNSWindow class]; | 324 [AppNSWindow class] : [AppFramelessNSWindow class]; |
325 | 325 |
326 // Estimate the initial bounds of the window. Once the frame insets are known, | 326 // Estimate the initial bounds of the window. Once the frame insets are known, |
327 // the window bounds and constraints can be set precisely. | 327 // the window bounds and constraints can be set precisely. |
328 NSRect cocoa_bounds = GfxToCocoaBounds( | 328 NSRect cocoa_bounds = GfxToCocoaBounds( |
329 params.GetInitialWindowBounds(gfx::Insets())); | 329 params.GetInitialWindowBounds(gfx::Insets())); |
330 window.reset([[window_class alloc] | 330 window.reset([[window_class alloc] |
331 initWithContentRect:cocoa_bounds | 331 initWithContentRect:cocoa_bounds |
332 styleMask:GetWindowStyleMask() | 332 styleMask:GetWindowStyleMask() |
333 backing:NSBackingStoreBuffered | 333 backing:NSBackingStoreBuffered |
334 defer:NO]); | 334 defer:NO]); |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 967 } |
968 | 968 |
969 void NativeAppWindowCocoa::SetInterceptAllKeys(bool want_all_key) { | 969 void NativeAppWindowCocoa::SetInterceptAllKeys(bool want_all_key) { |
970 // TODO(sriramsr): implement for OSX (http://crbug.com/166928). | 970 // TODO(sriramsr): implement for OSX (http://crbug.com/166928). |
971 NOTIMPLEMENTED(); | 971 NOTIMPLEMENTED(); |
972 } | 972 } |
973 | 973 |
974 NativeAppWindowCocoa::~NativeAppWindowCocoa() { | 974 NativeAppWindowCocoa::~NativeAppWindowCocoa() { |
975 } | 975 } |
976 | 976 |
977 ShellNSWindow* NativeAppWindowCocoa::window() const { | 977 AppNSWindow* NativeAppWindowCocoa::window() const { |
978 NSWindow* window = [window_controller_ window]; | 978 NSWindow* window = [window_controller_ window]; |
979 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 979 CHECK(!window || [window isKindOfClass:[AppNSWindow class]]); |
980 return static_cast<ShellNSWindow*>(window); | 980 return static_cast<AppNSWindow*>(window); |
981 } | 981 } |
982 | 982 |
983 content::WebContents* NativeAppWindowCocoa::WebContents() const { | 983 content::WebContents* NativeAppWindowCocoa::WebContents() const { |
984 return app_window_->web_contents(); | 984 return app_window_->web_contents(); |
985 } | 985 } |
986 | 986 |
987 void NativeAppWindowCocoa::UpdateRestoredBounds() { | 987 void NativeAppWindowCocoa::UpdateRestoredBounds() { |
988 if (IsRestored(*this)) | 988 if (IsRestored(*this)) |
989 restored_bounds_ = [window() frame]; | 989 restored_bounds_ = [window() frame]; |
990 } | 990 } |
991 | 991 |
992 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { | 992 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { |
993 [window() orderOut:window_controller_]; | 993 [window() orderOut:window_controller_]; |
994 } | 994 } |
OLD | NEW |