Commit 1e2eb1df authored by Aran Gilman's avatar Aran Gilman Committed by Commit Bot

Add darkModeEnabled Blink setting.

Bug: 1002664
Change-Id: If9515337d146721919edb3add59d205f1786d6a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795999
Commit-Queue: Aran Gilman <gilmanmh@google.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696970}
parent d3dd348e
...@@ -39,6 +39,13 @@ bool HasLightBackground(const LayoutView& root) { ...@@ -39,6 +39,13 @@ bool HasLightBackground(const LayoutView& root) {
kBrightnessThreshold; kBrightnessThreshold;
} }
bool IsDarkModeEnabled(const Settings& frame_settings) {
static bool isDarkModeEnabledByFeatureFlag =
features::kForceDarkInversionMethodParam.Get() !=
ForceDarkInversionMethod::kUseBlinkSettings;
return isDarkModeEnabledByFeatureFlag || frame_settings.GetDarkModeEnabled();
}
DarkModeInversionAlgorithm GetMode(const Settings& frame_settings) { DarkModeInversionAlgorithm GetMode(const Settings& frame_settings) {
switch (features::kForceDarkInversionMethodParam.Get()) { switch (features::kForceDarkInversionMethodParam.Get()) {
case ForceDarkInversionMethod::kUseBlinkSettings: case ForceDarkInversionMethod::kUseBlinkSettings:
...@@ -129,7 +136,8 @@ const DarkModeSettings& GetCachedDisabledSettings() { ...@@ -129,7 +136,8 @@ const DarkModeSettings& GetCachedDisabledSettings() {
DarkModeSettings BuildDarkModeSettings(const Settings& frame_settings, DarkModeSettings BuildDarkModeSettings(const Settings& frame_settings,
const LayoutView& root) { const LayoutView& root) {
if (ShouldApplyDarkModeFilterToPage(frame_settings.GetDarkModePagePolicy(), if (IsDarkModeEnabled(frame_settings) &&
ShouldApplyDarkModeFilterToPage(frame_settings.GetDarkModePagePolicy(),
root)) { root)) {
return GetCachedEnabledSettings(frame_settings); return GetCachedEnabledSettings(frame_settings);
} }
......
...@@ -107,14 +107,7 @@ void Settings::SetForceDarkModeEnabled(bool enabled) { ...@@ -107,14 +107,7 @@ void Settings::SetForceDarkModeEnabled(bool enabled) {
if (force_dark_mode_ == enabled) if (force_dark_mode_ == enabled)
return; return;
force_dark_mode_ = enabled; force_dark_mode_ = enabled;
SetDarkModeEnabled(force_dark_mode_);
if (force_dark_mode_) {
SetDarkModeInversionAlgorithm(
DarkModeInversionAlgorithm::kInvertLightnessLAB);
SetDarkModeImagePolicy(DarkModeImagePolicy::kFilterSmart);
} else {
SetDarkModeInversionAlgorithm(DarkModeInversionAlgorithm::kOff);
}
Invalidate(SettingsDelegate::kColorSchemeChange); Invalidate(SettingsDelegate::kColorSchemeChange);
} }
......
...@@ -882,9 +882,14 @@ ...@@ -882,9 +882,14 @@
// //
// Dark mode // Dark mode
// //
{
name: "darkModeEnabled",
initial: false,
invalidate: "Paint",
},
{ {
name: "darkModeInversionAlgorithm", name: "darkModeInversionAlgorithm",
initial: "DarkModeInversionAlgorithm::kOff", initial: "DarkModeInversionAlgorithm::kInvertLightnessLAB",
type: "DarkModeInversionAlgorithm", type: "DarkModeInversionAlgorithm",
invalidate: "Paint", invalidate: "Paint",
}, },
......
...@@ -439,47 +439,47 @@ ...@@ -439,47 +439,47 @@
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/grayscale-images", "base": "paint/dark-mode/grayscale-images",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeImageStyle=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeImageStyle=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/image-filter-all", "base": "paint/dark-mode/image-filter-all",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/image-filter-none", "base": "paint/dark-mode/image-filter-none",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeImagePolicy=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeImagePolicy=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/image-filter-smart", "base": "paint/dark-mode/image-filter-smart",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeImagePolicy=2,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeImagePolicy=2,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/native-theme-off", "base": "paint/dark-mode/native-theme-off",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/native-theme-on", "base": "paint/dark-mode/native-theme-on",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/page-policy-all", "base": "paint/dark-mode/page-policy-all",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModePagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModePagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/page-policy-background", "base": "paint/dark-mode/page-policy-background",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModePagePolicy=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModePagePolicy=1,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "dark-mode", "prefix": "dark-mode",
"base": "paint/dark-mode/svg-invert-all", "base": "paint/dark-mode/svg-invert-all",
"args": ["--blink-settings=darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"] "args": ["--blink-settings=darkModeEnabled=true,darkModeInversionAlgorithm=3,darkModeImagePolicy=0,darkModeTextBrightnessThreshold=256,darkModeBackgroundBrightnessThreshold=0"]
}, },
{ {
"prefix": "presentation", "prefix": "presentation",
......
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