| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" | 5 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
| 10 #include "base/gfx/png_encoder.h" | 10 #include "base/gfx/png_encoder.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND); | 99 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND); |
| 100 SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT); | 100 SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT); |
| 101 SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK); | 101 SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK); |
| 102 SkColor color_section = | 102 SkColor color_section = |
| 103 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); | 103 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); |
| 104 SkColor color_section_text = | 104 SkColor color_section_text = |
| 105 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); | 105 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); |
| 106 SkColor color_section_link = | 106 SkColor color_section_link = |
| 107 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); | 107 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); |
| 108 | 108 |
| 109 // Generate a lighter color. | 109 SkColor color_header = |
| 110 skia::HSL section_lighter; | 110 tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER); |
| 111 skia::SkColorToHSL(color_section, section_lighter); | 111 // Generate a lighter color for the header gradients. |
| 112 section_lighter.l += (1 - section_lighter.l) * 0.33; | 112 skia::HSL header_lighter; |
| 113 SkColor color_section_lighter = | 113 skia::SkColorToHSL(color_header, header_lighter); |
| 114 skia::HSLToSkColor(SkColorGetA(color_section), section_lighter); | 114 header_lighter.l += (1 - header_lighter.l) * 0.33; |
| 115 SkColor color_header_gradient_light = |
| 116 skia::HSLToSkColor(SkColorGetA(color_header), header_lighter); |
| 117 |
| 118 // Generate section border color from the header color. See |
| 119 // BookmarkBarView::Paint for how we do this for the bookmark bar |
| 120 // borders. |
| 121 SkColor color_section_border = |
| 122 SkColorSetARGB(80, |
| 123 SkColorGetR(color_header), |
| 124 SkColorGetG(color_header), |
| 125 SkColorGetB(color_header)); |
| 115 | 126 |
| 116 // Generate the replacements. | 127 // Generate the replacements. |
| 117 std::vector<string16> subst; | 128 std::vector<string16> subst; |
| 118 // A second list of replacements, each of which must be in $$x format, | 129 // A second list of replacements, each of which must be in $$x format, |
| 119 // where x is a digit from 1-9. | 130 // where x is a digit from 1-9. |
| 120 std::vector<string16> subst2; | 131 std::vector<string16> subst2; |
| 121 | 132 |
| 122 // Cache-buster for background. | 133 // Cache-buster for background. |
| 123 subst.push_back(WideToUTF16( | 134 subst.push_back(WideToUTF16( |
| 124 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID))); // $1 | 135 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID))); // $1 |
| 125 | 136 |
| 126 // Colors. | 137 // Colors. |
| 127 subst.push_back(SkColorToRGBAString(color_background)); // $2 | 138 subst.push_back(SkColorToRGBAString(color_background)); // $2 |
| 128 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); // $3 | 139 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); // $3 |
| 129 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); // $4 | 140 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); // $4 |
| 130 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); // $5 | 141 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); // $5 |
| 131 subst.push_back(SkColorToRGBAString(color_section)); // $6 | 142 subst.push_back(SkColorToRGBAString(color_header)); // $6 |
| 132 subst.push_back(SkColorToRGBAString(color_section_lighter)); // $7 | 143 subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7 |
| 133 subst.push_back(SkColorToRGBAString(color_text)); // $8 | 144 subst.push_back(SkColorToRGBAString(color_text)); // $8 |
| 134 subst.push_back(SkColorToRGBAString(color_link)); // $9 | 145 subst.push_back(SkColorToRGBAString(color_link)); // $9 |
| 135 | 146 |
| 136 subst2.push_back(SkColorToRGBAString(color_section_text)); // $$1 | 147 subst2.push_back(SkColorToRGBAString(color_section)); // $$1 |
| 137 subst2.push_back(SkColorToRGBAString(color_section_link)); // $$2 | 148 subst2.push_back(SkColorToRGBAString(color_section_border)); // $$2 |
| 149 subst2.push_back(SkColorToRGBAString(color_section_text)); // $$3 |
| 150 subst2.push_back(SkColorToRGBAString(color_section_link)); // $$4 |
| 138 | 151 |
| 139 // Get our template. | 152 // Get our template. |
| 140 static const StringPiece new_tab_theme_css( | 153 static const StringPiece new_tab_theme_css( |
| 141 ResourceBundle::GetSharedInstance().GetRawDataResource( | 154 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 142 IDR_NEW_TAB_THEME_CSS)); | 155 IDR_NEW_TAB_THEME_CSS)); |
| 143 | 156 |
| 144 // Create the string from our template and the replacements. | 157 // Create the string from our template and the replacements. |
| 145 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string()); | 158 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string()); |
| 146 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders( | 159 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders( |
| 147 format_string, subst, NULL)); | 160 format_string, subst, NULL)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return BrowserThemeProvider::AlignmentToString(alignment); | 258 return BrowserThemeProvider::AlignmentToString(alignment); |
| 246 } | 259 } |
| 247 | 260 |
| 248 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { | 261 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { |
| 249 int repeat_mode; | 262 int repeat_mode; |
| 250 profile_->GetThemeProvider()->GetDisplayProperty( | 263 profile_->GetThemeProvider()->GetDisplayProperty( |
| 251 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); | 264 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); |
| 252 return BrowserThemeProvider::TilingToString(repeat_mode); | 265 return BrowserThemeProvider::TilingToString(repeat_mode); |
| 253 } | 266 } |
| 254 | 267 |
| OLD | NEW |