| 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 cbbf9eae016d41c92581fa4c95978e241f61044d..b76021462bbda2c69988463b39df2a08e2fc9b24 100644
|
| --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
|
| +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
|
| @@ -30,6 +30,7 @@
|
| #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
|
| #include "chrome/browser/ui/sync/sync_promo_ui.h"
|
| #include "chrome/browser/ui/webui/app_launcher_login_handler.h"
|
| +#include "chrome/browser/ui/webui/color_utils.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_switches.h"
|
| @@ -90,27 +91,6 @@ const char kLearnMoreGuestSessionUrl[] =
|
| "https://support.google.com/chrome/?p=ui_guest";
|
| #endif
|
|
|
| -std::string SkColorToRGBAString(SkColor color) {
|
| - // We convert the alpha using DoubleToString because StringPrintf will use
|
| - // locale specific formatters (e.g., use , instead of . in German).
|
| - return base::StringPrintf(
|
| - "rgba(%d,%d,%d,%s)",
|
| - SkColorGetR(color),
|
| - SkColorGetG(color),
|
| - SkColorGetB(color),
|
| - base::DoubleToString(SkColorGetA(color) / 255.0).c_str());
|
| -}
|
| -
|
| -// Creates an rgb string for an SkColor, but leaves the alpha blank so that the
|
| -// css can fill it in.
|
| -std::string SkColorToRGBComponents(SkColor color) {
|
| - return base::StringPrintf(
|
| - "%d,%d,%d",
|
| - SkColorGetR(color),
|
| - SkColorGetG(color),
|
| - SkColorGetB(color));
|
| -}
|
| -
|
| 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
|
| @@ -520,7 +500,8 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
|
| profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
|
|
|
| // Colors.
|
| - substitutions["colorBackground"] = SkColorToRGBAString(color_background);
|
| + substitutions["colorBackground"] =
|
| + ColorUtils::SkColorToRGBAString(color_background);
|
| substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false);
|
| substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true);
|
| substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
|
| @@ -572,15 +553,17 @@ void NTPResourceCache::CreateNewTabCSS() {
|
| profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
|
|
|
| // Colors.
|
| - substitutions["colorBackground"] = SkColorToRGBAString(color_background);
|
| + substitutions["colorBackground"] =
|
| + ColorUtils::SkColorToRGBAString(color_background);
|
| substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false);
|
| substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true);
|
| substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
|
| - substitutions["colorTextRgba"] = SkColorToRGBAString(color_text);
|
| - substitutions["colorTextLight"] = SkColorToRGBAString(color_text_light);
|
| + substitutions["colorTextRgba"] = ColorUtils::SkColorToRGBAString(color_text);
|
| + substitutions["colorTextLight"] =
|
| + ColorUtils::SkColorToRGBAString(color_text_light);
|
| substitutions["colorSectionBorder"] =
|
| - SkColorToRGBComponents(color_section_border);
|
| - substitutions["colorText"] = SkColorToRGBComponents(color_text);
|
| + ColorUtils::SkColorToRGBComponents(color_section_border);
|
| + substitutions["colorText"] = ColorUtils::SkColorToRGBComponents(color_text);
|
|
|
| // For themes that right-align the background, we flip the attribution to the
|
| // left to avoid conflicts.
|
|
|