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

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

Issue 355233002: Fix build when ENABLE_MANAGED_USERS is not defined (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits, minor refactoring Created 6 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 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 "chrome/browser/profiles/profiles_state.h" 8 #include "chrome/browser/profiles/profiles_state.h"
9 #include "chrome/browser/ui/views/profiles/avatar_label.h"
10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 9 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
11 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
12 #include "components/signin/core/common/profile_management_switches.h" 11 #include "components/signin/core/common/profile_management_switches.h"
13 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
14 #include "ui/views/controls/button/image_button.h" 13 #include "ui/views/controls/button/image_button.h"
15 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
16 15
16 #if defined(ENABLE_MANAGED_USERS)
17 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
18 #endif
19
17 namespace { 20 namespace {
18 21
19 // Besides the frame border, there's another 9 px of empty space atop the 22 // Besides the frame border, there's another 9 px of empty space atop the
20 // window in restored mode, to use to drag the window around. 23 // window in restored mode, to use to drag the window around.
21 const int kNonClientRestoredExtraThickness = 9; 24 const int kNonClientRestoredExtraThickness = 9;
22 25
23 // The titlebar never shrinks too short to show the caption button plus some 26 // The titlebar never shrinks too short to show the caption button plus some
24 // padding below it. 27 // padding below it.
25 const int kCaptionButtonHeightWithPadding = 19; 28 const int kCaptionButtonHeightWithPadding = 19;
26 29
(...skipping 17 matching lines...) Expand all
44 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the 47 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
45 // user). 48 // user).
46 const int kAvatarBottomSpacing = 2; 49 const int kAvatarBottomSpacing = 2;
47 50
48 // Space between the frame border and the edge of the avatar. 51 // Space between the frame border and the edge of the avatar.
49 const int kAvatarOuterSpacing = 2; 52 const int kAvatarOuterSpacing = 2;
50 53
51 // Space between the edge of the avatar and the tabstrip. 54 // Space between the edge of the avatar and the tabstrip.
52 const int kAvatarInnerSpacing = 4; 55 const int kAvatarInnerSpacing = 4;
53 56
57 #if defined(ENABLE_MANAGED_USERS)
54 // Space between the trailing edge of the avatar label and the tabstrip. 58 // Space between the trailing edge of the avatar label and the tabstrip.
55 const int kAvatarLabelInnerSpacing = 10; 59 const int kSupervisedUserAvatarLabelInnerSpacing = 10;
60 #endif
56 61
57 // How far the new avatar button is from the closest caption button. 62 // How far the new avatar button is from the closest caption button.
58 const int kNewAvatarButtonOffset = 5; 63 const int kNewAvatarButtonOffset = 5;
59 64
60 // When the title bar is in its normal two row mode (usually the case for 65 // When the title bar is in its normal two row mode (usually the case for
61 // restored windows), the New Tab button isn't at the same height as the caption 66 // restored windows), the New Tab button isn't at the same height as the caption
62 // buttons, but the space will look cluttered if it actually slides under them, 67 // buttons, but the space will look cluttered if it actually slides under them,
63 // so we stop it when the gap between the two is down to 5 px. 68 // so we stop it when the gap between the two is down to 5 px.
64 const int kNewTabCaptionNormalSpacing = 5; 69 const int kNewTabCaptionNormalSpacing = 5;
65 70
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 has_leading_buttons_(false), 112 has_leading_buttons_(false),
108 has_trailing_buttons_(false), 113 has_trailing_buttons_(false),
109 extra_caption_y_(kExtraCaption), 114 extra_caption_y_(kExtraCaption),
110 window_caption_spacing_(kCaptionButtonSpacing), 115 window_caption_spacing_(kCaptionButtonSpacing),
111 minimize_button_(NULL), 116 minimize_button_(NULL),
112 maximize_button_(NULL), 117 maximize_button_(NULL),
113 restore_button_(NULL), 118 restore_button_(NULL),
114 close_button_(NULL), 119 close_button_(NULL),
115 window_icon_(NULL), 120 window_icon_(NULL),
116 window_title_(NULL), 121 window_title_(NULL),
117 avatar_label_(NULL), 122 #if defined(ENABLE_MANAGED_USERS)
123 supervised_user_avatar_label_(NULL),
124 #endif
118 avatar_button_(NULL), 125 avatar_button_(NULL),
119 new_avatar_button_(NULL) { 126 new_avatar_button_(NULL) {
120 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); 127 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
121 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); 128 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE);
122 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); 129 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE);
123 } 130 }
124 131
125 OpaqueBrowserFrameViewLayout::~OpaqueBrowserFrameViewLayout() {} 132 OpaqueBrowserFrameViewLayout::~OpaqueBrowserFrameViewLayout() {}
126 133
127 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( 134 void OpaqueBrowserFrameViewLayout::SetButtonOrdering(
(...skipping 10 matching lines...) Expand all
138 available_width -= leading_button_start_; 145 available_width -= leading_button_start_;
139 146
140 const int caption_spacing = NewTabCaptionSpacing(); 147 const int caption_spacing = NewTabCaptionSpacing();
141 const int tabstrip_width = available_width - caption_spacing; 148 const int tabstrip_width = available_width - caption_spacing;
142 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false), 149 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false),
143 std::max(0, tabstrip_width), 150 std::max(0, tabstrip_width),
144 tabstrip_preferred_size.height()); 151 tabstrip_preferred_size.height());
145 152
146 int leading_tabstrip_indent = kTabStripIndent; 153 int leading_tabstrip_indent = kTabStripIndent;
147 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) { 154 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) {
148 if (avatar_label_ && avatar_label_->bounds().width()) 155 #if defined(ENABLE_MANAGED_USERS)
149 leading_tabstrip_indent += kAvatarLabelInnerSpacing; 156 if (supervised_user_avatar_label_ &&
157 supervised_user_avatar_label_->bounds().width())
158 leading_tabstrip_indent += kSupervisedUserAvatarLabelInnerSpacing;
150 else 159 else
151 leading_tabstrip_indent += kAvatarInnerSpacing; 160 leading_tabstrip_indent += kAvatarInnerSpacing;
161 #else
162 leading_tabstrip_indent += kAvatarInnerSpacing;
163 #endif
152 } 164 }
153 bounds.Inset(leading_tabstrip_indent, 0, 0, 0); 165 bounds.Inset(leading_tabstrip_indent, 0, 0, 0);
154 return bounds; 166 return bounds;
155 } 167 }
156 168
157 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( 169 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize(
158 int available_width) const { 170 int available_width) const {
159 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); 171 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize();
160 int border_thickness = NonClientBorderThickness(); 172 int border_thickness = NonClientBorderThickness();
161 min_size.Enlarge(2 * border_thickness, 173 min_size.Enlarge(2 * border_thickness,
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 avatar_bounds_.SetRect( 434 avatar_bounds_.SetRect(
423 avatar_x, 435 avatar_x,
424 avatar_y, 436 avatar_y,
425 incognito_icon.width(), 437 incognito_icon.width(),
426 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); 438 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
427 if (avatar_button_) { 439 if (avatar_button_) {
428 avatar_button_->set_button_on_right(avatar_on_right); 440 avatar_button_->set_button_on_right(avatar_on_right);
429 avatar_button_->SetBoundsRect(avatar_bounds_); 441 avatar_button_->SetBoundsRect(avatar_bounds_);
430 442
431 int edge_offset; 443 int edge_offset;
432 if (avatar_label_) { 444 #if defined(ENABLE_MANAGED_USERS)
433 avatar_label_->SetLabelOnRight(avatar_on_right); 445 if (supervised_user_avatar_label_) {
446 supervised_user_avatar_label_->SetLabelOnRight(avatar_on_right);
434 // Space between the bottom of the avatar and the bottom of the avatar 447 // Space between the bottom of the avatar and the bottom of the avatar
435 // label. 448 // label.
436 const int kAvatarLabelBottomSpacing = 3; 449 const int kSupervisedUserAvatarLabelBottomSpacing = 3;
437 gfx::Size label_size = avatar_label_->GetPreferredSize(); 450 gfx::Size label_size = supervised_user_avatar_label_->GetPreferredSize();
438 // The outside edge of the avatar label should be just outside that of the 451 // The outside edge of the avatar label should be just outside that of the
439 // avatar menu button. 452 // avatar menu button.
440 int avatar_label_x = avatar_on_right ? 453 int avatar_label_x = avatar_on_right ?
441 (host->width() - trailing_button_start_ - label_size.width()) : 454 (host->width() - trailing_button_start_ - label_size.width()) :
442 leading_button_start_; 455 leading_button_start_;
443 gfx::Rect label_bounds( 456 gfx::Rect label_bounds(
444 avatar_label_x, 457 avatar_label_x,
445 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), 458 avatar_bottom - kSupervisedUserAvatarLabelBottomSpacing -
459 label_size.height(),
446 label_size.width(), 460 label_size.width(),
447 delegate_->ShouldShowAvatar() ? label_size.height() : 0); 461 delegate_->ShouldShowAvatar() ? label_size.height() : 0);
448 avatar_label_->SetBoundsRect(label_bounds); 462 supervised_user_avatar_label_->SetBoundsRect(label_bounds);
449 edge_offset = label_size.width(); 463 edge_offset = label_size.width();
450 } else { 464 } else {
451 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); 465 edge_offset = kAvatarOuterSpacing + incognito_icon.width();
452 } 466 }
467 #else
468 edge_offset = kAvatarOuterSpacing + incognito_icon.width();
469 #endif
453 if (avatar_on_right) 470 if (avatar_on_right)
454 trailing_button_start_ += edge_offset; 471 trailing_button_start_ += edge_offset;
455 else 472 else
456 leading_button_start_ += edge_offset; 473 leading_button_start_ += edge_offset;
457 474
458 // We just add the avatar button size to the minimum size because clicking 475 // We just add the avatar button size to the minimum size because clicking
459 // the avatar label does the same thing as clicking the avatar button. 476 // the avatar label does the same thing as clicking the avatar button.
460 minimum_size_for_buttons_ += kAvatarOuterSpacing + incognito_icon.width(); 477 minimum_size_for_buttons_ += kAvatarOuterSpacing + incognito_icon.width();
461 } 478 }
462 } 479 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 case VIEW_ID_WINDOW_ICON: 637 case VIEW_ID_WINDOW_ICON:
621 window_icon_ = view; 638 window_icon_ = view;
622 break; 639 break;
623 case VIEW_ID_WINDOW_TITLE: 640 case VIEW_ID_WINDOW_TITLE:
624 if (view) { 641 if (view) {
625 DCHECK_EQ(std::string(views::Label::kViewClassName), 642 DCHECK_EQ(std::string(views::Label::kViewClassName),
626 view->GetClassName()); 643 view->GetClassName());
627 } 644 }
628 window_title_ = static_cast<views::Label*>(view); 645 window_title_ = static_cast<views::Label*>(view);
629 break; 646 break;
630 case VIEW_ID_AVATAR_LABEL: 647 #if defined(ENABLE_MANAGED_USERS)
631 avatar_label_ = static_cast<AvatarLabel*>(view); 648 case VIEW_ID_SUPERVISED_USER_AVATAR_LABEL:
649 supervised_user_avatar_label_ =
650 static_cast<SupervisedUserAvatarLabel*>(view);
632 break; 651 break;
652 #endif
633 case VIEW_ID_AVATAR_BUTTON: 653 case VIEW_ID_AVATAR_BUTTON:
634 if (view) { 654 if (view) {
635 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), 655 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName),
636 view->GetClassName()); 656 view->GetClassName());
637 } 657 }
638 avatar_button_ = static_cast<AvatarMenuButton*>(view); 658 avatar_button_ = static_cast<AvatarMenuButton*>(view);
639 break; 659 break;
640 case VIEW_ID_NEW_AVATAR_BUTTON: 660 case VIEW_ID_NEW_AVATAR_BUTTON:
641 new_avatar_button_ = view; 661 new_avatar_button_ = view;
642 break; 662 break;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 705
686 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, 706 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host,
687 views::View* view) { 707 views::View* view) {
688 SetView(view->id(), view); 708 SetView(view->id(), view);
689 } 709 }
690 710
691 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, 711 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host,
692 views::View* view) { 712 views::View* view) {
693 SetView(view->id(), NULL); 713 SetView(view->id(), NULL);
694 } 714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698