-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
source_set("themes") { | ||
sources = [ | ||
"theme_properties.cc", | ||
"theme_properties.h", | ||
] | ||
deps = [ | ||
"//skia", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/themes/theme_properties.h" | ||
|
||
#include "chrome/browser/themes/theme_properties.h" | ||
#include "chrome/common/channel_info.h" | ||
#include "ui/gfx/color_palette.h" | ||
|
||
namespace { | ||
|
||
#if defined(OFFICIAL_BUILD) | ||
base::Optional<SkColor> MaybeGetDefaultColorForBraveUiReleaseChannel(int id, bool incognito) { | ||
switch (id) { | ||
// Applies when the window is active, tabs and also tab bar everywhere except active tab | ||
case ThemeProperties::COLOR_FRAME: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB: | ||
return incognito ? SkColorSetRGB(0x81, 0x85, 0x89) : SkColorSetRGB(0xD8, 0xDE, 0xE1); | ||
// Window when the window is innactive, tabs and also tab bar everywhere except active tab | ||
case ThemeProperties::COLOR_FRAME_INACTIVE: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE: | ||
return incognito ? SkColorSetRGB(0x71, 0x75, 0x79) : SkColorSetRGB(0xC8, 0xCE, 0xC8); | ||
// Active tab and also the URL toolbar | ||
// Parts of this color show up as you hover over innactive tabs too | ||
case ThemeProperties::COLOR_TOOLBAR: | ||
case ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND: | ||
case ThemeProperties::COLOR_CONTROL_BACKGROUND: | ||
case ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR: | ||
return incognito ? SkColorSetRGB(0x91, 0x95, 0x99) : SkColorSetRGB(0xF6, 0xF7, 0xF9); | ||
case ThemeProperties::COLOR_TAB_TEXT: | ||
return SkColorSetRGB(0x22, 0x23, 0x26); | ||
case ThemeProperties::COLOR_BOOKMARK_TEXT: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: | ||
return SkColorSetRGB(0x22, 0x23, 0x26); | ||
default: | ||
return base::nullopt; | ||
} | ||
} | ||
#endif | ||
|
||
base::Optional<SkColor> MaybeGetDefaultColorForBraveUiDevChannel(int id, bool incognito) { | ||
switch (id) { | ||
// Applies when the window is active, tabs and also tab bar everywhere except active tab | ||
case ThemeProperties::COLOR_FRAME: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB: | ||
return incognito ? SkColorSetRGB(0x68, 0x6B, 0x6E) : SkColorSetRGB(0x58, 0x5B, 0x5E); | ||
// Window when the window is innactive, tabs and also tab bar everywhere except active tab | ||
case ThemeProperties::COLOR_FRAME_INACTIVE: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE: | ||
return incognito ? SkColorSetRGB(0x58, 0x5B, 0x5E) : SkColorSetRGB(0x48, 0x4B, 0x4E); | ||
// Active tab and also the URL toolbar | ||
// Parts of this color show up as you hover over innactive tabs too | ||
case ThemeProperties::COLOR_TOOLBAR: | ||
case ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND: | ||
case ThemeProperties::COLOR_CONTROL_BACKGROUND: | ||
case ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR: | ||
return incognito ? SkColorSetRGB(0x32, 0x33, 0x36) : SkColorSetRGB(0x22, 0x23, 0x26); | ||
case ThemeProperties::COLOR_TAB_TEXT: | ||
return SkColorSetRGB(0xF7, 0xF8, 0xF9); | ||
case ThemeProperties::COLOR_BOOKMARK_TEXT: | ||
case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: | ||
return SkColorSetRGB(0x81, 0x85, 0x89); | ||
default: | ||
return base::nullopt; | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
// Returns a |nullopt| if the UI color is not handled by Brave. | ||
base::Optional<SkColor> MaybeGetDefaultColorForBraveUi(int id, bool incognito) { | ||
if (id == BRAVE_COLOR_FOR_TEST) { | ||
return SkColorSetRGB(11, 13, 17); | ||
} | ||
#if !defined(OFFICIAL_BUILD) | ||
return MaybeGetDefaultColorForBraveUiDevChannel(id, incognito); | ||
#else | ||
switch (chrome::GetChannel()) { | ||
case version_info::Channel::STABLE: | ||
case version_info::Channel::BETA: | ||
return MaybeGetDefaultColorForBraveUiReleaseChannel(id, incognito); | ||
case version_info::Channel::DEV: | ||
case version_info::Channel::CANARY: | ||
case version_info::Channel::UNKNOWN: | ||
default: | ||
return MaybeGetDefaultColorForBraveUiDevChannel(id, incognito); | ||
} | ||
#endif | ||
return base::nullopt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ | ||
#define BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ | ||
|
||
#include "base/optional.h" | ||
#include "third_party/skia/include/core/SkColor.h" | ||
|
||
#define BRAVE_COLOR_FOR_TEST 0x7FFFFFFF | ||
|
||
base::Optional<SkColor> MaybeGetDefaultColorForBraveUi(int id, bool incognito); | ||
|
||
#define MAYBE_OVERRIDE_DEFAULT_COLOR_FOR_BRAVE(id, incognito) \ | ||
const base::Optional<SkColor> braveColor = MaybeGetDefaultColorForBraveUi(id, incognito); \ | ||
if (braveColor) return braveColor.value(); | ||
|
||
#endif // BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/themes/theme_properties.h" | ||
#include "chrome/browser/themes/theme_properties.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
TEST(BraveThemeTest, ObtainsBraveOverrideColors) { | ||
SkColor actualColor = ThemeProperties::GetDefaultColor(BRAVE_COLOR_FOR_TEST, false); | ||
SkColor expectedColor = SkColorSetRGB(11, 13, 17); | ||
ASSERT_EQ(actualColor, expectedColor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/chrome/browser/themes/theme_properties.cc b/chrome/browser/themes/theme_properties.cc | ||
index 135c5029bb1aeeab1be398388db47392069ec0c5..af1105e469f8935f55160f86220a2d38757a450d 100644 | ||
--- a/chrome/browser/themes/theme_properties.cc | ||
+++ b/chrome/browser/themes/theme_properties.cc | ||
@@ -10,6 +10,7 @@ | ||
#include "base/optional.h" | ||
#include "base/strings/string_split.h" | ||
#include "base/strings/string_util.h" | ||
+#include "brave/browser/themes/theme_properties.h" | ||
#include "build/build_config.h" | ||
#include "chrome/browser/themes/browser_theme_pack.h" | ||
#include "ui/base/material_design/material_design_controller.h" | ||
@@ -290,6 +291,7 @@ color_utils::HSL ThemeProperties::GetDefaultTint(int id, bool incognito) { | ||
|
||
// static | ||
SkColor ThemeProperties::GetDefaultColor(int id, bool incognito) { | ||
+ MAYBE_OVERRIDE_DEFAULT_COLOR_FOR_BRAVE(id, incognito) | ||
const base::Optional<SkColor> color = | ||
MaybeGetDefaultColorForNewerMaterialUi(id, incognito); | ||
if (color) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters