Commit 3c660255 authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Remove more remnants of dark mode from old NTP-ish UIs

BUG=965811

Change-Id: I70024269a3239b1920d0cd73f79ab9242fde6ac6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1671467
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671476}
parent 58800448
...@@ -53,11 +53,7 @@ const char* GetHtmlTextDirection(const base::string16& text) { ...@@ -53,11 +53,7 @@ const char* GetHtmlTextDirection(const base::string16& text) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// NewTabUI // NewTabUI
NewTabUI::NewTabUI(content::WebUI* web_ui) NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
: content::WebUIController(web_ui),
dark_mode_observer_(ui::NativeTheme::GetInstanceForNativeUi(),
base::BindRepeating(&NewTabUI::OnDarkModeChanged,
base::Unretained(this))) {
web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
Profile* profile = GetProfile(); Profile* profile = GetProfile();
...@@ -76,8 +72,6 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) ...@@ -76,8 +72,6 @@ NewTabUI::NewTabUI(content::WebUI* web_ui)
pref_change_registrar_.Add( pref_change_registrar_.Add(
prefs::kWebKitDefaultFontSize, prefs::kWebKitDefaultFontSize,
base::Bind(&NewTabUI::OnDefaultFontSizeChanged, base::Unretained(this))); base::Bind(&NewTabUI::OnDefaultFontSizeChanged, base::Unretained(this)));
dark_mode_observer_.Start();
} }
NewTabUI::~NewTabUI() {} NewTabUI::~NewTabUI() {}
...@@ -91,16 +85,6 @@ void NewTabUI::OnShowBookmarkBarChanged() { ...@@ -91,16 +85,6 @@ void NewTabUI::OnShowBookmarkBarChanged() {
attached); attached);
} }
void NewTabUI::OnDarkModeChanged(bool /*dark_mode*/) {
if (!web_ui() || !web_ui()->CanCallJavascript())
return;
bool enabled = base::FeatureList::IsEnabled(features::kWebUIDarkMode);
web_ui()->CallJavascriptFunctionUnsafe(
"document.documentElement.toggleAttribute", base::Value("dark"),
base::Value(enabled && dark_mode_observer_.InDarkMode()));
}
void NewTabUI::OnDefaultFontSizeChanged() { void NewTabUI::OnDefaultFontSizeChanged() {
web_ui()->CallJavascriptFunctionUnsafe("ntp.defaultFontSizeChanged"); web_ui()->CallJavascriptFunctionUnsafe("ntp.defaultFontSizeChanged");
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/url_data_source.h" #include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_controller.h"
#include "ui/native_theme/dark_mode_observer.h"
class GURL; class GURL;
class Profile; class Profile;
...@@ -74,14 +73,11 @@ class NewTabUI : public content::WebUIController { ...@@ -74,14 +73,11 @@ class NewTabUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource); DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
}; };
void OnDarkModeChanged(bool dark_mode);
void OnDefaultFontSizeChanged(); void OnDefaultFontSizeChanged();
void OnShowBookmarkBarChanged(); void OnShowBookmarkBarChanged();
Profile* GetProfile() const; Profile* GetProfile() const;
ui::DarkModeObserver dark_mode_observer_;
PrefChangeRegistrar pref_change_registrar_; PrefChangeRegistrar pref_change_registrar_;
DISALLOW_COPY_AND_ASSIGN(NewTabUI); DISALLOW_COPY_AND_ASSIGN(NewTabUI);
......
...@@ -347,8 +347,6 @@ void NTPResourceCache::CreateNewTabGuestHTML() { ...@@ -347,8 +347,6 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
l10n_util::GetStringUTF16(guest_tab_link_ids)); l10n_util::GetStringUTF16(guest_tab_link_ids));
localized_strings.SetString("learnMoreLink", guest_tab_link); localized_strings.SetString("learnMoreLink", guest_tab_link);
SetDarkKey(&localized_strings);
const std::string& app_locale = g_browser_process->GetApplicationLocale(); const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
...@@ -467,8 +465,6 @@ void NTPResourceCache::CreateNewTabHTML() { ...@@ -467,8 +465,6 @@ void NTPResourceCache::CreateNewTabHTML() {
"isUserSignedIn", "isUserSignedIn",
IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount()); IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
SetDarkKey(&load_time_data);
// Load the new tab page appropriate for this build. // Load the new tab page appropriate for this build.
base::StringPiece new_tab_html( base::StringPiece new_tab_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResource( ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
...@@ -584,11 +580,3 @@ void NTPResourceCache::CreateNewTabCSS() { ...@@ -584,11 +580,3 @@ void NTPResourceCache::CreateNewTabCSS() {
ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions); ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions);
new_tab_css_ = base::RefCountedString::TakeString(&css_string); new_tab_css_ = base::RefCountedString::TakeString(&css_string);
} }
void NTPResourceCache::SetDarkKey(base::Value* dict) {
DCHECK(dict && dict->is_dict());
bool use_dark =
base::FeatureList::IsEnabled(features::kWebUIDarkMode) &&
ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
dict->SetKey("dark", base::Value(use_dark ? "dark" : ""));
}
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