Commit f1a974db authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Mac: Add command line switch to force dark mode

Bug: 850098
Change-Id: I8d18484774982a8ec0272f62f0bd77a43668eb0d
Reviewed-on: https://chromium-review.googlesource.com/1238796Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593347}
parent fa6ab7df
...@@ -338,6 +338,20 @@ typedef NSString* VNBarcodeSymbology NS_STRING_ENUM; ...@@ -338,6 +338,20 @@ typedef NSString* VNBarcodeSymbology NS_STRING_ENUM;
@end @end
#endif // MAC_OS_X_VERSION_10_13 #endif // MAC_OS_X_VERSION_10_13
// Once Chrome no longer supports macOS 10.13, everything within this
// preprocessor block can be removed.
#if !defined(MAC_OS_X_VERSION_10_14) || \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
@interface NSApplication (ForwardDeclare)
@property(strong) NSAppearance* appearance;
@end
BASE_EXPORT extern NSString* const NSAppearanceNameDarkAqua;
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// The symbol for kCWSSIDDidChangeNotification is available in the // The symbol for kCWSSIDDidChangeNotification is available in the
// CoreWLAN.framework for OSX versions 10.6 through 10.10. The symbol is not // CoreWLAN.framework for OSX versions 10.6 through 10.10. The symbol is not
......
...@@ -18,3 +18,8 @@ NSString* const NSAppearanceNameVibrantDark = @"NSAppearanceNameVibrantDark"; ...@@ -18,3 +18,8 @@ NSString* const NSAppearanceNameVibrantDark = @"NSAppearanceNameVibrantDark";
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
NSString* const CIDetectorTypeText = @"CIDetectorTypeText"; NSString* const CIDetectorTypeText = @"CIDetectorTypeText";
#endif // MAC_OS_X_VERSION_10_11 #endif // MAC_OS_X_VERSION_10_11
#if !defined(MAC_OS_X_VERSION_10_14) || \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
NSString* const NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
#endif
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/call_with_eh_frame.h" #include "base/mac/call_with_eh_frame.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/native_event_processor_mac.h" #include "content/public/browser/native_event_processor_mac.h"
#include "content/public/browser/native_event_processor_observer_mac.h" #include "content/public/browser/native_event_processor_observer_mac.h"
#include "ui/base/ui_base_switches.h"
namespace chrome_browser_application_mac { namespace chrome_browser_application_mac {
...@@ -120,6 +122,12 @@ std::string DescriptionForNSEvent(NSEvent* event) { ...@@ -120,6 +122,12 @@ std::string DescriptionForNSEvent(NSEvent* event) {
- (id)init { - (id)init {
self = [super init]; self = [super init];
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForceDarkMode)) {
if (@available(macOS 10.14, *)) {
self.appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
}
}
// Sanity check to alert if overridden methods are not supported. // Sanity check to alert if overridden methods are not supported.
DCHECK([NSApplication DCHECK([NSApplication
......
...@@ -48,6 +48,9 @@ const char kEnableTouchDragDrop[] = "enable-touch-drag-drop"; ...@@ -48,6 +48,9 @@ const char kEnableTouchDragDrop[] = "enable-touch-drag-drop";
const char kEnableTouchableAppContextMenu[] = const char kEnableTouchableAppContextMenu[] =
"enable-touchable-app-context-menus"; "enable-touchable-app-context-menus";
// Forces dark mode in UI for platforms that support it.
const char kForceDarkMode[] = "force-dark-mode";
// Forces high-contrast mode in native UI drawing, regardless of system // Forces high-contrast mode in native UI drawing, regardless of system
// settings. Note that this has limited effect on Windows: only Aura colors will // settings. Note that this has limited effect on Windows: only Aura colors will
// be switched to high contrast, not other system colors. // be switched to high contrast, not other system colors.
......
...@@ -27,6 +27,7 @@ UI_BASE_EXPORT extern const char kDisableTouchAdjustment[]; ...@@ -27,6 +27,7 @@ UI_BASE_EXPORT extern const char kDisableTouchAdjustment[];
UI_BASE_EXPORT extern const char kDisableTouchDragDrop[]; UI_BASE_EXPORT extern const char kDisableTouchDragDrop[];
UI_BASE_EXPORT extern const char kEnableTouchDragDrop[]; UI_BASE_EXPORT extern const char kEnableTouchDragDrop[];
UI_BASE_EXPORT extern const char kEnableTouchableAppContextMenu[]; UI_BASE_EXPORT extern const char kEnableTouchableAppContextMenu[];
UI_BASE_EXPORT extern const char kForceDarkMode[];
UI_BASE_EXPORT extern const char kForceHighContrast[]; UI_BASE_EXPORT extern const char kForceHighContrast[];
UI_BASE_EXPORT extern const char kLang[]; UI_BASE_EXPORT extern const char kLang[];
UI_BASE_EXPORT extern const char kMaterialDesignInkDropAnimationSpeed[]; UI_BASE_EXPORT extern const char kMaterialDesignInkDropAnimationSpeed[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment