Index: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
index a6ab0c53f09f1ab867d7696471e0fc3676606c53..dbd654a82cda136a2bf8ba3cf4f74011c7ab6b31 100644 |
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
@@ -7,7 +7,7 @@ |
#include <string> |
#include <vector> |
-#include "base/command_line.h" |
+#include "base/feature_list.h" |
#include "base/memory/ref_counted_memory.h" |
#include "base/strings/string16.h" |
#include "base/strings/string_number_conversions.h" |
@@ -32,6 +32,7 @@ |
#include "chrome/browser/ui/webui/app_launcher_login_handler.h" |
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
+#include "chrome/common/chrome_features.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/features.h" |
#include "chrome/common/pref_names.h" |
@@ -140,6 +141,10 @@ std::string GetNewTabBackgroundTilingCSS( |
return ThemeProperties::TilingToString(repeat_mode); |
} |
+bool IsMDIncognitoTabEnabled() { |
+ return base::FeatureList::IsEnabled(features::kMaterialDesignIncognitoNTP); |
+} |
+ |
} // namespace |
NTPResourceCache::NTPResourceCache(Profile* profile) |
@@ -275,13 +280,24 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { |
base::DictionaryValue localized_strings; |
localized_strings.SetString("title", |
l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
+ |
int new_tab_description_ids = IDS_NEW_TAB_OTR_DESCRIPTION; |
int new_tab_heading_ids = IDS_NEW_TAB_OTR_HEADING; |
int new_tab_link_ids = IDS_NEW_TAB_OTR_LEARN_MORE_LINK; |
int new_tab_warning_ids = IDS_NEW_TAB_OTR_MESSAGE_WARNING; |
+ int new_tab_features_ids = 0; // not used |
int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; |
const char* new_tab_link = kLearnMoreIncognitoUrl; |
+ // The MD Incognito NTP page uses different strings. |
+ if (IsMDIncognitoTabEnabled() && !profile_->IsGuestSession()) { |
+ new_tab_description_ids = IDS_NEW_TAB_OTR_SUBTITLE; |
+ new_tab_heading_ids = IDS_NEW_TAB_OTR_TITLE; |
+ new_tab_warning_ids = IDS_NEW_TAB_OTR_VISIBLE; |
+ new_tab_features_ids = IDS_NEW_TAB_OTR_NOT_SAVED; |
+ new_tab_html_idr = IDR_MD_INCOGNITO_TAB_HTML; |
+ } |
+ |
if (profile_->IsGuestSession()) { |
localized_strings.SetString("guestTabDescription", |
l10n_util::GetStringUTF16(new_tab_description_ids)); |
@@ -292,6 +308,13 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { |
l10n_util::GetStringUTF16(new_tab_description_ids)); |
localized_strings.SetString("incognitoTabHeading", |
l10n_util::GetStringUTF16(new_tab_heading_ids)); |
+ |
+ DCHECK_EQ(IsMDIncognitoTabEnabled(), !!new_tab_features_ids); |
+ if (IsMDIncognitoTabEnabled()) { |
+ localized_strings.SetString( |
+ "incognitoTabFeatures", |
+ l10n_util::GetStringUTF16(new_tab_features_ids)); |
+ } |
localized_strings.SetString("incognitoTabWarning", |
l10n_util::GetStringUTF16(new_tab_warning_ids)); |
} |
@@ -302,12 +325,14 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { |
bool bookmark_bar_attached = |
profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
- localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
+ localized_strings.SetString("bookmarkbarattached", |
+ bookmark_bar_attached ? "true" : "false"); |
const ui::ThemeProvider& tp = |
ThemeService::GetThemeProviderForProfile(profile_); |
- localized_strings.SetBoolean("hasCustomBackground", |
- tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND)); |
+ localized_strings.SetString( |
+ "hasCustomBackground", |
+ tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND) ? "true" : "false"); |
const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); |