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

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

Issue 1492423003: Rejigger ThemeService: move exposure of ThemeProvider interface to a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a test Created 5 years 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 4623939553293c05b0d540b03bc7fdbebe9c0307..98ca65534a76ef4647948b2f3b73b73462672c66 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -112,8 +112,8 @@ std::string SkColorToRGBComponents(SkColor color) {
SkColorGetB(color));
}
-SkColor GetThemeColor(ui::ThemeProvider* tp, int id) {
- SkColor color = tp->GetColor(id);
+SkColor GetThemeColor(const ui::ThemeProvider& tp, int id) {
+ SkColor color = tp.GetColor(id);
// If web contents are being inverted because the system is in high-contrast
// mode, any system theme colors we use must be inverted too to cancel out.
return color_utils::IsInvertedColorScheme() ?
@@ -122,17 +122,17 @@ SkColor GetThemeColor(ui::ThemeProvider* tp, int id) {
// Get the CSS string for the background position on the new tab page for the
// states when the bar is attached or detached.
-std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
+std::string GetNewTabBackgroundCSS(const ui::ThemeProvider& theme_provider,
bool bar_attached) {
// TODO(glen): This is a quick workaround to hide the notused.png image when
// no image is provided - we don't have time right now to figure out why
// this is painting as white.
// http://crbug.com/17593
- if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
+ if (!theme_provider.HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
return "-64px";
}
- int alignment = theme_provider->GetDisplayProperty(
+ int alignment = theme_provider.GetDisplayProperty(
ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
if (bar_attached)
@@ -156,9 +156,9 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
// How the background image on the new tab page should be tiled (see tiling
// masks in theme_service.h).
std::string GetNewTabBackgroundTilingCSS(
- const ui::ThemeProvider* theme_provider) {
- int repeat_mode = theme_provider->GetDisplayProperty(
- ThemeProperties::NTP_BACKGROUND_TILING);
+ const ui::ThemeProvider& theme_provider) {
+ int repeat_mode =
+ theme_provider.GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING);
return ThemeProperties::TilingToString(repeat_mode);
}
@@ -338,9 +338,10 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar);
localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached);
- ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
+ const ui::ThemeProvider& tp =
+ ThemeService::GetThemeProviderForProfile(profile_);
pkotwicz 2015/12/04 23:16:50 This looks like |profile_| is always the non-OTR p
Evan Stade 2015/12/09 00:57:11 well, I suppose we might need to change that in th
pkotwicz 2015/12/09 02:08:29 This class fetches colors as well using the ThemeP
Evan Stade 2015/12/09 23:38:40 are you asking me to fix that right now, or pointi
pkotwicz 2015/12/10 01:02:02 I am asking you to fix this right now or to commit
Evan Stade 2015/12/10 01:31:17 I don't understand the urgency. There are no speci
localized_strings.SetBoolean("hasCustomBackground",
- tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND));
+ tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
@@ -539,12 +540,12 @@ void NTPResourceCache::CreateNewTabHTML() {
}
void NTPResourceCache::CreateNewTabIncognitoCSS() {
- ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
- DCHECK(tp);
+ const ui::ThemeProvider& tp =
+ ThemeService::GetThemeProviderForProfile(profile_);
// Get our theme colors
SkColor color_background =
- tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)
+ tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND)
? GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND)
: SkColorSetRGB(0x32, 0x32, 0x32);
@@ -574,8 +575,8 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
}
void NTPResourceCache::CreateNewTabCSS() {
- ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
- DCHECK(tp);
+ const ui::ThemeProvider& tp =
+ ThemeService::GetThemeProviderForProfile(profile_);
// Get our theme colors
SkColor color_background =
@@ -622,8 +623,8 @@ void NTPResourceCache::CreateNewTabCSS() {
// For themes that right-align the background, we flip the attribution to the
// left to avoid conflicts.
- int alignment = tp->GetDisplayProperty(
- ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
+ int alignment =
+ tp.GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
if (alignment & ThemeProperties::ALIGN_RIGHT) {
substitutions["leftAlignAttribution"] = "0";
substitutions["rightAlignAttribution"] = "auto";
@@ -635,7 +636,7 @@ void NTPResourceCache::CreateNewTabCSS() {
}
substitutions["displayAttribution"] =
- tp->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "inline" : "none";
+ tp.HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "inline" : "none";
// Get our template.
static const base::StringPiece new_tab_theme_css(

Powered by Google App Engine
This is Rietveld 408576698