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 347019: Convert ReplaceStringPlaceholders(std::string...) to take a (Closed)
Patch Set: a Created 11 years, 1 month 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
« no previous file with comments | « base/string_util.cc ('k') | chrome/renderer/extensions/extension_process_bindings.cc » ('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/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 subst2.push_back("block"); // $$8 186 subst2.push_back("block"); // $$8
187 else 187 else
188 subst2.push_back("none"); // $$8 188 subst2.push_back("none"); // $$8
189 189
190 // Get our template. 190 // Get our template.
191 static const base::StringPiece new_tab_theme_css( 191 static const base::StringPiece new_tab_theme_css(
192 ResourceBundle::GetSharedInstance().GetRawDataResource( 192 ResourceBundle::GetSharedInstance().GetRawDataResource(
193 IDR_NEW_TAB_THEME_CSS)); 193 IDR_NEW_TAB_THEME_CSS));
194 194
195 // Create the string from our template and the replacements. 195 // Create the string from our template and the replacements.
196 std::string format_string = new_tab_theme_css.as_string();
197 const std::string css_string = ReplaceStringPlaceholders( 196 const std::string css_string = ReplaceStringPlaceholders(
198 format_string, subst, NULL); 197 new_tab_theme_css, subst, NULL);
199 new_tab_css_ = ReplaceStringPlaceholders( 198 new_tab_css_ = ReplaceStringPlaceholders(
200 css_string, subst2, NULL); 199 css_string, subst2, NULL);
201 } 200 }
202 201
203 void DOMUIThemeSource::InitNewIncognitoTabCSS() { 202 void DOMUIThemeSource::InitNewIncognitoTabCSS() {
204 ThemeProvider* tp = profile_->GetThemeProvider(); 203 ThemeProvider* tp = profile_->GetThemeProvider();
205 DCHECK(tp); 204 DCHECK(tp);
206 205
207 // Get our theme colors 206 // Get our theme colors
208 SkColor color_background = 207 SkColor color_background =
(...skipping 11 matching lines...) Expand all
220 subst.push_back(GetNewTabBackgroundCSS(false)); // $3 219 subst.push_back(GetNewTabBackgroundCSS(false)); // $3
221 subst.push_back(GetNewTabBackgroundCSS(true)); // $4 220 subst.push_back(GetNewTabBackgroundCSS(true)); // $4
222 subst.push_back(GetNewTabBackgroundTilingCSS()); // $5 221 subst.push_back(GetNewTabBackgroundTilingCSS()); // $5
223 222
224 // Get our template. 223 // Get our template.
225 static const base::StringPiece new_tab_theme_css( 224 static const base::StringPiece new_tab_theme_css(
226 ResourceBundle::GetSharedInstance().GetRawDataResource( 225 ResourceBundle::GetSharedInstance().GetRawDataResource(
227 IDR_NEW_INCOGNITO_TAB_THEME_CSS)); 226 IDR_NEW_INCOGNITO_TAB_THEME_CSS));
228 227
229 // Create the string from our template and the replacements. 228 // Create the string from our template and the replacements.
230 std::string format_string = new_tab_theme_css.as_string();
231 new_incognito_tab_css_ = ReplaceStringPlaceholders( 229 new_incognito_tab_css_ = ReplaceStringPlaceholders(
232 format_string, subst, NULL); 230 new_tab_theme_css, subst, NULL);
233 } 231 }
234 232
235 void DOMUIThemeSource::SendNewTabCSS(int request_id, 233 void DOMUIThemeSource::SendNewTabCSS(int request_id,
236 const std::string& css_string) { 234 const std::string& css_string) {
237 // Convert to a format appropriate for sending. 235 // Convert to a format appropriate for sending.
238 scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes); 236 scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes);
239 css_bytes->data.resize(css_string.size()); 237 css_bytes->data.resize(css_string.size());
240 std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin()); 238 std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin());
241 239
242 // Send. 240 // Send.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return BrowserThemeProvider::AlignmentToString(alignment); 287 return BrowserThemeProvider::AlignmentToString(alignment);
290 } 288 }
291 289
292 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { 290 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() {
293 int repeat_mode; 291 int repeat_mode;
294 profile_->GetThemeProvider()->GetDisplayProperty( 292 profile_->GetThemeProvider()->GetDisplayProperty(
295 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); 293 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode);
296 return BrowserThemeProvider::TilingToString(repeat_mode); 294 return BrowserThemeProvider::TilingToString(repeat_mode);
297 } 295 }
298 296
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | chrome/renderer/extensions/extension_process_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698