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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.cc

Issue 11365075: alternate ntp: tweaks and fixes for bookmark bar in ntp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/ui/browser_finder.h" 7 #include "chrome/browser/ui/browser_finder.h"
8 #include "chrome/browser/ui/find_bar/find_bar.h" 8 #include "chrome/browser/ui/find_bar/find_bar.h"
9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
10 #include "chrome/browser/ui/search/search_model.h" 10 #include "chrome/browser/ui/search/search_model.h"
11 #include "chrome/browser/ui/search/search_ui.h"
11 #include "chrome/browser/ui/view_ids.h" 12 #include "chrome/browser/ui/view_ids.h"
12 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 13 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
13 #include "chrome/browser/ui/views/download/download_shelf_view.h" 14 #include "chrome/browser/ui/views/download/download_shelf_view.h"
14 #include "chrome/browser/ui/views/frame/browser_frame.h" 15 #include "chrome/browser/ui/views/frame/browser_frame.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/frame/contents_container.h" 17 #include "chrome/browser/ui/views/frame/contents_container.h"
17 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 18 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
18 #include "chrome/browser/ui/views/tabs/tab_strip.h" 19 #include "chrome/browser/ui/views/tabs/tab_strip.h"
19 #include "chrome/browser/ui/views/toolbar_view.h" 20 #include "chrome/browser/ui/views/toolbar_view.h"
20 #include "ui/base/hit_test.h" 21 #include "ui/base/hit_test.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 active_bookmark_bar_->GetToolbarOverlap(false); 416 active_bookmark_bar_->GetToolbarOverlap(false);
416 active_bookmark_bar_->SetVisible(true); 417 active_bookmark_bar_->SetVisible(true);
417 active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(), y, 418 active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(), y,
418 vertical_layout_rect_.width(), 419 vertical_layout_rect_.width(),
419 bookmark_bar_height); 420 bookmark_bar_height);
420 return y + bookmark_bar_height; 421 return y + bookmark_bar_height;
421 } 422 }
422 423
423 void BrowserViewLayout::LayoutBookmarkBarAtBottom() { 424 void BrowserViewLayout::LayoutBookmarkBarAtBottom() {
424 DCHECK(active_bookmark_bar_); 425 DCHECK(active_bookmark_bar_);
426 // Layout bookmark bar at bottom of content view in the y-direction.
427 // Bookmark bar is child of |BrowserView| while content view is child of
428 // ContentsContainer, so convert its bottom coordinate relative to
429 // |BrowserView|.
425 gfx::Point content_bottom( 430 gfx::Point content_bottom(
426 0, browser_view_->contents_container_->bounds().bottom()); 431 0, browser_view_->contents_container_->bounds().bottom());
427 views::View::ConvertPointToTarget( 432 views::View::ConvertPointToTarget(
428 browser_view_->contents_container_->parent(), browser_view_, 433 browser_view_->contents_container_->parent(), browser_view_,
429 &content_bottom); 434 &content_bottom);
430 if (!browser_view_->IsBookmarkBarVisible()) { 435 // Only show bookmark bar if height of content view is >=
436 // chrome::search::kMinContentHeightForBottomBookmarkBar.
437 if (browser_view_->contents_container_->height() <
438 chrome::search::kMinContentHeightForBottomBookmarkBar ||
439 !browser_view_->IsBookmarkBarVisible()) {
431 active_bookmark_bar_->SetVisible(false); 440 active_bookmark_bar_->SetVisible(false);
432 active_bookmark_bar_->SetBounds(0, content_bottom.y(), 441 active_bookmark_bar_->SetBounds(0, content_bottom.y(),
433 browser_view_->width(), 0); 442 browser_view_->width(), 0);
443 return;
434 } 444 }
435 445
436 // BookmarkBarView uses infobar visibility to determine toolbar overlap, which 446 // BookmarkBarView uses infobar visibility to determine toolbar overlap, which
437 // is 0 if bookmark bar is detached and infobar is visible. Since the 447 // is 0 if bookmark bar is detached and infobar is visible. Since the
438 // bookmark bar on the NTP is detached at bottom of content view, toolbar 448 // bookmark bar on the NTP is detached at bottom of content view, toolbar
439 // overlap is irrelevant. So set infobar visible to force no toolbar overlap. 449 // overlap is irrelevant. So set infobar visible to force no toolbar overlap.
440 active_bookmark_bar_->set_infobar_visible(true); 450 active_bookmark_bar_->set_infobar_visible(true);
451 active_bookmark_bar_->SetVisible(true);
441 int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height(); 452 int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height();
442 active_bookmark_bar_->SetVisible(true);
443 active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(), 453 active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(),
444 content_bottom.y() - bookmark_bar_height, 454 content_bottom.y() - bookmark_bar_height,
445 vertical_layout_rect_.width(), 455 vertical_layout_rect_.width(),
446 bookmark_bar_height); 456 bookmark_bar_height);
447 } 457 }
448 458
449 int BrowserViewLayout::LayoutInfoBar(int top) { 459 int BrowserViewLayout::LayoutInfoBar(int top) {
450 // Raise the |infobar_container_| by its vertical overlap. 460 // Raise the |infobar_container_| by its vertical overlap.
451 infobar_container_->SetVisible(InfobarVisible()); 461 infobar_container_->SetVisible(InfobarVisible());
452 int height; 462 int height;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 bottom -= height; 543 bottom -= height;
534 } 544 }
535 return bottom; 545 return bottom;
536 } 546 }
537 547
538 bool BrowserViewLayout::InfobarVisible() const { 548 bool BrowserViewLayout::InfobarVisible() const {
539 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 549 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
540 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 550 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
541 (infobar_container_->GetPreferredSize().height() != 0); 551 (infobar_container_->GetPreferredSize().height() != 0);
542 } 552 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698