summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 21:35:30 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 21:35:30 +0000
commit99deea6d3b0cf9c93351f247c5b62d3c8dea47da (patch)
tree7ecc4902afb5f5466558ef68d9915fb607fb2e7f
parent190be391c2c420310d95eda78b5fce0e00d069bf (diff)
downloadchromium_src-99deea6d3b0cf9c93351f247c5b62d3c8dea47da.zip
chromium_src-99deea6d3b0cf9c93351f247c5b62d3c8dea47da.tar.gz
chromium_src-99deea6d3b0cf9c93351f247c5b62d3c8dea47da.tar.bz2
More theme bits for the NTP and window frame.
BUG=12768,13352 TEST=Verify that a theme with attribution works on the NTP and a theme with an overlay shows up Review URL: http://codereview.chromium.org/119227 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17773 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/theme_provider.h4
-rw-r--r--chrome/app/generated_resources.grd4
-rw-r--r--chrome/app/theme/theme_resources.grd2
-rw-r--r--chrome/browser/browser_theme_provider.cc15
-rw-r--r--chrome/browser/browser_theme_provider.h3
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source.cc7
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc7
-rw-r--r--chrome/browser/resources/new_tab.html18
-rw-r--r--chrome/browser/resources/new_tab_theme.css4
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc12
-rw-r--r--views/widget/default_theme_provider.cc4
-rw-r--r--views/widget/default_theme_provider.h1
12 files changed, 74 insertions, 7 deletions
diff --git a/app/theme_provider.h b/app/theme_provider.h
index 70d374b..774810e 100644
--- a/app/theme_provider.h
+++ b/app/theme_provider.h
@@ -42,6 +42,10 @@ class ThemeProvider {
// a custom frame.
virtual bool ShouldUseNativeFrame() = 0;
+ // Whether or not we have a certain image. Used for when the default theme
+ // doesn't provide a certain image, but custom themes might (badges, etc).
+ virtual bool HasCustomImage(int id) = 0;
+
#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
// Gets the GdkPixbuf with the specified |id|. Returns a pointer to a shared
// instance of the GdkPixbuf. This shared GdkPixbuf is owned by the theme
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 730b748..b374261 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3391,6 +3391,10 @@ each locale. -->
desc="Title of recently closed windows in the recently closed section of the new tab page when the window has more than one tab. The % is replaced by the number of tabs">
% Tabs
</message>
+ <message name="IDS_NEW_TAB_ATTRIBUTION_INTRO"
+ desc="Leading sentence above a custom logo that the theme artist has provided">
+ Theme created by
+ </message>
<!-- SafeBrowsing -->
<message name="IDS_SAFE_BROWSING_MALWARE_TITLE" desc="SafeBrowsing Malware HTML title">
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 3d0e421..27be2b3 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -257,7 +257,9 @@
<include name="IDR_THEME_TAB_BACKGROUND_INCOGNITO" file="theme_tab_background_incognito.png" type="BINDATA" />
<include name="IDR_THEME_TAB_BACKGROUND_V" file="theme_tab_background_glass.png" type="BINDATA" />
<include name="IDR_THEME_NTP_BACKGROUND" file="ntp_background.png" type="BINDATA" />
+ <include name="IDR_THEME_FRAME_OVERLAY" file="notused.png" type="BINDATA" />
<include name="IDR_THEME_BUTTON_BACKGROUND" file="notused.png" type="BINDATA" />
+ <include name="IDR_THEME_NTP_ATTRIBUTION" file="notused.png" type="BINDATA" />
<include name="IDR_FORWARD_MASK" file="forward_mask.png" type="BINDATA" />
<include name="IDR_BACK_MASK" file="back_mask.png" type="BINDATA" />
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc
index 1fc1dea..6307c86 100644
--- a/chrome/browser/browser_theme_provider.cc
+++ b/chrome/browser/browser_theme_provider.cc
@@ -41,6 +41,8 @@ static const char* kColorNTPBackground = "ntp_background";
static const char* kColorNTPText = "ntp_text";
static const char* kColorNTPLink = "ntp_link";
static const char* kColorNTPSection = "ntp_section";
+static const char* kColorNTPSectionText = "ntp_section_text";
+static const char* kColorNTPSectionLink = "ntp_section_link";
static const char* kColorControlBackground = "control_background";
static const char* kColorButtonBackground = "button_background";
@@ -78,6 +80,8 @@ static const SkColor kDefaultColorNTPBackground = SkColorSetRGB(255, 255, 255);
static const SkColor kDefaultColorNTPText = SkColorSetRGB(0, 0, 0);
static const SkColor kDefaultColorNTPLink = SkColorSetRGB(0, 0, 204);
static const SkColor kDefaultColorNTPSection = SkColorSetRGB(225, 236, 254);
+static const SkColor kDefaultColorNTPSectionText = SkColorSetRGB(0, 0, 0);
+static const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(0, 0, 204);
static const SkColor kDefaultColorControlBackground = NULL;
static const SkColor kDefaultColorButtonBackground = NULL;
@@ -220,6 +224,10 @@ SkColor BrowserThemeProvider::GetColor(int id) {
return FindColor(kColorNTPLink, kDefaultColorNTPLink);
case COLOR_NTP_SECTION:
return FindColor(kColorNTPSection, kDefaultColorNTPSection);
+ case COLOR_NTP_SECTION_TEXT:
+ return FindColor(kColorNTPSectionText, kDefaultColorNTPSectionText);
+ case COLOR_NTP_SECTION_LINK:
+ return FindColor(kColorNTPSectionLink, kDefaultColorNTPSectionLink);
case COLOR_CONTROL_BACKGROUND:
return FindColor(kColorControlBackground, kDefaultColorControlBackground);
case COLOR_BUTTON_BACKGROUND:
@@ -258,6 +266,10 @@ bool BrowserThemeProvider::ShouldUseNativeFrame() {
#endif
}
+bool BrowserThemeProvider::HasCustomImage(int id) {
+ return (images_.find(id) != images_.end());
+}
+
void BrowserThemeProvider::SetTheme(Extension* extension) {
// Clear our image cache.
FreeImages();
@@ -687,9 +699,6 @@ void BrowserThemeProvider::SaveDisplayPropertyData() {
}
void BrowserThemeProvider::NotifyThemeChanged() {
- // TODO(glen): If we're in glass and IDR_THEME_FRAME has been provided,
- // swap us back to opaque frame.
-
// Redraw!
for (BrowserList::const_iterator browser = BrowserList::begin();
browser != BrowserList::end(); ++browser) {
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index b905315..9883c67 100644
--- a/chrome/browser/browser_theme_provider.h
+++ b/chrome/browser/browser_theme_provider.h
@@ -44,6 +44,8 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
COLOR_NTP_TEXT,
COLOR_NTP_LINK,
COLOR_NTP_SECTION,
+ COLOR_NTP_SECTION_TEXT,
+ COLOR_NTP_SECTION_LINK,
COLOR_CONTROL_BACKGROUND,
COLOR_BUTTON_BACKGROUND,
TINT_BUTTONS,
@@ -71,6 +73,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
virtual SkColor GetColor(int id);
virtual bool GetDisplayProperty(int id, int* result);
virtual bool ShouldUseNativeFrame();
+ virtual bool HasCustomImage(int id);
#if defined(OS_LINUX)
virtual GdkPixbuf* GetPixbufNamed(int id);
#endif
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.cc b/chrome/browser/dom_ui/dom_ui_theme_source.cc
index 41b3124..edf9e07 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_theme_source.cc
@@ -95,6 +95,10 @@ void DOMUIThemeSource::SendNewTabCSS(int request_id) {
SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK);
SkColor color_section =
tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION);
+ SkColor color_section_text =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT);
+ SkColor color_section_link =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK);
// Generate the replacements.
std::vector<string16> subst;
@@ -110,6 +114,8 @@ void DOMUIThemeSource::SendNewTabCSS(int request_id) {
subst.push_back(SkColorToRGBAString(color_text));
subst.push_back(SkColorToRGBAString(color_link));
subst.push_back(SkColorToRGBAString(color_section));
+ subst.push_back(SkColorToRGBAString(color_section_text));
+ subst.push_back(SkColorToRGBAString(color_section_link));
// Get our template.
static const StringPiece new_tab_theme_css(
@@ -169,4 +175,3 @@ std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) {
}
return BrowserThemeProvider::AlignmentToString(alignment);
}
-
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 24a9153..54731a2 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -252,6 +252,9 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
localized_strings.SetString(L"bookmarkbarattached",
profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
"true" : "false");
+ localized_strings.SetString(L"hasattribution",
+ profile_->GetThemeProvider()->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ?
+ "true" : "false");
localized_strings.SetString(L"title", title);
localized_strings.SetString(L"mostvisited", most_visited);
localized_strings.SetString(L"searches",
@@ -285,6 +288,8 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_SINGLE));
localized_strings.SetString(L"closedwindowmultiple",
l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_MULTIPLE));
+ localized_strings.SetString(L"attributionintro",
+ l10n_util::GetString(IDS_NEW_TAB_ATTRIBUTION_INTRO));
SetFontAndTextDirection(&localized_strings);
@@ -714,7 +719,7 @@ void MostVisitedHandler::OnSegmentUsageAvailable(
std::string pinned_url;
std::string pinned_title;
- if (MostVisitedHandler::GetPinnedURLAtIndex(j, &pinned_url,
+ if (MostVisitedHandler::GetPinnedURLAtIndex(j, &pinned_url,
&pinned_title)) {
url = GURL(pinned_url);
title = UTF8ToUTF16(pinned_title);
diff --git a/chrome/browser/resources/new_tab.html b/chrome/browser/resources/new_tab.html
index 3ce97ed..ba582fe 100644
--- a/chrome/browser/resources/new_tab.html
+++ b/chrome/browser/resources/new_tab.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
-<html id="t" jsvalues="dir:textdirection;firstview:firstview;bookmarkbarattached:bookmarkbarattached;">
+<html id="t" jsvalues="dir:textdirection;firstview:firstview;bookmarkbarattached:bookmarkbarattached;hasattribution:hasattribution">
<!--
This page is optimized for perceived performance. Our enemies are the time
taken for the backend to generate our data, and the time taken to parse
@@ -323,6 +323,9 @@ html[dir='rtl'] #searches input {
#searches input:-webkit-input-placeholder-mode {
color: #aaa;
}
+html[hasattribution='false'] .attribution {
+ display:none;
+}
.footer {
border-top:1px solid #ccc;
padding-top:4px;
@@ -352,7 +355,7 @@ html[dir='rtl'] #searches input {
</style>
<link id="themecss" rel="stylesheet" href="chrome://theme/css/newtab.css" />
</head>
-<body onload="logEvent('body onload fired');"
+<body onload="updateAttribution(); logEvent('body onload fired');"
jsvalues=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div id="l10n" style="display:none;">
<span id="closedwindowsingle" jscontent="closedwindowsingle">1 Tab</span>
@@ -458,6 +461,11 @@ document.addEventListener('DOMContentLoaded', handleDOMContentLoaded);
<div class="section-title" jscontent="recentlyclosed"></div>
<div id="recentlyClosedContainer"></div>
</div>
+
+ <div id="attribution" class="sidebar attribution">
+ <span jscontent="attributionintro"></span><br />
+ <img id="attribution-img" />
+ </div>
</td>
</tr>
</table>
@@ -935,6 +943,12 @@ function restoreThumbnails() {
function themeChanged() {
$('themecss').href = 'chrome://theme/css/newtab.css?' + Date.now();
+ updateAttribution();
+}
+
+function updateAttribution() {
+ $('attribution-img').src = 'chrome://theme/theme_ntp_attribution?' +
+ Date.now();
}
function bookmarkBarAttached() {
diff --git a/chrome/browser/resources/new_tab_theme.css b/chrome/browser/resources/new_tab_theme.css
index 3776cfe..ff36f52 100644
--- a/chrome/browser/resources/new_tab_theme.css
+++ b/chrome/browser/resources/new_tab_theme.css
@@ -18,4 +18,8 @@ a {
}
.sidebar.themed {
background-color: $7;
+ color: $8;
+}
+.sidebar.themed a {
+ color: $9;
} \ No newline at end of file
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 06777cb..5d73082 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -580,6 +580,12 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
// Draw the theme frame.
canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
+ // Draw the theme frame overlay
+ if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) {
+ SkBitmap* theme_overlay = tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY);
+ canvas->DrawBitmapInt(*theme_overlay, 0, 0);
+ }
+
// Top.
int top_left_height = std::min(top_left_corner->height(),
height() - bottom_left_corner->height());
@@ -639,6 +645,12 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Draw the theme frame.
canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
+ // Draw the theme frame overlay
+ if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) {
+ SkBitmap* theme_overlay = tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY);
+ canvas->DrawBitmapInt(*theme_overlay, 0, 0);
+ }
+
if (!browser_view_->IsToolbarVisible()) {
// There's no toolbar to edge the frame border, so we need to draw a bottom
// edge. The graphic we use for this has a built in client edge, so we clip
diff --git a/views/widget/default_theme_provider.cc b/views/widget/default_theme_provider.cc
index b9b0ddf..e97a713 100644
--- a/views/widget/default_theme_provider.cc
+++ b/views/widget/default_theme_provider.cc
@@ -31,4 +31,8 @@ bool DefaultThemeProvider::ShouldUseNativeFrame() {
return false;
#endif
}
+
+bool DefaultThemeProvider::HasCustomImage(int id) {
+ return false;
+}
} // namespace views
diff --git a/views/widget/default_theme_provider.h b/views/widget/default_theme_provider.h
index f576bc6..2ee7ad3 100644
--- a/views/widget/default_theme_provider.h
+++ b/views/widget/default_theme_provider.h
@@ -22,6 +22,7 @@ class DefaultThemeProvider : public ThemeProvider {
virtual SkColor GetColor(int id);
virtual bool GetDisplayProperty(int id, int* result);
virtual bool ShouldUseNativeFrame();
+ virtual bool HasCustomImage(int id);
private:
DISALLOW_COPY_AND_ASSIGN(DefaultThemeProvider);