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

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

Issue 1614523002: Remove old-avatar supervised user labels on non-Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/opaque_browser_frame_view_layout.h" 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/profiles/profiles_state.h" 9 #include "chrome/browser/profiles/profiles_state.h"
10 #include "chrome/browser/ui/layout_constants.h" 10 #include "chrome/browser/ui/layout_constants.h"
11 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 11 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "components/signin/core/common/profile_management_switches.h" 13 #include "components/signin/core/common/profile_management_switches.h"
14 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
15 #include "ui/views/controls/button/image_button.h" 15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/controls/label.h" 16 #include "ui/views/controls/label.h"
17 17
18 #if defined(ENABLE_SUPERVISED_USERS)
19 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
20 #endif
21
22 namespace { 18 namespace {
23 19
24 // Besides the frame border, there's empty space atop the window in restored 20 // Besides the frame border, there's empty space atop the window in restored
25 // mode, to use to drag the window around. 21 // mode, to use to drag the window around.
26 const int kNonClientRestoredExtraThickness = 11; 22 const int kNonClientRestoredExtraThickness = 11;
27 23
28 // The titlebar never shrinks too short to show the caption button plus some 24 // The titlebar never shrinks too short to show the caption button plus some
29 // padding below it. 25 // padding below it.
30 const int kCaptionButtonHeight = 18; 26 const int kCaptionButtonHeight = 18;
31 const int kTitleBarAdditionalPadding = 3; 27 const int kTitleBarAdditionalPadding = 3;
(...skipping 18 matching lines...) Expand all
50 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the 46 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
51 // user). 47 // user).
52 const int kAvatarBottomSpacing = 2; 48 const int kAvatarBottomSpacing = 2;
53 49
54 // Space between the frame border and the edge of the avatar. 50 // Space between the frame border and the edge of the avatar.
55 const int kAvatarOuterSpacing = 2; 51 const int kAvatarOuterSpacing = 2;
56 52
57 // Space between the edge of the avatar and the tabstrip. 53 // Space between the edge of the avatar and the tabstrip.
58 const int kAvatarInnerSpacing = 4; 54 const int kAvatarInnerSpacing = 4;
59 55
60 #if defined(ENABLE_SUPERVISED_USERS)
61 // Space between the trailing edge of the avatar label and the tabstrip.
62 const int kSupervisedUserAvatarLabelInnerSpacing = 10;
63 #endif
64
65 // How far the new avatar button is from the closest caption button. 56 // How far the new avatar button is from the closest caption button.
66 const int kNewAvatarButtonOffset = 5; 57 const int kNewAvatarButtonOffset = 5;
67 58
68 // When the title bar is in its normal two row mode (usually the case for 59 // When the title bar is in its normal two row mode (usually the case for
69 // restored windows), the New Tab button isn't at the same height as the caption 60 // restored windows), the New Tab button isn't at the same height as the caption
70 // buttons, but the space will look cluttered if it actually slides under them, 61 // buttons, but the space will look cluttered if it actually slides under them,
71 // so we stop it when the gap between the two is down to 5 px. 62 // so we stop it when the gap between the two is down to 5 px.
72 const int kNewTabCaptionNormalSpacing = 5; 63 const int kNewTabCaptionNormalSpacing = 5;
73 64
74 // When the title bar is condensed to one row (as when maximized), the New Tab 65 // When the title bar is condensed to one row (as when maximized), the New Tab
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 has_leading_buttons_(false), 106 has_leading_buttons_(false),
116 has_trailing_buttons_(false), 107 has_trailing_buttons_(false),
117 extra_caption_y_(kExtraCaption), 108 extra_caption_y_(kExtraCaption),
118 window_caption_spacing_(kCaptionButtonSpacing), 109 window_caption_spacing_(kCaptionButtonSpacing),
119 minimize_button_(nullptr), 110 minimize_button_(nullptr),
120 maximize_button_(nullptr), 111 maximize_button_(nullptr),
121 restore_button_(nullptr), 112 restore_button_(nullptr),
122 close_button_(nullptr), 113 close_button_(nullptr),
123 window_icon_(nullptr), 114 window_icon_(nullptr),
124 window_title_(nullptr), 115 window_title_(nullptr),
125 #if defined(ENABLE_SUPERVISED_USERS)
126 supervised_user_avatar_label_(nullptr),
127 #endif
128 avatar_button_(nullptr), 116 avatar_button_(nullptr),
129 new_avatar_button_(nullptr) { 117 new_avatar_button_(nullptr) {
130 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); 118 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
131 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); 119 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE);
132 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); 120 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE);
133 } 121 }
134 122
135 OpaqueBrowserFrameViewLayout::~OpaqueBrowserFrameViewLayout() {} 123 OpaqueBrowserFrameViewLayout::~OpaqueBrowserFrameViewLayout() {}
136 124
137 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( 125 void OpaqueBrowserFrameViewLayout::SetButtonOrdering(
138 const std::vector<views::FrameButton>& leading_buttons, 126 const std::vector<views::FrameButton>& leading_buttons,
139 const std::vector<views::FrameButton>& trailing_buttons) { 127 const std::vector<views::FrameButton>& trailing_buttons) {
140 leading_buttons_ = leading_buttons; 128 leading_buttons_ = leading_buttons;
141 trailing_buttons_ = trailing_buttons; 129 trailing_buttons_ = trailing_buttons;
142 } 130 }
143 131
144 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( 132 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip(
145 const gfx::Size& tabstrip_preferred_size, 133 const gfx::Size& tabstrip_preferred_size,
146 int available_width) const { 134 int available_width) const {
147 available_width -= trailing_button_start_; 135 available_width -= trailing_button_start_;
148 available_width -= leading_button_start_; 136 available_width -= leading_button_start_;
149 137
150 const int caption_spacing = NewTabCaptionSpacing(); 138 const int caption_spacing = NewTabCaptionSpacing();
151 const int tabstrip_width = available_width - caption_spacing; 139 const int tabstrip_width = available_width - caption_spacing;
152 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false), 140 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false),
153 std::max(0, tabstrip_width), 141 std::max(0, tabstrip_width),
154 tabstrip_preferred_size.height()); 142 tabstrip_preferred_size.height());
155 143
156 int leading_tabstrip_indent = kTabStripIndent; 144 int leading_tabstrip_indent = kTabStripIndent;
157 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) { 145 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight())
158 #if defined(ENABLE_SUPERVISED_USERS)
159 if (supervised_user_avatar_label_ &&
160 supervised_user_avatar_label_->bounds().width())
161 leading_tabstrip_indent += kSupervisedUserAvatarLabelInnerSpacing;
162 else
163 leading_tabstrip_indent += kAvatarInnerSpacing;
164 #else
165 leading_tabstrip_indent += kAvatarInnerSpacing; 146 leading_tabstrip_indent += kAvatarInnerSpacing;
166 #endif
167 }
168 bounds.Inset(leading_tabstrip_indent, 0, 0, 0); 147 bounds.Inset(leading_tabstrip_indent, 0, 0, 0);
169 return bounds; 148 return bounds;
170 } 149 }
171 150
172 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( 151 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize(
173 int available_width) const { 152 int available_width) const {
174 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); 153 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize();
175 int border_thickness = NonClientBorderThickness(); 154 int border_thickness = NonClientBorderThickness();
176 min_size.Enlarge(2 * border_thickness, 155 min_size.Enlarge(2 * border_thickness,
177 NonClientTopBorderHeight(false) + border_thickness); 156 NonClientTopBorderHeight(false) + border_thickness);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 avatar_restored_y; 421 avatar_restored_y;
443 avatar_bounds_.SetRect( 422 avatar_bounds_.SetRect(
444 avatar_x, 423 avatar_x,
445 avatar_y, 424 avatar_y,
446 incognito_icon.width(), 425 incognito_icon.width(),
447 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); 426 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
448 if (avatar_button_) { 427 if (avatar_button_) {
449 avatar_button_->set_button_on_right(avatar_on_right); 428 avatar_button_->set_button_on_right(avatar_on_right);
450 avatar_button_->SetBoundsRect(avatar_bounds_); 429 avatar_button_->SetBoundsRect(avatar_bounds_);
451 430
452 int edge_offset; 431 int edge_offset = kAvatarOuterSpacing + incognito_icon.width();
453 #if defined(ENABLE_SUPERVISED_USERS)
454 if (supervised_user_avatar_label_) {
455 supervised_user_avatar_label_->SetLabelOnRight(avatar_on_right);
456 // Space between the bottom of the avatar and the bottom of the avatar
457 // label.
458 const int kSupervisedUserAvatarLabelBottomSpacing = 3;
459 gfx::Size label_size = supervised_user_avatar_label_->GetPreferredSize();
460 // The outside edge of the avatar label should be just outside that of the
461 // avatar menu button.
462 int avatar_label_x = avatar_on_right ?
463 (host->width() - trailing_button_start_ - label_size.width()) :
464 leading_button_start_;
465 gfx::Rect label_bounds(
466 avatar_label_x,
467 avatar_bottom - kSupervisedUserAvatarLabelBottomSpacing -
468 label_size.height(),
469 label_size.width(),
470 delegate_->ShouldShowAvatar() ? label_size.height() : 0);
471 supervised_user_avatar_label_->SetBoundsRect(label_bounds);
472 edge_offset = label_size.width();
473 } else {
474 edge_offset = kAvatarOuterSpacing + incognito_icon.width();
475 }
476 #else
477 edge_offset = kAvatarOuterSpacing + incognito_icon.width();
478 #endif
479 if (avatar_on_right) 432 if (avatar_on_right)
480 trailing_button_start_ += edge_offset; 433 trailing_button_start_ += edge_offset;
481 else 434 else
482 leading_button_start_ += edge_offset; 435 leading_button_start_ += edge_offset;
483 436
484 // We just add the avatar button size to the minimum size because clicking 437 // We just add the avatar button size to the minimum size because clicking
485 // the avatar label does the same thing as clicking the avatar button. 438 // the avatar label does the same thing as clicking the avatar button.
486 minimum_size_for_buttons_ += kAvatarOuterSpacing + incognito_icon.width(); 439 minimum_size_for_buttons_ += kAvatarOuterSpacing + incognito_icon.width();
487 } 440 }
488 } 441 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 case VIEW_ID_WINDOW_ICON: 599 case VIEW_ID_WINDOW_ICON:
647 window_icon_ = view; 600 window_icon_ = view;
648 break; 601 break;
649 case VIEW_ID_WINDOW_TITLE: 602 case VIEW_ID_WINDOW_TITLE:
650 if (view) { 603 if (view) {
651 DCHECK_EQ(std::string(views::Label::kViewClassName), 604 DCHECK_EQ(std::string(views::Label::kViewClassName),
652 view->GetClassName()); 605 view->GetClassName());
653 } 606 }
654 window_title_ = static_cast<views::Label*>(view); 607 window_title_ = static_cast<views::Label*>(view);
655 break; 608 break;
656 #if defined(ENABLE_SUPERVISED_USERS)
657 case VIEW_ID_SUPERVISED_USER_AVATAR_LABEL:
658 supervised_user_avatar_label_ =
659 static_cast<SupervisedUserAvatarLabel*>(view);
660 break;
661 #endif
662 case VIEW_ID_AVATAR_BUTTON: 609 case VIEW_ID_AVATAR_BUTTON:
663 if (view) { 610 if (view) {
664 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), 611 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName),
665 view->GetClassName()); 612 view->GetClassName());
666 } 613 }
667 avatar_button_ = static_cast<AvatarMenuButton*>(view); 614 avatar_button_ = static_cast<AvatarMenuButton*>(view);
668 break; 615 break;
669 case VIEW_ID_NEW_AVATAR_BUTTON: 616 case VIEW_ID_NEW_AVATAR_BUTTON:
670 new_avatar_button_ = view; 617 new_avatar_button_ = view;
671 break; 618 break;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 661
715 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, 662 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host,
716 views::View* view) { 663 views::View* view) {
717 SetView(view->id(), view); 664 SetView(view->id(), view);
718 } 665 }
719 666
720 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, 667 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host,
721 views::View* view) { 668 views::View* view) {
722 SetView(view->id(), nullptr); 669 SetView(view->id(), nullptr);
723 } 670 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698