summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 18:23:58 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 18:23:58 +0000
commitb9b150bafaa855018e4af087962dcf4a5d7436f2 (patch)
tree5b1a55a1a78f2dff9b6c5db2f94e50e62cdcf857
parenta7db59a612909895bc4cfefb38da59eb16afd630 (diff)
downloadchromium_src-b9b150bafaa855018e4af087962dcf4a5d7436f2.zip
chromium_src-b9b150bafaa855018e4af087962dcf4a5d7436f2.tar.gz
chromium_src-b9b150bafaa855018e4af087962dcf4a5d7436f2.tar.bz2
alternate ntp: tweaks and fixes for bookmark bar in ntp
- change bmb height to 48 - paint separator above bmb with different colors for standard and theme - bmb background * if theme is used, paint theme background color at max 80% opacity * otherwise, use transparent background - only show bmb when at least a row of "Most Visited" thumbnails is shown - don't show instruction bmb - fix new tab css to let content view show entire theme background image with no vertical offset, 'cos floating detached bmb doesn't show any part of the image - fix to paint separator below bmb after a suggestion is committed BUG=158944 TEST=verify per bug rpt Review URL: https://chromiumcodereview.appspot.com/11365075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165963 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/ntp_search/tile_page.js11
-rw-r--r--chrome/browser/ui/search/search_ui.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc12
-rw-r--r--chrome/browser/ui/views/detachable_toolbar_view.cc12
-rw-r--r--chrome/browser/ui/views/detachable_toolbar_view.h8
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc33
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout.cc14
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc25
8 files changed, 91 insertions, 26 deletions
diff --git a/chrome/browser/resources/ntp_search/tile_page.js b/chrome/browser/resources/ntp_search/tile_page.js
index 00af6cd..b7067bc 100644
--- a/chrome/browser/resources/ntp_search/tile_page.js
+++ b/chrome/browser/resources/ntp_search/tile_page.js
@@ -10,13 +10,14 @@ cr.define('ntp', function() {
//----------------------------------------------------------------------------
/**
- * Bottom Panel's minimum padding bottom, which is 57 (the height of bookmark
- * bar in detached mode as defined by chrome::kNTPBookmarkBarHeight) minus 12
- * (top padding of a bookmark button).
+ * Bottom Panel's minimum padding bottom, which is 48 (the height of bookmark
+ * bar in detached mode as defined by kSearchNewtabBookmarkBarHeight in
+ * chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc minus 12 (top
+ * padding of a bookmark button).
* @type {number}
* @const
*/
- var BOTTOM_PANEL_MIN_PADDING_BOTTOM = 45;
+ var BOTTOM_PANEL_MIN_PADDING_BOTTOM = 36;
/**
* The height required to show 2 rows of Tiles in the Bottom Panel.
@@ -40,7 +41,7 @@ cr.define('ntp', function() {
// TODO(pedrosimonetti): This value is related to
// kMinContentHeightForBottomBookmarkBar defined in chrome/browser/ui/search/
// search_ui.h. Change that value when calulation of bottom panel changes.
- var HEIGHT_FOR_BOTTOM_PANEL = 600;
+ var HEIGHT_FOR_BOTTOM_PANEL = 591;
/**
* The Bottom Panel width required to show 5 cols of Tiles, which is used
diff --git a/chrome/browser/ui/search/search_ui.cc b/chrome/browser/ui/search/search_ui.cc
index 590ff85..0ca1b62 100644
--- a/chrome/browser/ui/search/search_ui.cc
+++ b/chrome/browser/ui/search/search_ui.cc
@@ -13,7 +13,7 @@
namespace chrome {
namespace search {
-const int kMinContentHeightForBottomBookmarkBar = 277;
+const int kMinContentHeightForBottomBookmarkBar = 268;
} // namespace search
} // namespace chrome
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 2811a56..2a80475 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -134,6 +134,11 @@ static const int kInstructionsPadding = 6;
// Tag for the 'Other bookmarks' button.
static const int kOtherFolderButtonTag = 1;
+// TODO(kuan): change chrome::kNTPBookmarkBarHeight to this new height when
+// search_ntp replaces ntp4; for now, while both versions exist, this new height
+// is only needed locally.
+static const int kSearchNewtabBookmarkBarHeight = 48;
+
namespace {
// BookmarkButton -------------------------------------------------------------
@@ -1659,7 +1664,8 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
// Next, layout out the buttons. Any buttons that are placed beyond the
// visible region and made invisible.
- if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) {
+ if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded() &&
+ !browser_->search_model()->mode().is_ntp()) {
gfx::Size pref = instructions_->GetPreferredSize();
if (!compute_bounds_only) {
instructions_->SetBounds(
@@ -1729,12 +1735,14 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
x += kRightMargin;
prefsize.set_width(x);
if (IsDetached()) {
+ int ntp_bookmark_bar_height = browser_->search_model()->mode().is_ntp() ?
+ kSearchNewtabBookmarkBarHeight : chrome::kNTPBookmarkBarHeight;
x += static_cast<int>(
kNewtabHorizontalPadding * (1 - size_animation_->GetCurrentValue()));
prefsize.set_height(
browser_defaults::kBookmarkBarHeight +
static_cast<int>(
- (chrome::kNTPBookmarkBarHeight -
+ (ntp_bookmark_bar_height -
browser_defaults::kBookmarkBarHeight) *
(1 - size_animation_->GetCurrentValue())));
} else {
diff --git a/chrome/browser/ui/views/detachable_toolbar_view.cc b/chrome/browser/ui/views/detachable_toolbar_view.cc
index f1f9a40..354af9f 100644
--- a/chrome/browser/ui/views/detachable_toolbar_view.cc
+++ b/chrome/browser/ui/views/detachable_toolbar_view.cc
@@ -65,12 +65,20 @@ void DetachableToolbarView::CalculateContentArea(
// static
void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas,
DetachableToolbarView* view) {
+ PaintHorizontalBorderWithColor(canvas, view,
+ ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
+}
+
+// static
+void DetachableToolbarView::PaintHorizontalBorderWithColor(
+ gfx::Canvas* canvas,
+ DetachableToolbarView* view,
+ SkColor border_color) {
// Border can be at the top or at the bottom of the view depending on whether
// the view (bar/shelf) is attached or detached.
int thickness = views::NonClientFrameView::kClientEdgeThickness;
int y = view->IsDetached() ? 0 : (view->height() - thickness);
- canvas->FillRect(gfx::Rect(0, y, view->width(), thickness),
- ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
+ canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), border_color);
}
// static
diff --git a/chrome/browser/ui/views/detachable_toolbar_view.h b/chrome/browser/ui/views/detachable_toolbar_view.h
index 13f0309..4d3666a 100644
--- a/chrome/browser/ui/views/detachable_toolbar_view.h
+++ b/chrome/browser/ui/views/detachable_toolbar_view.h
@@ -50,10 +50,16 @@ class DetachableToolbarView : public views::AccessiblePaneView {
double* roundness,
views::View* view);
- // Paint the horizontal border separating the shelf/bar from the page content.
+ // Paint the horizontal border separating the shelf/bar from the page content,
+ // with COLOR_TOOLBAR_SEPARATOR.
static void PaintHorizontalBorder(gfx::Canvas* canvas,
DetachableToolbarView* view);
+ // Similar to PaintHorizontalBorder but with the specified |border_color|.
+ static void PaintHorizontalBorderWithColor(gfx::Canvas* canvas,
+ DetachableToolbarView* view,
+ SkColor border_color);
+
// Paint the background of the content area (the surface behind the
// bookmarks). |rect| is the rectangle to paint the background within.
// |roundness| describes the roundness of the corners.
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index d2c899b..d2e9364 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -14,6 +14,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/tab_helper.h"
@@ -221,6 +223,8 @@ BookmarkExtensionBackground::BookmarkExtensionBackground(
void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
views::View* view) const {
+ ui::ThemeProvider* tp = host_view_->GetThemeProvider();
+
// If search mode is |NTP|, bookmark bar is detached and floating on top of
// the content view (in z-order) and below the "Most Visited" thumbnails (in
// the y-direction). It's visually nicer without the bookmark background, so
@@ -228,10 +232,31 @@ void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
// each bookmark button is part of the content view.
const chrome::search::Mode& search_mode =
browser_view_->browser()->search_model()->mode();
- if (search_mode.is_ntp())
+ if (search_mode.is_ntp()) {
+ BookmarkModel* bookmark_model =
+ BookmarkModelFactory::GetForProfile(browser_->profile());
+ if (bookmark_model && bookmark_model->HasBookmarks()) {
+ // If a theme is being used, paint the theme background color at maximum
+ // 80% opacity to make the the bookmark bar more legible;
+ // otherwise, use a transparent background.
+ if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
+ const U8CPU kBackgroundOpacity = 204; // 80% opacity
+ SkColor color = tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND);
+ if (gfx::IsInvertedColorScheme())
+ color = color_utils::InvertColor(color);
+ if (SkColorGetA(color) > kBackgroundOpacity)
+ color = SkColorSetA(color, kBackgroundOpacity);
+ canvas->DrawColor(color);
+ DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
+ } else {
+ const SkColor kBorderColor = SkColorSetARGB(25, 0, 0, 0); // 10% black
+ DetachableToolbarView::PaintHorizontalBorderWithColor(
+ canvas, host_view_, kBorderColor);
+ }
+ }
return;
+ }
- ui::ThemeProvider* tp = host_view_->GetThemeProvider();
int toolbar_overlap = host_view_->GetToolbarOverlap();
// The client edge is drawn below the toolbar bounds.
if (toolbar_overlap)
@@ -272,9 +297,7 @@ void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_,
browser_view_->OffsetPointForToolbarBackgroundImage(
gfx::Point(host_view_->GetMirroredX(), host_view_->y())));
- // For instant extended API, only draw bookmark separator for |MODE_DFEAULT|
- // mode.
- if (host_view_->height() >= toolbar_overlap && search_mode.is_default())
+ if (host_view_->height() >= toolbar_overlap)
DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
}
}
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index a1452cc..51f897b 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/ui/find_bar/find_bar.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/search/search_model.h"
+#include "chrome/browser/ui/search/search_ui.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
@@ -422,15 +423,24 @@ int BrowserViewLayout::LayoutBookmarkBarAtTop(int top) {
void BrowserViewLayout::LayoutBookmarkBarAtBottom() {
DCHECK(active_bookmark_bar_);
+ // Layout bookmark bar at bottom of content view in the y-direction.
+ // Bookmark bar is child of |BrowserView| while content view is child of
+ // ContentsContainer, so convert its bottom coordinate relative to
+ // |BrowserView|.
gfx::Point content_bottom(
0, browser_view_->contents_container_->bounds().bottom());
views::View::ConvertPointToTarget(
browser_view_->contents_container_->parent(), browser_view_,
&content_bottom);
- if (!browser_view_->IsBookmarkBarVisible()) {
+ // Only show bookmark bar if height of content view is >=
+ // chrome::search::kMinContentHeightForBottomBookmarkBar.
+ if (browser_view_->contents_container_->height() <
+ chrome::search::kMinContentHeightForBottomBookmarkBar ||
+ !browser_view_->IsBookmarkBarVisible()) {
active_bookmark_bar_->SetVisible(false);
active_bookmark_bar_->SetBounds(0, content_bottom.y(),
browser_view_->width(), 0);
+ return;
}
// BookmarkBarView uses infobar visibility to determine toolbar overlap, which
@@ -438,8 +448,8 @@ void BrowserViewLayout::LayoutBookmarkBarAtBottom() {
// bookmark bar on the NTP is detached at bottom of content view, toolbar
// overlap is irrelevant. So set infobar visible to force no toolbar overlap.
active_bookmark_bar_->set_infobar_visible(true);
- int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height();
active_bookmark_bar_->SetVisible(true);
+ int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height();
active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(),
content_bottom.y() - bookmark_bar_height,
vertical_layout_rect_.width(),
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 73e81d4..5b2a045 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -118,7 +118,8 @@ SkColor GetThemeColor(ui::ThemeProvider* tp, int id) {
// Get the CSS string for the background position on the new tab page for the
// states when the bar is attached or detached.
std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
- bool bar_attached) {
+ bool bar_attached,
+ bool is_ntp_search) {
int alignment;
theme_provider->GetDisplayProperty(
ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment);
@@ -131,7 +132,12 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
return "-64px";
}
- if (bar_attached)
+ // For instant extended API i.e. |is_ntp_search| is true, bookmark bar is
+ // always detached at bottom of content view in the y-direction, floating on
+ // top of it in the z-order, and not showing any part of the theme background
+ // image, so the content view should show the entire theme background image as
+ // is, with no vertical offset.
+ if (bar_attached || is_ntp_search)
return ThemeService::AlignmentToString(alignment);
if (alignment & ThemeService::ALIGN_TOP) {
@@ -455,10 +461,12 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() {
subst.push_back(
profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1
+ bool is_ntp_search = chrome::search::IsInstantExtendedAPIEnabled(profile_);
+
// Colors.
subst.push_back(SkColorToRGBAString(color_background)); // $2
- subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3
- subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4
+ subst.push_back(GetNewTabBackgroundCSS(tp, false, is_ntp_search)); // $3
+ subst.push_back(GetNewTabBackgroundCSS(tp, true, is_ntp_search)); // $4
subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5
// Get our template.
@@ -529,10 +537,12 @@ void NTPResourceCache::CreateNewTabCSS() {
subst.push_back(
profile_->GetPrefs()->GetString(prefs::kCurrentThemeID)); // $1
+ bool is_ntp_search = chrome::search::IsInstantExtendedAPIEnabled(profile_);
+
// Colors.
subst.push_back(SkColorToRGBAString(color_background)); // $2
- subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3
- subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4
+ subst.push_back(GetNewTabBackgroundCSS(tp, false, is_ntp_search)); // $3
+ subst.push_back(GetNewTabBackgroundCSS(tp, true, is_ntp_search)); // $4
subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5
subst.push_back(SkColorToRGBAString(color_header)); // $6
subst.push_back(SkColorToRGBAString(color_header_gradient_light)); // $7
@@ -558,8 +568,7 @@ void NTPResourceCache::CreateNewTabCSS() {
// Get our template.
static const base::StringPiece new_tab_theme_css(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- chrome::search::IsInstantExtendedAPIEnabled(profile_) ?
+ ResourceBundle::GetSharedInstance().GetRawDataResource(is_ntp_search ?
IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS));
// Create the string from our template and the replacements.