| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
| index a88c010ae185587e8ac944a500684a4a5a27dbd6..7912a5db83d4fb57098caab7af07c5d600237498 100644
|
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
| @@ -32,8 +32,6 @@
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| #include "chrome/browser/ui/chrome_pages.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_instructions_view.h"
|
| #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h"
|
| @@ -134,23 +132,8 @@ 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;
|
| -
|
| -// TODO(kuan): change BookmarkBarView::kNewtabHorizontalPadding to this new
|
| -// valud when search_ntp replaces ntp4; for now, while both versions exist, this
|
| -// new padding value is only needed locally.
|
| -static const int kSearchNewtabHorizontalPadding = 0;
|
| -
|
| namespace {
|
|
|
| -bool IsDetachedAtBottom(Browser* browser) {
|
| - return browser->search_model()->mode().is_ntp() &&
|
| - browser->bookmark_bar_state() == BookmarkBar::DETACHED;
|
| -}
|
| -
|
| // BookmarkButton -------------------------------------------------------------
|
|
|
| // Buttons used for the bookmarks on the bookmark bar.
|
| @@ -163,10 +146,10 @@ class BookmarkButton : public views::TextButton {
|
| BookmarkButton(views::ButtonListener* listener,
|
| const GURL& url,
|
| const string16& title,
|
| - Browser* browser)
|
| + Profile* profile)
|
| : TextButton(listener, title),
|
| url_(url),
|
| - browser_(browser) {
|
| + profile_(profile) {
|
| show_animation_.reset(new ui::SlideAnimation(this));
|
| if (bookmark_utils::IsBookmarkBarViewAnimationsDisabled()) {
|
| // For some reason during testing the events generated by animating
|
| @@ -182,8 +165,7 @@ class BookmarkButton : public views::TextButton {
|
| gfx::Point location(p);
|
| ConvertPointToScreen(this, &location);
|
| *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle(
|
| - location, url_, text(), browser_->profile(),
|
| - GetWidget()->GetNativeView());
|
| + location, url_, text(), profile_, GetWidget()->GetNativeView());
|
| return !tooltip->empty();
|
| }
|
|
|
| @@ -197,24 +179,9 @@ class BookmarkButton : public views::TextButton {
|
| return kViewClassName;
|
| }
|
|
|
| - protected:
|
| -// Without Aura, transparency can't be used and text looks bad without subpix.
|
| -#if defined(USE_AURA)
|
| - // views::TextButton overrides.
|
| - virtual int ComputeCanvasStringFlags() const OVERRIDE {
|
| - int flags = views::TextButton::ComputeCanvasStringFlags();
|
| - // If search mode is |NTP| and bookmark bar is detached, button background
|
| - // is transparent, so button text needs to be rendered without subpixel
|
| - // rendering to avoid ugly artifacts.
|
| - if (IsDetachedAtBottom(browser_))
|
| - flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
|
| - return flags;
|
| - }
|
| -#endif
|
| -
|
| private:
|
| const GURL& url_;
|
| - Browser* browser_; // Weak.
|
| + Profile* profile_;
|
| scoped_ptr<ui::SlideAnimation> show_animation_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BookmarkButton);
|
| @@ -233,10 +200,8 @@ class BookmarkFolderButton : public views::MenuButton {
|
| BookmarkFolderButton(views::ButtonListener* listener,
|
| const string16& title,
|
| views::MenuButtonListener* menu_button_listener,
|
| - bool show_menu_marker,
|
| - Browser* browser)
|
| - : MenuButton(listener, title, menu_button_listener, show_menu_marker),
|
| - browser_(browser) {
|
| + bool show_menu_marker)
|
| + : MenuButton(listener, title, menu_button_listener, show_menu_marker) {
|
| show_animation_.reset(new ui::SlideAnimation(this));
|
| if (bookmark_utils::IsBookmarkBarViewAnimationsDisabled()) {
|
| // For some reason during testing the events generated by animating
|
| @@ -272,22 +237,7 @@ class BookmarkFolderButton : public views::MenuButton {
|
| views::MenuButton::PaintButton(canvas, views::MenuButton::PB_NORMAL);
|
| }
|
|
|
| - protected:
|
| -// Without Aura, transparency can't be used and text looks bad without subpix.
|
| -#if defined(USE_AURA)
|
| - // views::MenuButton overrides.
|
| - virtual int ComputeCanvasStringFlags() const OVERRIDE {
|
| - int flags = views::MenuButton::ComputeCanvasStringFlags();
|
| - // See explanation for BookmarkBarButton::ComputeCanvasStringFlags that also
|
| - // applies here.
|
| - if (IsDetachedAtBottom(browser_))
|
| - flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
|
| - return flags;
|
| - }
|
| -#endif
|
| -
|
| private:
|
| - Browser* browser_; // Weak.
|
| scoped_ptr<ui::SlideAnimation> show_animation_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton);
|
| @@ -321,21 +271,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| extension_misc::APP_LAUNCH_BOOKMARK_BAR);
|
| }
|
|
|
| -int GetSearchNtpMargin(int full_width) {
|
| - // Horizontally center bookmark bar.
|
| - int width =
|
| - full_width - 2 * chrome::search::kHorizontalPaddingForBottomBookmarkBar;
|
| - if (width > chrome::search::kMaxWidthForBottomBookmarkBar)
|
| - width = chrome::search::kMaxWidthForBottomBookmarkBar;
|
| - return (full_width - width) / 2;
|
| -}
|
| -
|
| -int GetNtpHorizontalPadding(const chrome::search::Mode& search_mode,
|
| - bool is_detached) {
|
| - return search_mode.is_ntp() && is_detached ? kSearchNewtabHorizontalPadding :
|
| - BookmarkBarView::kNewtabHorizontalPadding;
|
| -}
|
| -
|
| } // namespace
|
|
|
| // DropLocation ---------------------------------------------------------------
|
| @@ -488,8 +423,7 @@ void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) {
|
|
|
| void BookmarkBarView::SetBookmarkBarState(
|
| BookmarkBar::State state,
|
| - BookmarkBar::AnimateChangeType animate_type,
|
| - const chrome::search::Mode& search_mode) {
|
| + BookmarkBar::AnimateChangeType animate_type) {
|
| if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE) {
|
| animating_detached_ = (state == BookmarkBar::DETACHED ||
|
| bookmark_bar_state_ == BookmarkBar::DETACHED);
|
| @@ -501,25 +435,6 @@ void BookmarkBarView::SetBookmarkBarState(
|
| size_animation_->Reset(state == BookmarkBar::SHOW ? 1 : 0);
|
| }
|
| bookmark_bar_state_ = state;
|
| -
|
| -#if defined(USE_AURA)
|
| - // If we're detached and search mode is |NTP|, we'll be stacking us on top of
|
| - // content view, so set to use layer.
|
| - SetPaintToLayer(bookmark_bar_state_ == BookmarkBar::DETACHED &&
|
| - search_mode.is_ntp());
|
| - SetFillsBoundsOpaquely(false);
|
| -#endif // defined(USE_AURA)
|
| -}
|
| -
|
| -void BookmarkBarView::MaybeStackAtTop() {
|
| -#if defined(USE_AURA)
|
| - // If we're visible and search mode is |NTP| with layers, stack us on top,
|
| - // so that we float on top of content view below the most-visited thumbnails.
|
| - if (visible() && browser_->search_model()->mode().is_ntp() && layer() &&
|
| - layer()->parent()) {
|
| - layer()->parent()->StackAtTop(layer());
|
| - }
|
| -#endif // defined(USE_AURA)
|
| }
|
|
|
| int BookmarkBarView::GetToolbarOverlap(bool return_max) const {
|
| @@ -671,16 +586,6 @@ int BookmarkBarView::GetToolbarOverlap() const {
|
| return GetToolbarOverlap(false);
|
| }
|
|
|
| -int BookmarkBarView::GetLeftMargin() const {
|
| - return browser_->search_model()->mode().is_ntp() && IsDetached() ?
|
| - GetSearchNtpMargin(width()) : kLeftMargin;
|
| -}
|
| -
|
| -int BookmarkBarView::GetRightMargin() const {
|
| - return browser_->search_model()->mode().is_ntp() && IsDetached() ?
|
| - GetSearchNtpMargin(width()) : kRightMargin;
|
| -}
|
| -
|
| gfx::Size BookmarkBarView::GetPreferredSize() {
|
| return LayoutItems(true);
|
| }
|
| @@ -689,14 +594,11 @@ gfx::Size BookmarkBarView::GetMinimumSize() {
|
| // The minimum width of the bookmark bar should at least contain the overflow
|
| // button, by which one can access all the Bookmark Bar items, and the "Other
|
| // Bookmarks" folder, along with appropriate margins and button padding.
|
| - int width = GetLeftMargin();
|
| + int width = kLeftMargin;
|
|
|
| if (bookmark_bar_state_ == BookmarkBar::DETACHED) {
|
| double current_state = 1 - size_animation_->GetCurrentValue();
|
| - width += 2 * static_cast<int>(
|
| - GetNtpHorizontalPadding(browser_->search_model()->mode(),
|
| - IsDetached()) *
|
| - current_state);
|
| + width += 2 * static_cast<int>(kNewtabHorizontalPadding * current_state);
|
| }
|
|
|
| gfx::Size other_bookmarked_pref =
|
| @@ -748,7 +650,7 @@ void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) {
|
| int h = height();
|
| if (index == GetBookmarkButtonCount()) {
|
| if (index == 0) {
|
| - x = GetLeftMargin();
|
| + x = kLeftMargin;
|
| } else {
|
| x = GetBookmarkButton(index - 1)->x() +
|
| GetBookmarkButton(index - 1)->width();
|
| @@ -1280,8 +1182,7 @@ int BookmarkBarView::GetFirstHiddenNodeIndex() {
|
|
|
| MenuButton* BookmarkBarView::CreateOtherBookmarkedButton() {
|
| // Title is set in Loaded.
|
| - MenuButton* button = new BookmarkFolderButton(this, string16(), this, false,
|
| - browser_);
|
| + MenuButton* button = new BookmarkFolderButton(this, string16(), this, false);
|
| button->set_id(VIEW_ID_OTHER_BOOKMARKS);
|
| button->SetIcon(GetFolderIcon());
|
| button->set_context_menu_controller(this);
|
| @@ -1314,12 +1215,12 @@ MenuButton* BookmarkBarView::CreateOverflowButton() {
|
| views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) {
|
| if (node->is_url()) {
|
| BookmarkButton* button = new BookmarkButton(
|
| - this, node->url(), node->GetTitle(), browser_);
|
| + this, node->url(), node->GetTitle(), browser_->profile());
|
| ConfigureButton(node, button);
|
| return button;
|
| } else {
|
| views::MenuButton* button = new BookmarkFolderButton(
|
| - this, node->GetTitle(), this, false, browser_);
|
| + this, node->GetTitle(), this, false);
|
| button->SetIcon(GetFolderIcon());
|
| ConfigureButton(node, button);
|
| return button;
|
| @@ -1652,21 +1553,18 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
|
| if (!parent() && !compute_bounds_only)
|
| return prefsize;
|
|
|
| - int x = GetLeftMargin();
|
| + int x = kLeftMargin;
|
| int top_margin = IsDetached() ? kDetachedTopMargin : 0;
|
| int y = top_margin;
|
| - int width = this->width() - GetRightMargin() - x;
|
| + int width = View::width() - kRightMargin - kLeftMargin;
|
| int height = -top_margin - kBottomMargin;
|
| int separator_margin = kSeparatorMargin;
|
|
|
| if (IsDetached()) {
|
| double current_state = 1 - size_animation_->GetCurrentValue();
|
| - int horizontal_padding =
|
| - GetNtpHorizontalPadding(browser_->search_model()->mode(), IsDetached());
|
| - int x_inset = static_cast<int>(horizontal_padding * current_state);
|
| - x += x_inset;
|
| - width -= 2 * x_inset;
|
| + x += static_cast<int>(kNewtabHorizontalPadding * current_state);
|
| y += static_cast<int>(kNewtabVerticalPadding * current_state);
|
| + width -= static_cast<int>(kNewtabHorizontalPadding * current_state);
|
| height += View::height() -
|
| static_cast<int>(kNewtabVerticalPadding * 2 * current_state);
|
| separator_margin -= static_cast<int>(kSeparatorMargin * current_state);
|
| @@ -1684,20 +1582,14 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
|
| gfx::Size bookmarks_separator_pref =
|
| bookmarks_separator_view_->GetPreferredSize();
|
|
|
| - // The max_x is the last possible x position for a bookmark. Since width
|
| - // already accounts for left/right margins and padding, we must add back the
|
| - // x position of the first bookmark and remove more padding needed at the end.
|
| - int max_x = x + width - overflow_pref.width() - kButtonPadding -
|
| + int max_x = width - overflow_pref.width() - kButtonPadding -
|
| bookmarks_separator_pref.width();
|
| if (other_bookmarked_button_->visible())
|
| max_x -= other_bookmarked_pref.width() + kButtonPadding;
|
|
|
| // Next, layout out the buttons. Any buttons that are placed beyond the
|
| // visible region and made invisible.
|
| - // Don't show instructions if bookmark bar is detached at bottom i.e. in |NTP|
|
| - // mode.
|
| - if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded() &&
|
| - !(browser_->search_model()->mode().is_ntp() && IsDetached())) {
|
| + if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) {
|
| gfx::Size pref = instructions_->GetPreferredSize();
|
| if (!compute_bounds_only) {
|
| instructions_->SetBounds(
|
| @@ -1764,19 +1656,15 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
|
|
|
| // Set the preferred size computed so far.
|
| if (compute_bounds_only) {
|
| - x += GetRightMargin();
|
| + 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>(
|
| - GetNtpHorizontalPadding(browser_->search_model()->mode(),
|
| - IsDetached()) *
|
| - (1 - size_animation_->GetCurrentValue()));
|
| + kNewtabHorizontalPadding * (1 - size_animation_->GetCurrentValue()));
|
| prefsize.set_height(
|
| browser_defaults::kBookmarkBarHeight +
|
| static_cast<int>(
|
| - (ntp_bookmark_bar_height -
|
| + (chrome::kNTPBookmarkBarHeight -
|
| browser_defaults::kBookmarkBarHeight) *
|
| (1 - size_animation_->GetCurrentValue())));
|
| } else {
|
|
|