Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 1440113002: [MD] Change appearance of incognito NTP to MD spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: guest Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5215c672ff6cbcc2ccec700197f1f28d3651c14b..253a3254c7c041e9a5defff3cfe7941c426d1b2f 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -261,19 +261,17 @@ base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(WindowType win_type) {
base::RefCountedMemory* NTPResourceCache::GetNewTabCSS(WindowType win_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (win_type == GUEST) {
- if (!new_tab_guest_css_.get())
- CreateNewTabGuestCSS();
- return new_tab_guest_css_.get();
- } else if (win_type == INCOGNITO) {
+ DCHECK_NE(win_type, GUEST);
+
+ if (win_type == INCOGNITO) {
if (!new_tab_incognito_css_.get())
CreateNewTabIncognitoCSS();
return new_tab_incognito_css_.get();
- } else {
- if (!new_tab_css_.get())
- CreateNewTabCSS();
- return new_tab_css_.get();
}
+
+ if (!new_tab_css_.get())
Dan Beam 2015/11/13 01:32:22 nit: .get() isn't necessary here
Evan Stade 2015/11/13 01:39:00 Acknowledged (will fix).
Evan Stade 2015/11/19 23:05:24 Done.
+ CreateNewTabCSS();
+ return new_tab_css_.get();
}
void NTPResourceCache::Observe(int type,
@@ -539,7 +537,9 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
// Get our theme colors
SkColor color_background =
- GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND);
+ tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)
+ ? GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND)
+ : SkColorSetRGB(0x32, 0x32, 0x32);
// Generate the replacements.
std::map<base::StringPiece, std::string> substitutions;
@@ -553,6 +553,10 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false);
substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true);
substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
+ substitutions["hasCustomBackground"] =
+ !tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)
+ ? ".doesNotHaveCustomBackground"
Dan Beam 2015/11/13 01:32:22 i get that this is simple, but I think it is very
Evan Stade 2015/11/13 01:39:00 That sounds nightmarishly difficult because only t
Dan Beam 2015/11/16 19:57:25 can't you just add a hasCustomBackground boolean p
Evan Stade 2015/11/16 20:10:08 no. That would work for any NTPs you open after a
Dan Beam 2015/11/17 00:18:59 i'm saying pass a hasCustomBackground boolean to j
Dan Beam 2015/11/17 00:26:15 document.body.**
Evan Stade 2015/11/19 23:05:24 Done.
+ : std::string();
// Get our template.
static const base::StringPiece new_tab_theme_css(
@@ -566,39 +570,6 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css);
}
-void NTPResourceCache::CreateNewTabGuestCSS() {
- ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
- DCHECK(tp);
-
- // Get our theme colors
- SkColor color_background =
- GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND);
-
- // Generate the replacements.
- std::map<base::StringPiece, std::string> substitutions;
-
- // Cache-buster for background.
- substitutions["themeId"] =
- profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
-
- // Colors.
- substitutions["colorBackground"] = SkColorToRGBAString(color_background);
- substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false);
- substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true);
- substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
-
- // Get our template.
- static const base::StringPiece new_tab_theme_css(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_NEW_INCOGNITO_TAB_THEME_CSS));
-
- // Create the string from our template and the replacements.
- std::string full_css =
- ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions);
-
- new_tab_guest_css_ = base::RefCountedString::TakeString(&full_css);
-}
-
void NTPResourceCache::CreateNewTabCSS() {
ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
DCHECK(tp);

Powered by Google App Engine
This is Rietveld 408576698