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

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

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 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/system/user/user_view.h" 5 #include "ash/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/multi_profile_uma.h" 10 #include "ash/multi_profile_uma.h"
11 #include "ash/public/cpp/shell_window_ids.h" 11 #include "ash/public/cpp/shell_window_ids.h"
12 #include "ash/resources/grit/ash_resources.h" 12 #include "ash/resources/grit/ash_resources.h"
13 #include "ash/resources/vector_icons/vector_icons.h" 13 #include "ash/resources/vector_icons/vector_icons.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/session/session_controller.h" 15 #include "ash/session/session_controller.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_delegate.h" 17 #include "ash/shell_delegate.h"
18 #include "ash/shell_port.h"
18 #include "ash/strings/grit/ash_strings.h" 19 #include "ash/strings/grit/ash_strings.h"
19 #include "ash/system/tray/system_tray.h" 20 #include "ash/system/tray/system_tray.h"
20 #include "ash/system/tray/system_tray_controller.h" 21 #include "ash/system/tray/system_tray_controller.h"
21 #include "ash/system/tray/system_tray_delegate.h" 22 #include "ash/system/tray/system_tray_delegate.h"
22 #include "ash/system/tray/tray_constants.h" 23 #include "ash/system/tray/tray_constants.h"
23 #include "ash/system/tray/tray_popup_item_style.h" 24 #include "ash/system/tray/tray_popup_item_style.h"
24 #include "ash/system/tray/tray_popup_utils.h" 25 #include "ash/system/tray/tray_popup_utils.h"
25 #include "ash/system/user/button_from_view.h" 26 #include "ash/system/user/button_from_view.h"
26 #include "ash/system/user/login_status.h" 27 #include "ash/system/user/login_status.h"
27 #include "ash/system/user/rounded_image_view.h" 28 #include "ash/system/user/rounded_image_view.h"
28 #include "ash/system/user/user_card_view.h" 29 #include "ash/system/user/user_card_view.h"
29 #include "ash/wm_shell.h"
30 #include "ash/wm_window.h" 30 #include "ash/wm_window.h"
31 #include "base/memory/ptr_util.h" 31 #include "base/memory/ptr_util.h"
32 #include "components/signin/core/account_id/account_id.h" 32 #include "components/signin/core/account_id/account_id.h"
33 #include "components/user_manager/user_info.h" 33 #include "components/user_manager/user_info.h"
34 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/gfx/canvas.h" 36 #include "ui/gfx/canvas.h"
37 #include "ui/gfx/geometry/insets.h" 37 #include "ui/gfx/geometry/insets.h"
38 #include "ui/gfx/paint_vector_icon.h" 38 #include "ui/gfx/paint_vector_icon.h"
39 #include "ui/views/controls/button/label_button.h" 39 #include "ui/views/controls/button/label_button.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool UserView::IsActiveUser() const { 260 bool UserView::IsActiveUser() const {
261 return user_index_ == 0; 261 return user_index_ == 0;
262 } 262 }
263 263
264 int UserView::GetHeightForWidth(int width) const { 264 int UserView::GetHeightForWidth(int width) const {
265 return GetPreferredSize().height(); 265 return GetPreferredSize().height();
266 } 266 }
267 267
268 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { 268 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) {
269 if (sender == logout_button_) { 269 if (sender == logout_button_) {
270 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT); 270 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT);
271 RemoveAddUserMenuOption(); 271 RemoveAddUserMenuOption();
272 Shell::Get()->system_tray_controller()->SignOut(); 272 Shell::Get()->system_tray_controller()->SignOut();
273 } else if (sender == user_card_view_ && 273 } else if (sender == user_card_view_ &&
274 IsMultiProfileSupportedAndUserActive()) { 274 IsMultiProfileSupportedAndUserActive()) {
275 if (IsActiveUser()) { 275 if (IsActiveUser()) {
276 ToggleAddUserMenuOption(); 276 ToggleAddUserMenuOption();
277 } else { 277 } else {
278 RemoveAddUserMenuOption(); 278 RemoveAddUserMenuOption();
279 SwitchUser(user_index_); 279 SwitchUser(user_index_);
280 // Since the user list is about to change the system menu should get 280 // Since the user list is about to change the system menu should get
(...skipping 25 matching lines...) Expand all
306 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 306 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
307 logout_button_ = TrayPopupUtils::CreateTrayPopupBorderlessButton( 307 logout_button_ = TrayPopupUtils::CreateTrayPopupBorderlessButton(
308 this, user::GetLocalizedSignOutStringForStatus(login, true)); 308 this, user::GetLocalizedSignOutStringForStatus(login, true));
309 AddChildView(logout_button_); 309 AddChildView(logout_button_);
310 } 310 }
311 311
312 void UserView::AddUserCard(LoginStatus login) { 312 void UserView::AddUserCard(LoginStatus login) {
313 user_card_view_ = new UserCardView(login, -1, user_index_); 313 user_card_view_ = new UserCardView(login, -1, user_index_);
314 // The entry is clickable when no system modal dialog is open and the multi 314 // The entry is clickable when no system modal dialog is open and the multi
315 // profile option is active. 315 // profile option is active.
316 bool clickable = !WmShell::Get()->IsSystemModalWindowOpen() && 316 bool clickable = !ShellPort::Get()->IsSystemModalWindowOpen() &&
317 IsMultiProfileSupportedAndUserActive(); 317 IsMultiProfileSupportedAndUserActive();
318 if (clickable) { 318 if (clickable) {
319 views::View* contents_view = user_card_view_; 319 views::View* contents_view = user_card_view_;
320 auto* button = 320 auto* button =
321 new ButtonFromView(contents_view, this, 321 new ButtonFromView(contents_view, this,
322 IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS 322 IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS
323 : TrayPopupInkDropStyle::FILL_BOUNDS); 323 : TrayPopupInkDropStyle::FILL_BOUNDS);
324 user_card_view_ = button; 324 user_card_view_ = button;
325 is_user_card_button_ = true; 325 is_user_card_button_ = true;
326 } 326 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return; 396 return;
397 focus_manager_->RemoveFocusChangeListener(this); 397 focus_manager_->RemoveFocusChangeListener(this);
398 focus_manager_ = nullptr; 398 focus_manager_ = nullptr;
399 if (user_card_view_->GetFocusManager()) 399 if (user_card_view_->GetFocusManager())
400 user_card_view_->GetFocusManager()->ClearFocus(); 400 user_card_view_->GetFocusManager()->ClearFocus();
401 add_menu_option_.reset(); 401 add_menu_option_.reset();
402 } 402 }
403 403
404 } // namespace tray 404 } // namespace tray
405 } // namespace ash 405 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698