@@ -295,11 +295,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
295295 }
296296
297297 NSUInteger styleMask = NSTitledWindowMask ;
298- if (@available (macOS 10.10 , *)) {
299- if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
300- (!useStandardWindow || transparent () || !has_frame ())) {
301- styleMask = NSFullSizeContentViewWindowMask ;
302- }
298+ if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
299+ (!useStandardWindow || transparent () || !has_frame ())) {
300+ styleMask = NSFullSizeContentViewWindowMask ;
303301 }
304302 if (minimizable) {
305303 styleMask |= NSMiniaturizableWindowMask ;
@@ -354,11 +352,10 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
354352 [window_ setDisableKeyOrMainWindow: YES ];
355353
356354 if (transparent () || !has_frame ()) {
357- if (@available (macOS 10.10 , *)) {
358- // Don't show title bar.
359- [window_ setTitlebarAppearsTransparent: YES ];
360- [window_ setTitleVisibility: NSWindowTitleHidden];
361- }
355+ // Don't show title bar.
356+ [window_ setTitlebarAppearsTransparent: YES ];
357+ [window_ setTitleVisibility: NSWindowTitleHidden];
358+
362359 // Remove non-transparent corners, see http://git.io/vfonD.
363360 [window_ setOpaque: NO ];
364361 }
@@ -377,22 +374,15 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
377374
378375 // Hide the title bar background
379376 if (title_bar_style_ != NORMAL) {
380- if (@available (macOS 10.10 , *)) {
381- [window_ setTitlebarAppearsTransparent: YES ];
382- }
377+ [window_ setTitlebarAppearsTransparent: YES ];
383378 }
384379
385380 // Hide the title bar.
386381 if (title_bar_style_ == HIDDEN_INSET) {
387- if (@available (macOS 10.10 , *)) {
388- base::scoped_nsobject<NSToolbar > toolbar (
389- [[NSToolbar alloc ] initWithIdentifier: @" titlebarStylingToolbar" ]);
390- [toolbar setShowsBaselineSeparator: NO ];
391- [window_ setToolbar: toolbar];
392- } else {
393- [window_ enableWindowButtonsOffset ];
394- [window_ setWindowButtonsOffset: NSMakePoint (12 , 10 )];
395- }
382+ base::scoped_nsobject<NSToolbar > toolbar (
383+ [[NSToolbar alloc ] initWithIdentifier: @" titlebarStylingToolbar" ]);
384+ [toolbar setShowsBaselineSeparator: NO ];
385+ [window_ setToolbar: toolbar];
396386 }
397387
398388 // Resize to content bounds.
@@ -445,9 +435,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
445435 SetContentView (new views::View ());
446436
447437 // Make sure the bottom corner is rounded for non-modal windows:
448- // http://crbug.com/396264. But do not enable it on OS X 10.9 for transparent
449- // window, otherwise a semi-transparent frame would show.
450- if (!(transparent () && base::mac::IsOS10_9 ()) && !is_modal ()) {
438+ // http://crbug.com/396264.
439+ if (!is_modal ()) {
451440 base::scoped_nsobject<CALayer > background_layer ([[CALayer alloc ] init ]);
452441 [background_layer
453442 setAutoresizingMask: kCALayerWidthSizable | kCALayerHeightSizable ];
@@ -479,11 +468,6 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
479468 [[window_ contentView ] addSubview: buttons_view_];
480469 } else {
481470 if (title_bar_style_ != NORMAL) {
482- if (base::mac::IsOS10_9 ()) {
483- ShowWindowButton (NSWindowZoomButton);
484- ShowWindowButton (NSWindowMiniaturizeButton);
485- ShowWindowButton (NSWindowCloseButton);
486- }
487471 return ;
488472 }
489473
@@ -858,17 +842,11 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
858842}
859843
860844void NativeWindowMac::SetTitle (const std::string& title) {
861- // For macOS <= 10.9, the setTitleVisibility API is not available, we have
862- // to avoid calling setTitle for frameless window.
863- if (!base::mac::IsAtLeastOS10_10 () && (transparent () || !has_frame ()))
864- return ;
865-
866845 [window_ setTitle: base: :SysUTF8ToNSString (title)];
867846}
868847
869848std::string NativeWindowMac::GetTitle () {
870849 return base::SysNSStringToUTF8 ([window_ title ]);
871- ;
872850}
873851
874852void NativeWindowMac::FlashFrame (bool flash) {
@@ -1178,86 +1156,83 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
11781156}
11791157
11801158void NativeWindowMac::SetVibrancy (const std::string& type) {
1181- if (@available (macOS 10.10 , *)) {
1182- NSView * vibrant_view = [window_ vibrantView ];
1159+ NSView * vibrant_view = [window_ vibrantView ];
11831160
1184- if (type.empty ()) {
1185- if (background_color_before_vibrancy_) {
1186- [window_ setBackgroundColor: background_color_before_vibrancy_];
1187- [window_ setTitlebarAppearsTransparent: transparency_before_vibrancy_];
1188- }
1189- if (vibrant_view == nil )
1190- return ;
1161+ if (type.empty ()) {
1162+ if (background_color_before_vibrancy_) {
1163+ [window_ setBackgroundColor: background_color_before_vibrancy_];
1164+ [window_ setTitlebarAppearsTransparent: transparency_before_vibrancy_];
1165+ }
1166+ if (vibrant_view == nil )
1167+ return ;
11911168
1192- [vibrant_view removeFromSuperview ];
1193- [window_ setVibrantView: nil ];
1194- ui::GpuSwitchingManager::SetTransparent (transparent ());
1169+ [vibrant_view removeFromSuperview ];
1170+ [window_ setVibrantView: nil ];
1171+ ui::GpuSwitchingManager::SetTransparent (transparent ());
11951172
1196- return ;
1197- }
1173+ return ;
1174+ }
11981175
1199- background_color_before_vibrancy_.reset ([[window_ backgroundColor ] retain ]);
1200- transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent ];
1201- ui::GpuSwitchingManager::SetTransparent (true );
1176+ background_color_before_vibrancy_.reset ([[window_ backgroundColor ] retain ]);
1177+ transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent ];
1178+ ui::GpuSwitchingManager::SetTransparent (true );
12021179
1203- if (title_bar_style_ != NORMAL) {
1204- [window_ setTitlebarAppearsTransparent: YES ];
1205- [window_ setBackgroundColor: [NSColor clearColor ]];
1206- }
1180+ if (title_bar_style_ != NORMAL) {
1181+ [window_ setTitlebarAppearsTransparent: YES ];
1182+ [window_ setBackgroundColor: [NSColor clearColor ]];
1183+ }
12071184
1208- NSVisualEffectView * effect_view = (NSVisualEffectView *)vibrant_view;
1209- if (effect_view == nil ) {
1210- effect_view = [[[NSVisualEffectView alloc ]
1211- initWithFrame: [[window_ contentView ] bounds ]] autorelease ];
1212- [window_ setVibrantView: (NSView *)effect_view];
1213-
1214- [effect_view
1215- setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
1216- [effect_view setBlendingMode: NSVisualEffectBlendingModeBehindWindow];
1217- [effect_view setState: NSVisualEffectStateActive];
1218- [[window_ contentView ] addSubview: effect_view
1219- positioned: NSWindowBelow
1220- relativeTo: nil ];
1221- }
1185+ NSVisualEffectView * effect_view = (NSVisualEffectView *)vibrant_view;
1186+ if (effect_view == nil ) {
1187+ effect_view = [[[NSVisualEffectView alloc ]
1188+ initWithFrame: [[window_ contentView ] bounds ]] autorelease ];
1189+ [window_ setVibrantView: (NSView *)effect_view];
1190+
1191+ [effect_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
1192+ [effect_view setBlendingMode: NSVisualEffectBlendingModeBehindWindow];
1193+ [effect_view setState: NSVisualEffectStateActive];
1194+ [[window_ contentView ] addSubview: effect_view
1195+ positioned: NSWindowBelow
1196+ relativeTo: nil ];
1197+ }
12221198
1223- NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight ;
1199+ NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight ;
12241200
1225- if (type == " appearance-based" ) {
1226- vibrancyType = NSVisualEffectMaterialAppearanceBased ;
1227- } else if (type == " light" ) {
1228- vibrancyType = NSVisualEffectMaterialLight ;
1229- } else if (type == " dark" ) {
1230- vibrancyType = NSVisualEffectMaterialDark ;
1231- } else if (type == " titlebar" ) {
1232- vibrancyType = NSVisualEffectMaterialTitlebar;
1233- }
1201+ if (type == " appearance-based" ) {
1202+ vibrancyType = NSVisualEffectMaterialAppearanceBased ;
1203+ } else if (type == " light" ) {
1204+ vibrancyType = NSVisualEffectMaterialLight ;
1205+ } else if (type == " dark" ) {
1206+ vibrancyType = NSVisualEffectMaterialDark ;
1207+ } else if (type == " titlebar" ) {
1208+ vibrancyType = NSVisualEffectMaterialTitlebar;
1209+ }
12341210
1235- if (@available (macOS 10.11 , *)) {
1236- // TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
1237- // they are available in the minimum SDK version
1238- if (type == " selection" ) {
1239- // NSVisualEffectMaterialSelection
1240- vibrancyType = static_cast <NSVisualEffectMaterial >(4 );
1241- } else if (type == " menu" ) {
1242- // NSVisualEffectMaterialMenu
1243- vibrancyType = static_cast <NSVisualEffectMaterial >(5 );
1244- } else if (type == " popover" ) {
1245- // NSVisualEffectMaterialPopover
1246- vibrancyType = static_cast <NSVisualEffectMaterial >(6 );
1247- } else if (type == " sidebar" ) {
1248- // NSVisualEffectMaterialSidebar
1249- vibrancyType = static_cast <NSVisualEffectMaterial >(7 );
1250- } else if (type == " medium-light" ) {
1251- // NSVisualEffectMaterialMediumLight
1252- vibrancyType = static_cast <NSVisualEffectMaterial >(8 );
1253- } else if (type == " ultra-dark" ) {
1254- // NSVisualEffectMaterialUltraDark
1255- vibrancyType = static_cast <NSVisualEffectMaterial >(9 );
1256- }
1211+ if (@available (macOS 10.11 , *)) {
1212+ // TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
1213+ // they are available in the minimum SDK version
1214+ if (type == " selection" ) {
1215+ // NSVisualEffectMaterialSelection
1216+ vibrancyType = static_cast <NSVisualEffectMaterial >(4 );
1217+ } else if (type == " menu" ) {
1218+ // NSVisualEffectMaterialMenu
1219+ vibrancyType = static_cast <NSVisualEffectMaterial >(5 );
1220+ } else if (type == " popover" ) {
1221+ // NSVisualEffectMaterialPopover
1222+ vibrancyType = static_cast <NSVisualEffectMaterial >(6 );
1223+ } else if (type == " sidebar" ) {
1224+ // NSVisualEffectMaterialSidebar
1225+ vibrancyType = static_cast <NSVisualEffectMaterial >(7 );
1226+ } else if (type == " medium-light" ) {
1227+ // NSVisualEffectMaterialMediumLight
1228+ vibrancyType = static_cast <NSVisualEffectMaterial >(8 );
1229+ } else if (type == " ultra-dark" ) {
1230+ // NSVisualEffectMaterialUltraDark
1231+ vibrancyType = static_cast <NSVisualEffectMaterial >(9 );
12571232 }
1258-
1259- [effect_view setMaterial: vibrancyType];
12601233 }
1234+
1235+ [effect_view setMaterial: vibrancyType];
12611236}
12621237
12631238void NativeWindowMac::SetTouchBar (
@@ -1341,11 +1316,6 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
13411316 [parent->GetNativeWindow () addChildWindow: window_ ordered: NSWindowAbove];
13421317}
13431318
1344- void NativeWindowMac::ShowWindowButton (NSWindowButton button) {
1345- auto view = [window_ standardWindowButton: button];
1346- [view.superview addSubview: view positioned: NSWindowAbove relativeTo: nil ];
1347- }
1348-
13491319void NativeWindowMac::SetForwardMouseMessages (bool forward) {
13501320 [window_ setAcceptsMouseMovedEvents: forward];
13511321}
0 commit comments