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

Side by Side Diff: chrome/browser/dom_ui/dom_ui_theme_source.cc

Issue 159305: First pass at NNTP theming.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_theme_provider.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND); 93 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND);
94 SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT); 94 SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT);
95 SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK); 95 SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK);
96 SkColor color_section = 96 SkColor color_section =
97 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); 97 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION);
98 SkColor color_section_text = 98 SkColor color_section_text =
99 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); 99 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT);
100 SkColor color_section_link = 100 SkColor color_section_link =
101 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); 101 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK);
102 102
103 // Generate a lighter color.
104 skia::HSL section_lighter;
105 skia::SkColorToHSL(color_section, section_lighter);
106 section_lighter.l += (1 - section_lighter.l) * 0.33;
107 section_lighter.s += (1 - section_lighter.s) * 0.1;
108 SkColor color_section_lighter =
109 skia::HSLToSkColor(SkColorGetA(color_section), section_lighter);
110
103 // Generate the replacements. 111 // Generate the replacements.
104 std::vector<string16> subst; 112 std::vector<string16> subst;
105 // A second list of replacements, each of which must be in $$x format, 113 // A second list of replacements, each of which must be in $$x format,
106 // where x is a digit from 1-9. 114 // where x is a digit from 1-9.
107 std::vector<string16> subst2; 115 std::vector<string16> subst2;
108 116
109 // Cache-buster for background. 117 // Cache-buster for background.
110 subst.push_back(UTF8ToUTF16(IntToString(static_cast<int>( 118 subst.push_back(UTF8ToUTF16(IntToString(static_cast<int>(
111 base::Time::Now().ToDoubleT())))); 119 base::Time::Now().ToDoubleT())))); // $1
112 120
113 // Colors. 121 // Colors.
114 subst.push_back(SkColorToRGBAString(color_background)); 122 subst.push_back(SkColorToRGBAString(color_background)); // $2
115 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); 123 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); // $3
116 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); 124 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); // $4
117 subst.push_back(SkColorToRGBAString(color_text)); 125 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); // $5
118 subst.push_back(SkColorToRGBAString(color_link)); 126 subst.push_back(SkColorToRGBAString(color_section)); // $6
119 subst.push_back(SkColorToRGBAString(color_section)); 127 subst.push_back(SkColorToRGBAString(color_section_lighter)); // $7
120 subst.push_back(SkColorToRGBAString(color_section_text)); 128 subst.push_back(SkColorToRGBAString(color_text)); // $8
121 subst.push_back(SkColorToRGBAString(color_section_link)); 129 subst.push_back(SkColorToRGBAString(color_link)); // $9
122 130
123 subst2.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); 131 subst2.push_back(SkColorToRGBAString(color_section_text)); // $$1
132 subst2.push_back(SkColorToRGBAString(color_section_link)); // $$2
124 133
125 // Get our template. 134 // Get our template.
126 static const StringPiece new_tab_theme_css( 135 static const StringPiece new_tab_theme_css(
127 ResourceBundle::GetSharedInstance().GetRawDataResource( 136 ResourceBundle::GetSharedInstance().GetRawDataResource(
128 IDR_NEW_TAB_THEME_CSS)); 137 IDR_NEW_TAB_THEME_CSS));
129 138
130 // Create the string from our template and the replacements. 139 // Create the string from our template and the replacements.
131 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string()); 140 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string());
132 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders( 141 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders(
133 format_string, subst, NULL)); 142 format_string, subst, NULL));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return BrowserThemeProvider::AlignmentToString(alignment); 179 return BrowserThemeProvider::AlignmentToString(alignment);
171 180
172 // The bar is detached, so we must offset the background by the bar size 181 // The bar is detached, so we must offset the background by the bar size
173 // if it's a top-aligned bar. 182 // if it's a top-aligned bar.
174 #if defined(OS_WIN) 183 #if defined(OS_WIN)
175 int offset = BookmarkBarView::kNewtabBarHeight; 184 int offset = BookmarkBarView::kNewtabBarHeight;
176 #else 185 #else
177 int offset = 0; 186 int offset = 0;
178 #endif 187 #endif
179 188
189 // TODO(glen): This is a quick workaround to hide the notused.png image when
190 // no image is provided - we don't have time right now to figure out why
191 // this is painting as white.
192 // http://crbug.com/17593
193 if (!profile_->GetThemeProvider()->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
194 return "-64px";
195 }
196
180 if (alignment & BrowserThemeProvider::ALIGN_TOP) { 197 if (alignment & BrowserThemeProvider::ALIGN_TOP) {
181 if (alignment & BrowserThemeProvider::ALIGN_LEFT) 198 if (alignment & BrowserThemeProvider::ALIGN_LEFT)
182 return "0% " + IntToString(-offset) + "px"; 199 return "0% " + IntToString(-offset) + "px";
183 else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) 200 else if (alignment & BrowserThemeProvider::ALIGN_RIGHT)
184 return "100% " + IntToString(-offset) + "px"; 201 return "100% " + IntToString(-offset) + "px";
185 return "center " + IntToString(-offset) + "px"; 202 return "center " + IntToString(-offset) + "px";
186 } 203 }
187 return BrowserThemeProvider::AlignmentToString(alignment); 204 return BrowserThemeProvider::AlignmentToString(alignment);
188 } 205 }
189 206
190 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { 207 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() {
191 int repeat_mode; 208 int repeat_mode;
192 profile_->GetThemeProvider()->GetDisplayProperty( 209 profile_->GetThemeProvider()->GetDisplayProperty(
193 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); 210 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode);
194 return BrowserThemeProvider::TilingToString(repeat_mode); 211 return BrowserThemeProvider::TilingToString(repeat_mode);
195 } 212 }
196 213
OLDNEW
« no previous file with comments | « chrome/browser/browser_theme_provider.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698