Chromium Code Reviews| 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); |