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

Unified Diff: chrome/browser/dom_ui/dom_ui_theme_source.cc

Issue 164376: Merge 22613 - Apply theme to incognito NTP.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/dom_ui_theme_source.cc
===================================================================
--- chrome/browser/dom_ui/dom_ui_theme_source.cc (revision 23149)
+++ chrome/browser/dom_ui/dom_ui_theme_source.cc (working copy)
@@ -28,6 +28,7 @@
// Path for the New Tab CSS. When we get more than a few of these, we should
// use a resource map rather than hard-coded strings.
static const char* kNewTabCSSPath = "css/newtab.css";
+static const char* kNewIncognitoTabCSSPath = "css/newincognitotab.css";
static string16 SkColorToRGBAString(SkColor color) {
return WideToUTF16(l10n_util::GetStringF(IDS_RGBA_CSS_FORMAT_STRING,
@@ -59,6 +60,9 @@
if (strcmp(uncached_path.c_str(), kNewTabCSSPath) == 0) {
SendNewTabCSS(request_id);
return;
+ } else if (strcmp(uncached_path.c_str(), kNewIncognitoTabCSSPath) == 0) {
+ SendNewIncognitoTabCSS(request_id);
+ return;
} else {
int resource_id = ThemeResourcesUtil::GetId(uncached_path);
if (resource_id != -1) {
@@ -73,7 +77,8 @@
std::string DOMUIThemeSource::GetMimeType(const std::string& path) const {
std::string uncached_path = StripQueryParams(path);
- if (strcmp(uncached_path.c_str(), kNewTabCSSPath) == 0)
+ if (strcmp(uncached_path.c_str(), kNewTabCSSPath) == 0 ||
+ strcmp(uncached_path.c_str(), kNewIncognitoTabCSSPath) == 0)
return "text/css";
return "image/png";
}
@@ -152,6 +157,46 @@
SendResponse(request_id, css_bytes);
}
+void DOMUIThemeSource::SendNewIncognitoTabCSS(int request_id) {
+ ThemeProvider* tp = profile_->GetThemeProvider();
+ DCHECK(tp);
+
+ // Get our theme colors
+ SkColor color_background =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND);
+
+ // Generate the replacements.
+ std::vector<string16> subst;
+
+ // Cache-buster for background.
+ subst.push_back(WideToUTF16(
+ profile_->GetPrefs()->GetString(prefs::kCurrentThemeID))); // $1
+
+ // Colors.
+ subst.push_back(SkColorToRGBAString(color_background)); // $2
+ subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false))); // $3
+ subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true))); // $4
+ subst.push_back(UTF8ToUTF16(GetNewTabBackgroundTilingCSS())); // $5
+
+ // Get our template.
+ static const StringPiece new_tab_theme_css(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_NEW_INCOGNITO_TAB_THEME_CSS));
+
+ // Create the string from our template and the replacements.
+ string16 format_string = ASCIIToUTF16(new_tab_theme_css.as_string());
+ const std::string css_string = UTF16ToASCII(ReplaceStringPlaceholders(
+ format_string, subst, NULL));
+
+ // Convert to a format appropriate for sending.
+ scoped_refptr<RefCountedBytes> css_bytes(new RefCountedBytes);
+ css_bytes->data.resize(css_string.size());
+ std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin());
+
+ // Send.
+ SendResponse(request_id, css_bytes);
+}
+
void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) {
ThemeProvider* tp = profile_->GetThemeProvider();
DCHECK(tp);
Property changes on: chrome\browser\dom_ui\dom_ui_theme_source.cc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/dom_ui/dom_ui_theme_source.cc:r22613
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698