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..f8439f8c6e2ec797374f2c15b43ff1f281c61e02 100644 |
| --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| @@ -242,18 +242,18 @@ NTPResourceCache::WindowType NTPResourceCache::GetWindowType( |
| base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(WindowType win_type) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| if (win_type == GUEST) { |
| - if (!new_tab_guest_html_.get()) |
| + if (!new_tab_guest_html_) |
| CreateNewTabGuestHTML(); |
| return new_tab_guest_html_.get(); |
| } else if (win_type == INCOGNITO) { |
| - if (!new_tab_incognito_html_.get()) |
| + if (!new_tab_incognito_html_) |
| CreateNewTabIncognitoHTML(); |
| return new_tab_incognito_html_.get(); |
| } else { |
| // Refresh the cached HTML if necessary. |
| // NOTE: NewTabCacheNeedsRefresh() must be called every time the new tab |
| // HTML is fetched, because it needs to initialize cached values. |
| - if (NewTabCacheNeedsRefresh() || !new_tab_html_.get()) |
| + if (NewTabCacheNeedsRefresh() || !new_tab_html_) |
| CreateNewTabHTML(); |
| return new_tab_html_.get(); |
| } |
| @@ -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) { |
| - if (!new_tab_incognito_css_.get()) |
| + DCHECK_NE(win_type, GUEST); |
| + |
| + if (win_type == INCOGNITO) { |
| + if (!new_tab_incognito_css_.) |
|
Dan Beam
2015/11/20 00:48:45
oops
Evan Stade
2015/11/20 22:05:17
Done.
|
| CreateNewTabIncognitoCSS(); |
| return new_tab_incognito_css_.get(); |
| - } else { |
| - if (!new_tab_css_.get()) |
| - CreateNewTabCSS(); |
| - return new_tab_css_.get(); |
| } |
| + |
| + if (!new_tab_css_) |
| + CreateNewTabCSS(); |
| + return new_tab_css_.get(); |
| } |
| void NTPResourceCache::Observe(int type, |
| @@ -337,6 +335,10 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { |
| profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
| localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
| + ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
| + localized_strings.SetBoolean("hasCustomBackground", |
| + tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)); |
| + |
| const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); |
| @@ -539,7 +541,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; |
| @@ -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); |