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

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 7373006: When the chrome window is maximized, make sure the new tab button extends (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/tabs/tab_strip.cc
===================================================================
--- chrome/browser/ui/views/tabs/tab_strip.cc (revision 92539)
+++ chrome/browser/ui/views/tabs/tab_strip.cc (working copy)
@@ -14,6 +14,8 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/tabs/tab_strip_selection_model.h"
#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
@@ -77,8 +79,8 @@
class NewTabButton : public views::ImageButton {
public:
- explicit NewTabButton(views::ButtonListener* listener)
- : views::ImageButton(listener) {
+ explicit NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
+ : views::ImageButton(listener), tab_strip_(tab_strip) {
}
virtual ~NewTabButton() {}
@@ -88,7 +90,7 @@
// When the button is sized to the top of the tab strip we want the user to
// be able to click on complete bounds, and so don't return a custom hit
// mask.
- return !browser_defaults::kSizeTabButtonToTopOfTabStrip;
+ return !tab_strip_->SizeTabButtonToTopOfTabStrip();
}
virtual void GetHitTestMask(gfx::Path* path) const {
DCHECK(path);
@@ -110,6 +112,9 @@
}
private:
+ // Tab strip that contains this button.
+ TabStrip* tab_strip_;
+
DISALLOW_COPY_AND_ASSIGN(NewTabButton);
};
@@ -121,14 +126,15 @@
// static
const int TabStrip::mini_to_non_mini_gap_ = 3;
-TabStrip::TabStrip(TabStripController* controller)
+TabStrip::TabStrip(Browser* browser, TabStripController* controller)
: BaseTabStrip(controller, BaseTabStrip::HORIZONTAL_TAB_STRIP),
newtab_button_(NULL),
current_unselected_width_(Tab::GetStandardSize().width()),
current_selected_width_(Tab::GetStandardSize().width()),
available_width_for_tabs_(-1),
in_tab_close_(false),
- animation_container_(new ui::AnimationContainer()) {
+ animation_container_(new ui::AnimationContainer()),
+ browser_(browser) {
Init();
}
@@ -150,11 +156,7 @@
}
void TabStrip::InitTabStripButtons() {
- newtab_button_ = new NewTabButton(this);
- if (browser_defaults::kSizeTabButtonToTopOfTabStrip) {
- newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
- views::ImageButton::ALIGN_BOTTOM);
- }
+ newtab_button_ = new NewTabButton(this, this);
LoadNewTabButtonImage();
newtab_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ACCNAME_NEWTAB));
@@ -481,8 +483,19 @@
BaseTabStrip::DoLayout();
// It is possible we don't have a new tab button yet.
- if (newtab_button_)
+ if (newtab_button_) {
+ if (SizeTabButtonToTopOfTabStrip()) {
+ newtab_button_bounds_.set_height(
+ kNewTabButtonHeight + kNewTabButtonVOffset);
+ newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
+ views::ImageButton::ALIGN_BOTTOM);
+ } else {
+ newtab_button_bounds_.set_height(kNewTabButtonHeight);
+ newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
+ views::ImageButton::ALIGN_TOP);
+ }
newtab_button_->SetBoundsRect(newtab_button_bounds_);
+ }
}
void TabStrip::LayoutDraggedTabsAt(const std::vector<BaseTab*>& tabs,
@@ -562,10 +575,6 @@
void TabStrip::Init() {
set_id(VIEW_ID_TAB_STRIP);
newtab_button_bounds_.SetRect(0, 0, kNewTabButtonWidth, kNewTabButtonHeight);
- if (browser_defaults::kSizeTabButtonToTopOfTabStrip) {
- newtab_button_bounds_.set_height(
- kNewTabButtonHeight + kNewTabButtonVOffset);
- }
if (drop_indicator_width == 0) {
// Direction doesn't matter, both images are the same size.
SkBitmap* drop_image = GetDropArrowImage(true);
@@ -574,6 +583,16 @@
}
}
+bool TabStrip::SizeTabButtonToTopOfTabStrip() {
+ if (browser_defaults::kSizeTabButtonToTopOfTabStrip)
+ return true;
+
+ if (browser_ && browser_->window())
+ return browser_->window()->IsMaximized();
+
+ return false;
+}
+
void TabStrip::LoadNewTabButtonImage() {
ui::ThemeProvider* tp = GetThemeProvider();
@@ -938,8 +957,7 @@
// Update bounds of new tab button.
int new_tab_x;
- int new_tab_y = browser_defaults::kSizeTabButtonToTopOfTabStrip ?
- 0 : kNewTabButtonVOffset;
+ int new_tab_y = SizeTabButtonToTopOfTabStrip() ? 0 : kNewTabButtonVOffset;
if (abs(Round(unselected) - Tab::GetStandardSize().width()) > 1 &&
!in_tab_close_) {
// We're shrinking tabs, so we need to anchor the New Tab button to the

Powered by Google App Engine
This is Rietveld 408576698