Chromium Code Reviews| Index: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| index 839b14c86d651c4f6d46bb5b5138266fd3cdb18c..94f21377453f835088b8c848e4445da37e9d650b 100644 |
| --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| @@ -4,6 +4,8 @@ |
| #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| +#include "chrome/browser/profiles/profiles_state.h" |
| +#include "chrome/browser/ui/views/new_avatar_button.h" |
| #include "ui/gfx/font.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/label.h" |
| @@ -49,6 +51,9 @@ const int kAvatarLeftSpacing = 2; |
| // Space between the right edge of the avatar and the tabstrip. |
| const int kAvatarRightSpacing = -4; |
| +// How far the new avatar button is from the left of the minimize button. |
|
Elliot Glaysher
2013/10/01 18:12:56
Change comment: how far it is from the closest cap
noms (inactive)
2013/10/03 19:30:14
Done.
|
| +const int kNewAvatarButtonOffset = 5; |
| + |
| // In restored mode, the New Tab button isn't at the same height as the caption |
| // buttons, but the space will look cluttered if it actually slides under them, |
| // so we stop it when the gap between the two is down to 5 px. |
| @@ -101,7 +106,8 @@ OpaqueBrowserFrameViewLayout::OpaqueBrowserFrameViewLayout( |
| window_icon_(NULL), |
| window_title_(NULL), |
| avatar_label_(NULL), |
| - avatar_button_(NULL) { |
| + avatar_button_(NULL), |
| + new_avatar_button_(NULL) { |
| trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); |
| trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); |
| trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); |
| @@ -355,6 +361,33 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) { |
| } |
| } |
| +void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) { |
| + if (!has_trailing_buttons_ && !has_leading_buttons_) |
| + return; |
| + |
| + gfx::Size label_size = new_avatar_button_->GetPreferredSize(); |
| + int button_size_with_offset = kNewAvatarButtonOffset + label_size.width(); |
| + |
| + int button_x; |
| + int button_y = CaptionButtonY(false); |
| + if (has_trailing_buttons_) { |
| + button_x = host->width() - trailing_button_start_ - button_size_with_offset; |
| + trailing_button_start_ += button_size_with_offset; |
| + minimum_size_for_buttons_ += button_size_with_offset; |
| + } else { |
| + button_x = leading_button_start_ + kNewAvatarButtonOffset; |
| + leading_button_start_ += button_size_with_offset; |
| + minimum_size_for_buttons_ += button_size_with_offset; |
| + } |
| + |
| + new_avatar_button_->set_avatar_bubble_align_right(has_trailing_buttons_); |
| + new_avatar_button_->SetBounds( |
| + button_x, |
| + button_y, |
| + label_size.width(), |
| + button_y + kCaptionButtonHeightWithPadding); |
| +} |
| + |
| void OpaqueBrowserFrameViewLayout::LayoutAvatar() { |
| // Even though the avatar is used for both incognito and profiles we always |
| // use the incognito icon to layout the avatar button. The profile icon |
| @@ -560,6 +593,9 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) { |
| case VIEW_ID_AVATAR_BUTTON: |
| avatar_button_ = view; |
| break; |
| + case VIEW_ID_NEW_AVATAR_BUTTON: |
| + new_avatar_button_ = static_cast<NewAvatarButton*>(view); |
| + break; |
| default: |
| NOTIMPLEMENTED() << "Unknown view id " << id; |
| break; |
| @@ -586,7 +622,11 @@ void OpaqueBrowserFrameViewLayout::Layout(views::View* host) { |
| // on the trailing side. |
| leading_button_start_++; |
| - LayoutAvatar(); |
| + if (delegate_->IsRegularOrGuestSession() && |
| + profiles::IsNewProfileManagementEnabled()) |
| + LayoutNewStyleAvatar(host); |
| + else |
| + LayoutAvatar(); |
| client_view_bounds_ = CalculateClientAreaBounds( |
| host->width(), host->height()); |