summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 22:01:09 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 22:01:09 +0000
commite09cc594ec748ec3bd3275980cb422eef81d52e2 (patch)
treef5d365294133f632dd28daf74ee51c24d3856568 /chrome
parente468816fe2fdde97f56be94b2e06dcc33fbe259e (diff)
downloadchromium_src-e09cc594ec748ec3bd3275980cb422eef81d52e2.zip
chromium_src-e09cc594ec748ec3bd3275980cb422eef81d52e2.tar.gz
chromium_src-e09cc594ec748ec3bd3275980cb422eef81d52e2.tar.bz2
Revert 123804 - ntp theme fixes
1. fix where the theme background is displayed for default (0) alignment -- it should be center center. This matches what the bookmark bar does. This may break some themes that rely on the default being top-left alignment. I can't see a way around this. 2. Fix the bookmark bar for vertical center alignment. 3. update the ntp background when the bookmark bar is attached/detached. TODO: transition (3) so that it looks good on windows and mac. BUG=115594 TEST=manual Review URL: https://chromiumcodereview.appspot.com/9467027 TBR=estade@chromium.org Review URL: https://chromiumcodereview.appspot.com/9475026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ntp_background_util.cc15
-rw-r--r--chrome/browser/resources/chromeos/guest_session_tab.html4
-rw-r--r--chrome/browser/resources/incognito_tab.html4
-rw-r--r--chrome/browser/resources/ntp4/new_tab.html3
-rw-r--r--chrome/browser/resources/ntp4/new_tab.js18
-rw-r--r--chrome/browser/resources/ntp4/new_tab_theme.css7
-rw-r--r--chrome/browser/themes/theme_service.cc11
-rw-r--r--chrome/browser/themes/theme_service.h1
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui.cc18
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui.h3
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc4
-rw-r--r--chrome/browser/ui/webui/theme_source.cc4
12 files changed, 32 insertions, 60 deletions
diff --git a/chrome/browser/ntp_background_util.cc b/chrome/browser/ntp_background_util.cc
index 297a0f0..c6682d0 100644
--- a/chrome/browser/ntp_background_util.cc
+++ b/chrome/browser/ntp_background_util.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/ntp_background_util.h"
-#include <cmath>
-
#include "base/logging.h"
#include "chrome/browser/themes/theme_service.h"
#include "grit/theme_resources.h"
@@ -24,22 +22,15 @@ void PaintThemeBackground(
int width = area.width() + ntp_background->width();
int height = area.height() + ntp_background->height();
- if (alignment & ThemeService::ALIGN_BOTTOM) {
+ if (alignment & ThemeService::ALIGN_BOTTOM)
y_pos += area.height() + tab_contents_height - ntp_background->height();
- } else if (alignment & ThemeService::ALIGN_TOP) {
- // no op
- } else { // ALIGN_CENTER
- y_pos += std::floor(area.height() + tab_contents_height / 2.0 -
- ntp_background->height() / 2.0 + 0.5);
- }
if (alignment & ThemeService::ALIGN_RIGHT) {
x_pos += area.width() - ntp_background->width();
} else if (alignment & ThemeService::ALIGN_LEFT) {
// no op
} else { // ALIGN_CENTER
- x_pos +=
- std::floor(area.width() / 2.0 - ntp_background->width() / 2.0 + 0.5);
+ x_pos += area.width() / 2 - ntp_background->width() / 2;
}
if (tiling != ThemeService::REPEAT &&
@@ -77,7 +68,7 @@ void NtpBackgroundUtil::PaintBackgroundDetachedMode(ui::ThemeProvider* tp,
tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling);
int alignment;
if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT,
- &alignment)) {
+ &alignment)) {
SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND);
PaintThemeBackground(
diff --git a/chrome/browser/resources/chromeos/guest_session_tab.html b/chrome/browser/resources/chromeos/guest_session_tab.html
index 4eaa4f6..5915b22 100644
--- a/chrome/browser/resources/chromeos/guest_session_tab.html
+++ b/chrome/browser/resources/chromeos/guest_session_tab.html
@@ -6,7 +6,7 @@
<script>
// Until themes can clear the cache, force-reload the theme stylesheet.
document.write('<link id="incognitothemecss" rel="stylesheet" ' +
- 'href="chrome://theme/css/incognito_new_tab_theme.css?' +
+ 'href="chrome://theme/css/newincognitotab.css?' +
Date.now() + '">');
</script>
</head>
@@ -19,7 +19,7 @@ document.write('<link id="incognitothemecss" rel="stylesheet" ' +
<script>
function themeChanged() {
document.getElementById('incognitothemecss').href =
- 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now();
+ 'chrome://theme/css/newincognitotab.css?' + Date.now();
}
</script>
</html>
diff --git a/chrome/browser/resources/incognito_tab.html b/chrome/browser/resources/incognito_tab.html
index d2230e0..03dad1d 100644
--- a/chrome/browser/resources/incognito_tab.html
+++ b/chrome/browser/resources/incognito_tab.html
@@ -6,7 +6,7 @@
<script>
// Until themes can clear the cache, force-reload the theme stylesheet.
document.write('<link id="incognitothemecss" rel="stylesheet" ' +
- 'href="chrome://theme/css/incognito_new_tab_theme.css?' +
+ 'href="chrome://theme/css/newincognitotab.css?' +
Date.now() + '">');
</script>
</head>
@@ -23,7 +23,7 @@ document.write('<link id="incognitothemecss" rel="stylesheet" ' +
<script>
function themeChanged() {
document.getElementById('incognitothemecss').href =
- 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now();
+ 'chrome://theme/css/newincognitotab.css?' + Date.now();
}
function bookmarkBarAttached() {
diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html
index 2bb06dd..6730222 100644
--- a/chrome/browser/resources/ntp4/new_tab.html
+++ b/chrome/browser/resources/ntp4/new_tab.html
@@ -3,8 +3,7 @@
dir:textdirection;
hasattribution:hasattribution;
customlogo:customlogo;
- themegravity:themegravity;
- bookmarkbarattached:bookmarkbarattached;"
+ themegravity:themegravity;"
class="starting-up">
<head>
<meta charset="utf-8">
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index 4cdd44e..621157e 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -261,22 +261,15 @@ cr.define('ntp4', function() {
document.querySelector('head').appendChild(styleElement);
}
- function themeChanged(opt_hasAttribution) {
- $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now();
-
- if (typeof opt_hasAttribution != 'undefined') {
- document.documentElement.setAttribute('hasattribution',
- opt_hasAttribution);
- }
-
+ // TODO(estade): rename newtab.css to new_tab_theme.css
+ function themeChanged(hasAttribution) {
+ $('themecss').href = 'chrome://theme/css/newtab.css?' + Date.now();
+ if (typeof hasAttribution != 'undefined')
+ document.documentElement.setAttribute('hasattribution', hasAttribution);
updateLogo();
updateAttribution();
}
- function setBookmarkBarAttached(attached) {
- document.documentElement.setAttribute('bookmarkbarattached', attached);
- }
-
/**
* Sets the proper image for the logo at the bottom left.
*/
@@ -546,7 +539,6 @@ cr.define('ntp4', function() {
leaveRearrangeMode: leaveRearrangeMode,
saveAppPageName: saveAppPageName,
setAppToBeHighlighted: setAppToBeHighlighted,
- setBookmarkBarAttached: setBookmarkBarAttached,
setMostVisitedPages: setMostVisitedPages,
setRecentlyClosedTabs: setRecentlyClosedTabs,
setStripeColor: setStripeColor,
diff --git a/chrome/browser/resources/ntp4/new_tab_theme.css b/chrome/browser/resources/ntp4/new_tab_theme.css
index 5aab3aa..3a7fe56 100644
--- a/chrome/browser/resources/ntp4/new_tab_theme.css
+++ b/chrome/browser/resources/ntp4/new_tab_theme.css
@@ -2,7 +2,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
-html {
+html,
+#most-visited-settings {
background-attachment: fixed;
background-color: $2; /* COLOR_NTP_BACKGROUND */
background-image: url(chrome://theme/IDR_THEME_NTP_BACKGROUND?$1);
@@ -10,10 +11,6 @@ html {
background-repeat: $5;
}
-html[bookmarkbarattached='true'] {
- background-position: $4;
-}
-
body {
color: $8; /* COLOR_NTP_TEXT */
height: 100%;
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 910d176..e0f8f15 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -29,7 +29,6 @@ using content::BrowserThread;
using content::UserMetricsAction;
// Strings used in alignment properties.
-const char* ThemeService::kAlignmentCenter = "center";
const char* ThemeService::kAlignmentTop = "top";
const char* ThemeService::kAlignmentBottom = "bottom";
const char* ThemeService::kAlignmentLeft = "left";
@@ -378,8 +377,8 @@ std::string ThemeService::GetThemeID() const {
// static
std::string ThemeService::AlignmentToString(int alignment) {
// Convert from an AlignmentProperty back into a string.
- std::string vertical_string(kAlignmentCenter);
- std::string horizontal_string(kAlignmentCenter);
+ std::string vertical_string;
+ std::string horizontal_string;
if (alignment & ThemeService::ALIGN_TOP)
vertical_string = kAlignmentTop;
@@ -391,7 +390,11 @@ std::string ThemeService::AlignmentToString(int alignment) {
else if (alignment & ThemeService::ALIGN_RIGHT)
horizontal_string = kAlignmentRight;
- return horizontal_string + " " + vertical_string;
+ if (vertical_string.empty())
+ return horizontal_string;
+ if (horizontal_string.empty())
+ return vertical_string;
+ return vertical_string + " " + horizontal_string;
}
// static
diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h
index 12964cf..4ecde66 100644
--- a/chrome/browser/themes/theme_service.h
+++ b/chrome/browser/themes/theme_service.h
@@ -52,7 +52,6 @@ class ThemeService : public base::NonThreadSafe,
// Public constants used in ThemeService and its subclasses:
// Strings used in alignment properties.
- static const char* kAlignmentCenter;
static const char* kAlignmentTop;
static const char* kAlignmentBottom;
static const char* kAlignmentLeft;
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index 2a5e295..fe80f87 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -133,8 +133,6 @@ NewTabUI::NewTabUI(content::WebUI* web_ui)
new NewTabHTMLSource(GetProfile()->GetOriginalProfile());
GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source);
- pref_change_registrar_.Init(GetProfile()->GetPrefs());
- pref_change_registrar_.Add(prefs::kShowBookmarkBar, this);
// Listen for theme installation.
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
content::Source<ThemeService>(
@@ -199,19 +197,14 @@ void NewTabUI::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_PREF_CHANGED: { // kShowBookmarkBar
- StringValue attached(
- GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
- "true" : "false");
- web_ui()->CallJavascriptFunction("ntp4.setBookmarkBarAttached", attached);
- break;
- }
case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
InitializeCSSCaches();
- StringValue attribution(
+ ListValue args;
+ args.Append(Value::CreateStringValue(
ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage(
- IDR_THEME_NTP_ATTRIBUTION) ? "true" : "false");
- web_ui()->CallJavascriptFunction("themeChanged", attribution);
+ IDR_THEME_NTP_ATTRIBUTION) ?
+ "true" : "false"));
+ web_ui()->CallJavascriptFunction("themeChanged", args);
break;
}
case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: {
@@ -251,6 +244,7 @@ void NewTabUI::SetupFieldTrials() {
g_hint_group = trial->AppendGroup("PlusIcon", 40);
}
+
// static
bool NewTabUI::ShouldShowWebStoreFooterLink() {
const CommandLine* cli = CommandLine::ForCurrentProcess();
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chrome/browser/ui/webui/ntp/new_tab_ui.h
index 9cd11b5..885e271 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.h
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -11,7 +11,6 @@
#include "base/gtest_prod_util.h"
#include "base/time.h"
#include "base/timer.h"
-#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "content/public/browser/notification_observer.h"
@@ -117,8 +116,6 @@ class NewTabUI : public content::WebUIController,
// If the sync promo NTP bubble is being shown.
bool showing_sync_bubble_;
- PrefChangeRegistrar pref_change_registrar_;
-
DISALLOW_COPY_AND_ASSIGN(NewTabUI);
};
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 7d18d9c..724ed32 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -141,9 +141,9 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
if (alignment & ThemeService::ALIGN_TOP) {
if (alignment & ThemeService::ALIGN_LEFT)
- return "left " + base::IntToString(-offset) + "px";
+ return "0% " + base::IntToString(-offset) + "px";
else if (alignment & ThemeService::ALIGN_RIGHT)
- return "right " + base::IntToString(-offset) + "px";
+ return "100% " + base::IntToString(-offset) + "px";
return "center " + base::IntToString(-offset) + "px";
}
return ThemeService::AlignmentToString(alignment);
diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc
index 1dda6ff..bc07fff 100644
--- a/chrome/browser/ui/webui/theme_source.cc
+++ b/chrome/browser/ui/webui/theme_source.cc
@@ -21,8 +21,8 @@
using content::BrowserThread;
// use a resource map rather than hard-coded strings.
-static const char* kNewTabCSSPath = "css/new_tab_theme.css";
-static const char* kNewIncognitoTabCSSPath = "css/incognito_new_tab_theme.css";
+static const char* kNewTabCSSPath = "css/newtab.css";
+static const char* kNewIncognitoTabCSSPath = "css/newincognitotab.css";
static std::string StripQueryParams(const std::string& path) {
GURL path_url = GURL(std::string(chrome::kChromeUIScheme) + "://" +