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 c0848d869f53fa2a0b52dcdd4f4e0c6931762799..0b29cc624afcff0e155191619ff4de36c27fc361 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 closest caption button. |
| +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,24 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) { |
| } |
| } |
| +void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) { |
| + 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); |
| + |
| + button_x = host->width() - trailing_button_start_ - button_size_with_offset; |
|
Elliot Glaysher
2013/10/09 17:43:50
move this so that it is int buton_x = host->width(
noms (inactive)
2013/10/09 18:17:52
Done.
|
| + trailing_button_start_ += button_size_with_offset; |
| + minimum_size_for_buttons_ += button_size_with_offset; |
| + |
| + 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 |
| @@ -567,6 +591,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; |
| @@ -593,7 +620,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()); |