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

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

Issue 149741: Allow the tiling of theme background images on the NTP.... (Closed) Base URL: svn://chrome-svn/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/dom_ui/dom_ui_theme_source.h ('k') | chrome/browser/resources/new_tab_theme.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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 the replacements. 103 // Generate the replacements.
104 std::vector<string16> subst; 104 std::vector<string16> subst;
105 // A second list of replacements, each of which must be in $$x format,
106 // where x is a digit from 1-9.
107 std::vector<string16> subst2;
105 108
106 // Cache-buster for background. 109 // Cache-buster for background.
107 subst.push_back(UTF8ToUTF16(IntToString(static_cast<int>( 110 subst.push_back(UTF8ToUTF16(IntToString(static_cast<int>(
108 base::Time::Now().ToDoubleT())))); 111 base::Time::Now().ToDoubleT()))));
109 112
110 // Colors. 113 // Colors.
111 subst.push_back(SkColorToRGBAString(color_background)); 114 subst.push_back(SkColorToRGBAString(color_background));
112 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); 115 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false)));
113 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); 116 subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true)));
114 subst.push_back(SkColorToRGBAString(color_text)); 117 subst.push_back(SkColorToRGBAString(color_text));
115 subst.push_back(SkColorToRGBAString(color_link)); 118 subst.push_back(SkColorToRGBAString(color_link));
116 subst.push_back(SkColorToRGBAString(color_section)); 119 subst.push_back(SkColorToRGBAString(color_section));
117 subst.push_back(SkColorToRGBAString(color_section_text)); 120 subst.push_back(SkColorToRGBAString(color_section_text));
118 subst.push_back(SkColorToRGBAString(color_section_link)); 121 subst.push_back(SkColorToRGBAString(color_section_link));
119 122
123 subst2.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS()));
124
120 // Get our template. 125 // Get our template.
121 static const StringPiece new_tab_theme_css( 126 static const StringPiece new_tab_theme_css(
122 ResourceBundle::GetSharedInstance().GetRawDataResource( 127 ResourceBundle::GetSharedInstance().GetRawDataResource(
123 IDR_NEW_TAB_THEME_CSS)); 128 IDR_NEW_TAB_THEME_CSS));
124 129
125 // Create the string from our template and the replacements. 130 // Create the string from our template and the replacements.
126 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string()); 131 string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string());
127 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders( 132 const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders(
128 format_string, subst, NULL)); 133 format_string, subst, NULL));
134 const std::string css_string2 = UTF16ToASCII(ReplaceStringPlaceholders(
135 ASCIIToUTF16(css_string), subst2, NULL));
129 136
130 // Convert to a format appropriate for sending. 137 // Convert to a format appropriate for sending.
131 scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes); 138 scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes);
132 css_bytes->data.resize(css_string.size()); 139 css_bytes->data.resize(css_string2.size());
133 std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin()); 140 std::copy(css_string2.begin(), css_string2.end(), css_bytes->data.begin());
134 141
135 // Send. 142 // Send.
136 SendResponse(request_id, css_bytes); 143 SendResponse(request_id, css_bytes);
137 } 144 }
138 145
139 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { 146 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) {
140 ThemeProvider* tp = profile_->GetThemeProvider(); 147 ThemeProvider* tp = profile_->GetThemeProvider();
141 DCHECK(tp); 148 DCHECK(tp);
142 149
143 SkBitmap* image = tp->GetBitmapNamed(resource_id); 150 SkBitmap* image = tp->GetBitmapNamed(resource_id);
(...skipping 20 matching lines...) Expand all
164 int offset = BookmarkBarView::kNewtabBarHeight; 171 int offset = BookmarkBarView::kNewtabBarHeight;
165 #else 172 #else
166 int offset = 0; 173 int offset = 0;
167 #endif 174 #endif
168 175
169 if (alignment & BrowserThemeProvider::ALIGN_TOP) { 176 if (alignment & BrowserThemeProvider::ALIGN_TOP) {
170 if (alignment & BrowserThemeProvider::ALIGN_LEFT) 177 if (alignment & BrowserThemeProvider::ALIGN_LEFT)
171 return "0% " + IntToString(-offset) + "px"; 178 return "0% " + IntToString(-offset) + "px";
172 else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) 179 else if (alignment & BrowserThemeProvider::ALIGN_RIGHT)
173 return "100% " + IntToString(-offset) + "px"; 180 return "100% " + IntToString(-offset) + "px";
174 return IntToString(-offset) + "px"; 181 return "center " + IntToString(-offset) + "px";
175 } 182 }
176 return BrowserThemeProvider::AlignmentToString(alignment); 183 return BrowserThemeProvider::AlignmentToString(alignment);
177 } 184 }
185
186 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() {
187 int repeat_mode;
188 profile_->GetThemeProvider()->GetDisplayProperty(
189 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode);
190 return BrowserThemeProvider::TilingToString(repeat_mode);
191 }
192
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.h ('k') | chrome/browser/resources/new_tab_theme.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698