diff options
author | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 11:10:57 +0000 |
---|---|---|
committer | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 11:10:57 +0000 |
commit | 9b1aa8883af159110567975781eb48e4a4c04cfe (patch) | |
tree | b689571d768316e611fa74a144a7ae3cf44b47a1 | |
parent | 3f8a0f2cdec8c014c96ae63443ec1d1d15fd2960 (diff) | |
download | chromium_src-9b1aa8883af159110567975781eb48e4a4c04cfe.zip chromium_src-9b1aa8883af159110567975781eb48e4a4c04cfe.tar.gz chromium_src-9b1aa8883af159110567975781eb48e4a4c04cfe.tar.bz2 |
[mac] Add support for native frames for app windows.
Behind the --apps-use-native-frame flag.
BUG=225916
COLLABORATOR=jackhou@chromium.org
Review URL: https://chromiumcodereview.appspot.com/14769013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213834 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm | 58 |
2 files changed, 36 insertions, 23 deletions
diff --git a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h index 795dd6b..b9072a2 100644 --- a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h +++ b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h @@ -138,6 +138,7 @@ class NativeAppWindowCocoa : public NativeAppWindow { return shell_window_->extension(); } + NSUInteger GetWindowStyleMask() const; void InstallView(); void UninstallView(); void InstallDraggableRegionViews(); diff --git a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm index 7587df5..67611f4 100644 --- a/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.mm @@ -4,6 +4,7 @@ #include "chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h" +#include "base/command_line.h" #include "base/mac/mac_util.h" #include "base/strings/sys_string_conversions.h" #include "chrome/browser/profiles/profile.h" @@ -11,6 +12,7 @@ #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa.h" #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/notification_source.h" @@ -112,12 +114,17 @@ enum { @end @interface ShellNSWindow : ChromeEventProcessingWindow +@end +@implementation ShellNSWindow +@end + +@interface ShellCustomFrameNSWindow : ShellNSWindow - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view; @end -@implementation ShellNSWindow +@implementation ShellCustomFrameNSWindow - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view { [[NSBezierPath bezierPathWithRect:rect] addClip]; @@ -137,7 +144,7 @@ enum { @end -@interface ShellFramelessNSWindow : ShellNSWindow +@interface ShellFramelessNSWindow : ShellCustomFrameNSWindow @end @@ -230,25 +237,22 @@ NativeAppWindowCocoa::NativeAppWindowCocoa( } resizable_ = params.resizable; - NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSTexturedBackgroundWindowMask; - if (resizable_) - style_mask |= NSResizableWindowMask; base::scoped_nsobject<NSWindow> window; + Class window_class; if (has_frame_) { - window.reset([[ShellNSWindow alloc] - initWithContentRect:cocoa_bounds - styleMask:style_mask - backing:NSBackingStoreBuffered - defer:NO]); + bool should_use_native_frame = + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAppsUseNativeFrame); + window_class = should_use_native_frame ? + [ShellNSWindow class] : [ShellCustomFrameNSWindow class]; } else { - window.reset([[ShellFramelessNSWindow alloc] - initWithContentRect:cocoa_bounds - styleMask:style_mask - backing:NSBackingStoreBuffered - defer:NO]); + window_class = [ShellFramelessNSWindow class]; } + window.reset([[window_class alloc] + initWithContentRect:cocoa_bounds + styleMask:GetWindowStyleMask() + backing:NSBackingStoreBuffered + defer:NO]); [window setTitle:base::SysUTF8ToNSString(extension()->name())]; min_size_ = params.minimum_size; if (min_size_.width() || min_size_.height()) { @@ -298,6 +302,19 @@ NativeAppWindowCocoa::NativeAppWindowCocoa( shell_window)); } +NSUInteger NativeAppWindowCocoa::GetWindowStyleMask() const { + NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | + NSMiniaturizableWindowMask; + if (resizable_) + style_mask |= NSResizableWindowMask; + if (!has_frame_ || + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAppsUseNativeFrame)) { + style_mask |= NSTexturedBackgroundWindowMask; + } + return style_mask; +} + void NativeAppWindowCocoa::InstallView() { NSView* view = web_contents()->GetView()->GetNativeView(); if (has_frame_) { @@ -390,12 +407,7 @@ void NativeAppWindowCocoa::SetFullscreen(bool fullscreen) { base::mac::RequestFullScreen(base::mac::kFullScreenModeAutoHideAll); } else { base::mac::ReleaseFullScreen(base::mac::kFullScreenModeAutoHideAll); - NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSTexturedBackgroundWindowMask; - if (resizable_) - style_mask |= NSResizableWindowMask; - [window() setStyleMask:style_mask]; + [window() setStyleMask:GetWindowStyleMask()]; [window() setFrame:restored_bounds_ display:YES]; } InstallView(); |