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

Side by Side Diff: ash/common/system/user/user_view.cc

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/common/system/user/user_view.h" 5 #include "ash/common/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/multi_profile_uma.h" 10 #include "ash/common/multi_profile_uma.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 bool IsMultiProfileSupportedAndUserActive() { 63 bool IsMultiProfileSupportedAndUserActive() {
64 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && 64 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() &&
65 !WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked(); 65 !WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked();
66 } 66 }
67 67
68 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). 68 // Creates the view shown in the user switcher popup ("AddUserMenuOption").
69 views::View* CreateAddUserView(AddUserSessionPolicy policy, 69 views::View* CreateAddUserView(AddUserSessionPolicy policy,
70 views::ButtonListener* listener) { 70 views::ButtonListener* listener) {
71 auto view = new views::View; 71 auto* view = new views::View;
72 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; 72 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
73 auto layout = 73 auto* layout =
74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
75 kTrayPopupLabelHorizontalPadding + icon_padding); 75 kTrayPopupLabelHorizontalPadding + icon_padding);
76 layout->set_minimum_cross_axis_size( 76 layout->set_minimum_cross_axis_size(
77 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); 77 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
78 view->SetLayoutManager(layout); 78 view->SetLayoutManager(layout);
79 view->set_background( 79 view->set_background(
80 views::Background::CreateSolidBackground(kBackgroundColor)); 80 views::Background::CreateSolidBackground(kBackgroundColor));
81 81
82 int message_id = 0; 82 int message_id = 0;
83 switch (policy) { 83 switch (policy) {
84 case AddUserSessionPolicy::ALLOWED: { 84 case AddUserSessionPolicy::ALLOWED: {
85 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT; 85 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT;
86 86
87 auto icon = new views::ImageView(); 87 auto* icon = new views::ImageView();
88 icon->SetImage( 88 icon->SetImage(
89 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor)); 89 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor));
90 view->AddChildView(icon); 90 view->AddChildView(icon);
91 break; 91 break;
92 } 92 }
93 case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: 93 case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER:
94 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; 94 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
95 break; 95 break;
96 case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED: 96 case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED:
97 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; 97 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
98 break; 98 break;
99 case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: 99 case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS:
100 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS; 100 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
101 break; 101 break;
102 } 102 }
103 103
104 auto command_label = new views::Label(l10n_util::GetStringUTF16(message_id)); 104 auto* command_label = new views::Label(l10n_util::GetStringUTF16(message_id));
105 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 105 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
106 command_label->SetMultiLine(true); 106 command_label->SetMultiLine(true);
107 107
108 TrayPopupItemStyle label_style( 108 TrayPopupItemStyle label_style(
109 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); 109 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
110 int vertical_padding = kMenuSeparatorVerticalPadding; 110 int vertical_padding = kMenuSeparatorVerticalPadding;
111 if (policy != AddUserSessionPolicy::ALLOWED) { 111 if (policy != AddUserSessionPolicy::ALLOWED) {
112 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION); 112 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION);
113 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); 113 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
114 vertical_padding += kMenuSeparatorVerticalPadding; 114 vertical_padding += kMenuSeparatorVerticalPadding;
115 } 115 }
116 label_style.SetupLabel(command_label); 116 label_style.SetupLabel(command_label);
117 view->AddChildView(command_label); 117 view->AddChildView(command_label);
118 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding, 118 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding,
119 vertical_padding, 119 vertical_padding,
120 kTrayPopupLabelHorizontalPadding)); 120 kTrayPopupLabelHorizontalPadding));
121 if (policy == AddUserSessionPolicy::ALLOWED) { 121 if (policy == AddUserSessionPolicy::ALLOWED) {
122 auto button = 122 auto* button =
123 new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS); 123 new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS);
124 button->SetAccessibleName( 124 button->SetAccessibleName(
125 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 125 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
126 return button; 126 return button;
127 } 127 }
128 128
129 return view; 129 return view;
130 } 130 }
131 131
132 class UserViewMouseWatcherHost : public views::MouseWatcherHost { 132 class UserViewMouseWatcherHost : public views::MouseWatcherHost {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 add_user_enabled_(true), 214 add_user_enabled_(true),
215 focus_manager_(nullptr) { 215 focus_manager_(nullptr) {
216 CHECK_NE(LoginStatus::NOT_LOGGED_IN, login); 216 CHECK_NE(LoginStatus::NOT_LOGGED_IN, login);
217 // The logout button must be added before the user card so that the user card 217 // The logout button must be added before the user card so that the user card
218 // can correctly calculate the remaining available width. 218 // can correctly calculate the remaining available width.
219 // Note that only the current multiprofile user gets a button. 219 // Note that only the current multiprofile user gets a button.
220 if (IsActiveUser()) 220 if (IsActiveUser())
221 AddLogoutButton(login); 221 AddLogoutButton(login);
222 AddUserCard(login); 222 AddUserCard(login);
223 223
224 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 224 auto* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
225 SetLayoutManager(layout); 225 SetLayoutManager(layout);
226 layout->set_cross_axis_alignment( 226 layout->set_cross_axis_alignment(
227 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 227 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
228 layout->SetFlexForView(user_card_view_, 1); 228 layout->SetFlexForView(user_card_view_, 1);
229 229
230 if (IsActiveUser()) 230 if (IsActiveUser())
231 SetBorder(base::MakeUnique<ActiveUserBorder>()); 231 SetBorder(base::MakeUnique<ActiveUserBorder>());
232 } 232 }
233 233
234 UserView::~UserView() { 234 UserView::~UserView() {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return; 400 return;
401 focus_manager_->RemoveFocusChangeListener(this); 401 focus_manager_->RemoveFocusChangeListener(this);
402 focus_manager_ = nullptr; 402 focus_manager_ = nullptr;
403 if (user_card_view_->GetFocusManager()) 403 if (user_card_view_->GetFocusManager())
404 user_card_view_->GetFocusManager()->ClearFocus(); 404 user_card_view_->GetFocusManager()->ClearFocus();
405 add_menu_option_.reset(); 405 add_menu_option_.reset();
406 } 406 }
407 407
408 } // namespace tray 408 } // namespace tray
409 } // namespace ash 409 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698