Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / opaque_browser_frame_view_layout.cc
index e34ef2a..d17cf76 100644 (file)
@@ -6,18 +6,14 @@
 
 #include "base/command_line.h"
 #include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/ui/views/avatar_label.h"
-#include "chrome/browser/ui/views/avatar_menu_button.h"
+#include "chrome/browser/ui/views/profiles/avatar_label.h"
+#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/profile_management_switches.h"
+#include "components/signin/core/common/profile_management_switches.h"
 #include "ui/gfx/font.h"
 #include "ui/views/controls/button/image_button.h"
 #include "ui/views/controls/label.h"
 
-#if defined(OS_WIN)
-#include "win8/util/win8_util.h"
-#endif  // OS_WIN
-
 namespace {
 
 // Besides the frame border, there's another 9 px of empty space atop the
@@ -128,15 +124,6 @@ OpaqueBrowserFrameViewLayout::OpaqueBrowserFrameViewLayout(
 
 OpaqueBrowserFrameViewLayout::~OpaqueBrowserFrameViewLayout() {}
 
-// static
-bool OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons() {
-#if defined(OS_WIN)
-  return !win8::IsSingleWindowMetroMode();
-#else
-  return true;
-#endif
-}
-
 void OpaqueBrowserFrameViewLayout::SetButtonOrdering(
     const std::vector<views::FrameButton>& leading_buttons,
     const std::vector<views::FrameButton>& trailing_buttons) {
@@ -150,9 +137,6 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip(
   available_width -= trailing_button_start_;
   available_width -= leading_button_start_;
 
-  if (delegate_->GetAdditionalReservedSpaceInTabStrip())
-    available_width -= delegate_->GetAdditionalReservedSpaceInTabStrip();
-
   const int caption_spacing = NewTabCaptionSpacing();
   const int tabstrip_width = available_width - caption_spacing;
   gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false),
@@ -292,9 +276,6 @@ int OpaqueBrowserFrameViewLayout::NewTabCaptionSpacing() const {
 }
 
 void OpaqueBrowserFrameViewLayout::LayoutWindowControls(views::View* host) {
-  if (!ShouldAddDefaultCaptionButtons())
-    return;
-
   int caption_y = CaptionButtonY(false);
 
   // Keep a list of all buttons that we don't show.
@@ -397,7 +378,7 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) {
 }
 
 void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) {
-  DCHECK(switches::IsNewProfileManagement());
+  DCHECK(switches::IsNewAvatarMenu());
   if (!new_avatar_button_)
     return;
 
@@ -407,6 +388,9 @@ void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) {
   int button_x = host->width() - trailing_button_start_ -
       button_size_with_offset;
   int button_y = CaptionButtonY(false);
+  // If the window is maximized, the button is 1 pixel too short. Determined
+  // via visual inspection.
+  int extra_height = IsTitleBarCondensed() ? 1 : 0;
 
   trailing_button_start_ += button_size_with_offset;
   minimum_size_for_buttons_ += button_size_with_offset;
@@ -415,7 +399,7 @@ void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) {
       button_x,
       button_y,
       label_size.width(),
-      button_y + kCaptionButtonHeightWithPadding);
+      button_y + kCaptionButtonHeightWithPadding + extra_height);
 }
 
 void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) {
@@ -682,8 +666,7 @@ void OpaqueBrowserFrameViewLayout::Layout(views::View* host) {
   // on the trailing side.
   leading_button_start_++;
 
-  if (delegate_->IsRegularOrGuestSession() &&
-      switches::IsNewProfileManagement())
+  if (delegate_->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
     LayoutNewStyleAvatar(host);
   else
     LayoutAvatar(host);