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) {
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) {
switch (features::kForceDarkInversionMethodParam.Get()) {
case ForceDarkInversionMethod::kUseBlinkSettings:
......@@ -129,7 +136,8 @@ const DarkModeSettings& GetCachedDisabledSettings() {
DarkModeSettings BuildDarkModeSettings(const Settings& frame_settings,
const LayoutView& root) {
if (ShouldApplyDarkModeFilterToPage(frame_settings.GetDarkModePagePolicy(),
if (IsDarkModeEnabled(frame_settings) &&
ShouldApplyDarkModeFilterToPage(frame_settings.GetDarkModePagePolicy(),
root)) {
return GetCachedEnabledSettings(frame_settings);
}
......
......@@ -107,14 +107,7 @@ void Settings::SetForceDarkModeEnabled(bool enabled) {
if (force_dark_mode_ == enabled)
return;
force_dark_mode_ = enabled;
if (force_dark_mode_) {
SetDarkModeInversionAlgorithm(
DarkModeInversionAlgorithm::kInvertLightnessLAB);
SetDarkModeImagePolicy(DarkModeImagePolicy::kFilterSmart);
} else {
SetDarkModeInversionAlgorithm(DarkModeInversionAlgorithm::kOff);
}
SetDarkModeEnabled(force_dark_mode_);
Invalidate(SettingsDelegate::kColorSchemeChange);
}
......
......@@ -882,9 +882,14 @@
//
// Dark mode
//
{
name: "darkModeEnabled",
initial: false,
invalidate: "Paint",
},
{
name: "darkModeInversionAlgorithm",
initial: "DarkModeInversionAlgorithm::kOff",
initial: "DarkModeInversionAlgorithm::kInvertLightnessLAB",
type: "DarkModeInversionAlgorithm",
invalidate: "Paint",
},
......
......@@ -439,47 +439,47 @@
{
"prefix": "dark-mode",
"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",
"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",
"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",
"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",
"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",
"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",
"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",
"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",
"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",
......
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