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

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

Issue 115910: Allow themes to change the background of the new tab page.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 17403)
+++ chrome/browser/dom_ui/dom_ui_theme_source.cc (working copy)
@@ -20,6 +20,10 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+#if defined(OS_WIN)
+#include "chrome/browser/views/bookmark_bar_view.h"
+#endif
+
// 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";
@@ -85,6 +89,8 @@
DCHECK(tp);
// Get our theme colors
+ SkColor color_background =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND);
SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT);
SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK);
SkColor color_section =
@@ -98,6 +104,9 @@
base::Time::Now().ToDoubleT()))));
// Colors.
+ subst.push_back(SkColorToRGBAString(color_background));
+ subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(false)));
+ subst.push_back(UTF8ToUTF16(GetNewTabBackgroundCSS(true)));
subst.push_back(SkColorToRGBAString(color_text));
subst.push_back(SkColorToRGBAString(color_link));
subst.push_back(SkColorToRGBAString(color_section));
@@ -134,3 +143,30 @@
new RefCountedBytes(png_bytes);
SendResponse(request_id, image_data);
}
+
+std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) {
+ int alignment;
+ profile_->GetThemeProvider()->GetDisplayProperty(
+ BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment);
+
+ if (bar_attached)
+ return BrowserThemeProvider::AlignmentToString(alignment);
+
+ // The bar is detached, so we must offset the background by the bar size
+ // if it's a top-aligned bar.
+#if defined(OS_WIN)
+ int offset = BookmarkBarView::kNewtabBarHeight;
+#else
+ int offset = 0;
+#endif
+
+ if (alignment & BrowserThemeProvider::ALIGN_TOP) {
+ if (alignment & BrowserThemeProvider::ALIGN_LEFT)
+ return "0% " + IntToString(-offset) + "px";
+ else if (alignment & BrowserThemeProvider::ALIGN_RIGHT)
+ return "100% " + IntToString(-offset) + "px";
+ return IntToString(-offset) + "px";
+ }
+ return BrowserThemeProvider::AlignmentToString(alignment);
+}
+
« 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