Commit 6d5ec3bb authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

[NTP] Do not reload the MV tiles on theme change

This is a remnant from when the tile icon images were generated with a
(dark) gray background, depending on the system theme. Now that the tile
background controlled via CSS, it's no longer required to reload the
tiles when the background image is changed in dark mode.

Bug: 986935
Change-Id: Iccd076f354a838e9025856151e1e486824ed4c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1716100Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680316}
parent 35699cea
...@@ -248,13 +248,6 @@ let ntpApiHandle; ...@@ -248,13 +248,6 @@ let ntpApiHandle;
*/ */
let isDarkModeEnabled = false; let isDarkModeEnabled = false;
/**
* True if dark colored chips should be used instead of light mode chips when
* dark mode is enabled.
* @type {boolean}
*/
let useDarkChips = false;
/** /**
* Returns a timeout that can be executed early. Calls back true if this was * Returns a timeout that can be executed early. Calls back true if this was
* an early execution, false otherwise. * an early execution, false otherwise.
...@@ -353,8 +346,7 @@ function renderTheme() { ...@@ -353,8 +346,7 @@ function renderTheme() {
// Update dark mode styling. // Update dark mode styling.
isDarkModeEnabled = window.matchMedia('(prefers-color-scheme: dark)').matches; isDarkModeEnabled = window.matchMedia('(prefers-color-scheme: dark)').matches;
useDarkChips = getUseDarkChips(info); document.body.classList.toggle('light-chip', !getUseDarkChips(info));
document.body.classList.toggle('light-chip', !useDarkChips);
const background = [ const background = [
convertToRGBAColor(info.backgroundColorRgba), info.imageUrl, convertToRGBAColor(info.backgroundColorRgba), info.imageUrl,
...@@ -493,18 +485,9 @@ function renderOneGoogleBarTheme() { ...@@ -493,18 +485,9 @@ function renderOneGoogleBarTheme() {
* Callback for embeddedSearch.newTabPage.onthemechange. * Callback for embeddedSearch.newTabPage.onthemechange.
*/ */
function onThemeChange() { function onThemeChange() {
// Save the current dark mode state to check if dark mode has changed.
const usingDarkChips = useDarkChips;
renderTheme(); renderTheme();
renderOneGoogleBarTheme(); renderOneGoogleBarTheme();
sendThemeInfoToMostVisitedIframe(); sendThemeInfoToMostVisitedIframe();
// If dark mode has been changed, refresh the MV tiles to render the
// appropriate icon.
if (usingDarkChips != useDarkChips) {
reloadTiles();
}
} }
/** /**
......
...@@ -995,11 +995,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPDarkModeTest, ToggleDarkMode) { ...@@ -995,11 +995,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPDarkModeTest, ToggleDarkMode) {
ASSERT_TRUE(GetIsLightChipsApplied(active_tab)); ASSERT_TRUE(GetIsLightChipsApplied(active_tab));
// Enable dark mode and wait until the MV tiles have updated. // Enable dark mode and wait until the MV tiles have updated.
content::DOMMessageQueue msg_queue(active_tab);
theme()->SetDarkMode(true); theme()->SetDarkMode(true);
theme()->NotifyObservers(); theme()->NotifyObservers();
local_ntp_test_utils::WaitUntilTilesLoaded(active_tab, &msg_queue,
/*delay=*/0);
// Check that dark mode has been properly applied. // Check that dark mode has been properly applied.
EXPECT_TRUE(GetIsDarkModeApplied(active_tab)); EXPECT_TRUE(GetIsDarkModeApplied(active_tab));
...@@ -1008,11 +1005,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPDarkModeTest, ToggleDarkMode) { ...@@ -1008,11 +1005,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPDarkModeTest, ToggleDarkMode) {
EXPECT_FALSE(GetIsLightChipsApplied(active_tab)); EXPECT_FALSE(GetIsLightChipsApplied(active_tab));
// Disable dark mode and wait until the MV tiles have updated. // Disable dark mode and wait until the MV tiles have updated.
msg_queue.ClearQueue();
theme()->SetDarkMode(false); theme()->SetDarkMode(false);
theme()->NotifyObservers(); theme()->NotifyObservers();
local_ntp_test_utils::WaitUntilTilesLoaded(active_tab, &msg_queue,
/*delay=*/0);
// Check that dark mode has been removed. // Check that dark mode has been removed.
EXPECT_FALSE(GetIsDarkModeApplied(active_tab)); EXPECT_FALSE(GetIsDarkModeApplied(active_tab));
......
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