diff options
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/tray/media_security/multi_profile_media_tray_item.cc | 10 | ||||
-rw-r--r-- | ash/system/user/tray_user.cc | 21 | ||||
-rw-r--r-- | ash/system/user/tray_user.h | 12 | ||||
-rw-r--r-- | ash/system/user/user_card_view.cc | 43 | ||||
-rw-r--r-- | ash/system/user/user_card_view.h | 9 | ||||
-rw-r--r-- | ash/system/user/user_view.cc | 28 | ||||
-rw-r--r-- | ash/system/user/user_view.h | 4 |
7 files changed, 56 insertions, 71 deletions
diff --git a/ash/system/tray/media_security/multi_profile_media_tray_item.cc b/ash/system/tray/media_security/multi_profile_media_tray_item.cc index 870d4cd..468aa64 100644 --- a/ash/system/tray/media_security/multi_profile_media_tray_item.cc +++ b/ash/system/tray/media_security/multi_profile_media_tray_item.cc @@ -5,6 +5,7 @@ #include "ash/system/tray/media_security/multi_profile_media_tray_item.h" #include "ash/ash_view_ids.h" +#include "ash/content/shell_content_state.h" #include "ash/media_delegate.h" #include "ash/session/session_state_delegate.h" #include "ash/shell.h" @@ -46,12 +47,9 @@ class MultiProfileMediaTrayView : public TrayItemView, SessionStateDelegate* session_state_delegate = Shell::GetInstance()->session_state_delegate(); // The user at 0 is the current desktop user. - for (MultiProfileIndex index = 1; - index < session_state_delegate->NumberOfLoggedInUsers(); - ++index) { - content::BrowserContext* context = - session_state_delegate->GetBrowserContextByIndex(index); - if (media_delegate->GetMediaCaptureState(context) != MEDIA_CAPTURE_NONE) { + for (UserIndex index = 1; + index < session_state_delegate->NumberOfLoggedInUsers(); ++index) { + if (media_delegate->GetMediaCaptureState(index) != MEDIA_CAPTURE_NONE) { SetVisible(true); return; } diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 83ab7e7..fd101e7 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -39,9 +39,9 @@ const int kUserLabelToIconPadding = 5; namespace ash { -TrayUser::TrayUser(SystemTray* system_tray, MultiProfileIndex index) +TrayUser::TrayUser(SystemTray* system_tray, UserIndex index) : SystemTrayItem(system_tray), - multiprofile_index_(index), + user_index_(index), user_(nullptr), layout_view_(nullptr), avatar_(nullptr), @@ -95,9 +95,8 @@ views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { // If the screen is locked or a system modal dialog box is shown, show only // the currently active user. - if (multiprofile_index_ && - (session_state_delegate->IsUserSessionBlocked() || - Shell::GetInstance()->IsSystemModalWindowOpen())) + if (user_index_ && (session_state_delegate->IsUserSessionBlocked() || + Shell::GetInstance()->IsSystemModalWindowOpen())) return nullptr; CHECK(user_ == nullptr); @@ -105,10 +104,10 @@ views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { int logged_in_users = session_state_delegate->NumberOfLoggedInUsers(); // Do not show more UserView's then there are logged in users. - if (multiprofile_index_ >= logged_in_users) + if (user_index_ >= logged_in_users) return nullptr; - user_ = new tray::UserView(this, status, multiprofile_index_, false); + user_ = new tray::UserView(this, status, user_index_, false); return user_; } @@ -142,7 +141,7 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { // Only the active user is represented in the tray. if (!layout_view_) return; - if (multiprofile_index_ > 0) + if (user_index_ > 0) return; bool need_label = false; bool need_avatar = false; @@ -259,7 +258,7 @@ void TrayUser::OnUserAddedToSession() { SessionStateDelegate* session_state_delegate = Shell::GetInstance()->session_state_delegate(); // Only create views for user items which are logged in. - if (multiprofile_index_ >= session_state_delegate->NumberOfLoggedInUsers()) + if (user_index_ >= session_state_delegate->NumberOfLoggedInUsers()) return; // Enforce a layout change that newly added items become visible. @@ -274,11 +273,11 @@ void TrayUser::UpdateAvatarImage(user::LoginStatus status) { SessionStateDelegate* session_state_delegate = Shell::GetInstance()->session_state_delegate(); if (!avatar_ || - multiprofile_index_ >= session_state_delegate->NumberOfLoggedInUsers()) + user_index_ >= session_state_delegate->NumberOfLoggedInUsers()) return; const user_manager::UserInfo* user_info = - session_state_delegate->GetUserInfo(multiprofile_index_); + session_state_delegate->GetUserInfo(user_index_); CHECK(user_info); avatar_->SetImage(user_info->GetImage(), gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); diff --git a/ash/system/user/tray_user.h b/ash/system/user/tray_user.h index f66d672..f13005c 100644 --- a/ash/system/user/tray_user.h +++ b/ash/system/user/tray_user.h @@ -31,11 +31,11 @@ class UserView; class ASH_EXPORT TrayUser : public SystemTrayItem, public UserObserver { public: - // The given |multiprofile_index| is the user number in a multi profile - // scenario. Index #0 is the running user, the other indices are other logged - // in users (if there are any). Depending on the multi user mode, there will - // be either one (index #0) or all users be visible in the system tray. - TrayUser(SystemTray* system_tray, MultiProfileIndex index); + // The given |index| is the user index in a multi profile scenario. Index #0 + // is the active user, the other indices are other logged in users (if there + // are any). Depending on the multi user mode, there will be either one (index + // #0) or all users be visible in the system tray. + TrayUser(SystemTray* system_tray, UserIndex index); ~TrayUser() override; // Allows unit tests to see if the item was created. @@ -82,7 +82,7 @@ class ASH_EXPORT TrayUser : public SystemTrayItem, void UpdateLayoutOfItem(); // The user index to use. - MultiProfileIndex multiprofile_index_; + UserIndex user_index_; tray::UserView* user_; diff --git a/ash/system/user/user_card_view.cc b/ash/system/user/user_card_view.cc index 5201688..e582c8a 100644 --- a/ash/system/user/user_card_view.cc +++ b/ash/system/user/user_card_view.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <vector> +#include "ash/content/shell_content_state.h" #include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_delegate.h" @@ -60,7 +61,7 @@ const base::char16 kDisplayNameMark[] = {0x2060, 0}; #if defined(OS_CHROMEOS) class MediaIndicator : public views::View, public MediaCaptureObserver { public: - explicit MediaIndicator(MultiProfileIndex index) + explicit MediaIndicator(UserIndex index) : index_(index), label_(new views::Label) { SetLayoutManager(new views::FillLayout); views::ImageView* icon = new views::ImageView; @@ -83,11 +84,8 @@ class MediaIndicator : public views::View, public MediaCaptureObserver { // MediaCaptureObserver: void OnMediaCaptureChanged() override { - Shell* shell = Shell::GetInstance(); - content::BrowserContext* context = - shell->session_state_delegate()->GetBrowserContextByIndex(index_); MediaCaptureState state = - Shell::GetInstance()->media_delegate()->GetMediaCaptureState(context); + Shell::GetInstance()->media_delegate()->GetMediaCaptureState(index_); int res_id = 0; switch (state) { case MEDIA_CAPTURE_AUDIO_VIDEO: @@ -114,7 +112,7 @@ class MediaIndicator : public views::View, public MediaCaptureObserver { } private: - MultiProfileIndex index_; + UserIndex index_; views::Label* label_; DISALLOW_COPY_AND_ASSIGN(MediaIndicator); @@ -338,13 +336,13 @@ void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) { UserCardView::UserCardView(user::LoginStatus login_status, int max_width, - int multiprofile_index) { + int user_index) { SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems)); if (login_status == user::LOGGED_IN_PUBLIC) { AddPublicModeUserContent(max_width); } else { - AddUserContent(login_status, multiprofile_index); + AddUserContent(login_status, user_index); } } @@ -367,20 +365,20 @@ void UserCardView::AddPublicModeUserContent(int max_width) { } void UserCardView::AddUserContent(user::LoginStatus login_status, - int multiprofile_index) { - views::View* icon = CreateIcon(login_status, multiprofile_index); + int user_index) { + views::View* icon = CreateIcon(login_status, user_index); AddChildView(icon); views::Label* user_name = NULL; SessionStateDelegate* delegate = Shell::GetInstance()->session_state_delegate(); - if (!multiprofile_index) { + if (!user_index) { base::string16 user_name_string = login_status == user::LOGGED_IN_GUEST ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) - : delegate->GetUserInfo(multiprofile_index)->GetDisplayName(); + : delegate->GetUserInfo(user_index)->GetDisplayName(); if (user_name_string.empty() && IsMultiAccountSupportedAndUserActive()) - user_name_string = base::ASCIIToUTF16( - delegate->GetUserInfo(multiprofile_index)->GetEmail()); + user_name_string = + base::ASCIIToUTF16(delegate->GetUserInfo(user_index)->GetEmail()); if (!user_name_string.empty()) { user_name = new views::Label(user_name_string); user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); @@ -389,14 +387,13 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, views::Label* user_email = NULL; if (login_status != user::LOGGED_IN_GUEST && - (multiprofile_index || !IsMultiAccountSupportedAndUserActive())) { + (user_index || !IsMultiAccountSupportedAndUserActive())) { SystemTrayDelegate* tray_delegate = Shell::GetInstance()->system_tray_delegate(); base::string16 user_email_string = tray_delegate->IsUserSupervised() ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) - : base::UTF8ToUTF16( - delegate->GetUserInfo(multiprofile_index)->GetEmail()); + : base::UTF8ToUTF16(delegate->GetUserInfo(user_index)->GetEmail()); if (!user_email_string.empty()) { user_email = new views::Label(user_email_string); user_email->SetFontList( @@ -407,7 +404,7 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, } // Adjust text properties dependent on if it is an active or inactive user. - if (multiprofile_index) { + if (user_index) { // Fade the text of non active users to 50%. SkColor text_color = user_email->enabled_color(); text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2); @@ -430,7 +427,7 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, if (user_email) { #if defined(OS_CHROMEOS) // Only non active user can have a media indicator. - MediaIndicator* media_indicator = new MediaIndicator(multiprofile_index); + MediaIndicator* media_indicator = new MediaIndicator(user_index); views::View* email_indicator_view = new views::View; email_indicator_view->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems)); @@ -451,9 +448,9 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, } views::View* UserCardView::CreateIcon(user::LoginStatus login_status, - int multiprofile_index) { + int user_index) { RoundedImageView* icon = - new RoundedImageView(kTrayAvatarCornerRadius, multiprofile_index == 0); + new RoundedImageView(kTrayAvatarCornerRadius, user_index == 0); if (login_status == user::LOGGED_IN_GUEST) { icon->SetImage(*ui::ResourceBundle::GetSharedInstance() .GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON) @@ -462,9 +459,7 @@ views::View* UserCardView::CreateIcon(user::LoginStatus login_status, } else { SessionStateDelegate* delegate = Shell::GetInstance()->session_state_delegate(); - content::BrowserContext* context = - delegate->GetBrowserContextByIndex(multiprofile_index); - icon->SetImage(delegate->GetUserInfo(context)->GetImage(), + icon->SetImage(delegate->GetUserInfo(user_index)->GetImage(), gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); } return icon; diff --git a/ash/system/user/user_card_view.h b/ash/system/user/user_card_view.h index 147d3d9..130558d 100644 --- a/ash/system/user/user_card_view.h +++ b/ash/system/user/user_card_view.h @@ -17,9 +17,7 @@ namespace tray { class UserCardView : public views::View { public: // |max_width| takes effect only if |login_status| is LOGGED_IN_PUBLIC. - UserCardView(user::LoginStatus login_status, - int max_width, - int multiprofile_index); + UserCardView(user::LoginStatus login_status, int max_width, int user_index); ~UserCardView() override; // views::View overrides. @@ -29,11 +27,10 @@ class UserCardView : public views::View { // Creates the content for the public mode. void AddPublicModeUserContent(int max_width); - void AddUserContent(user::LoginStatus login_status, int multiprofile_index); + void AddUserContent(user::LoginStatus login_status, int user_index); // Create a user icon representation. - views::View* CreateIcon(user::LoginStatus login_status, - int multiprofile_index); + views::View* CreateIcon(user::LoginStatus login_status, int user_index); DISALLOW_COPY_AND_ASSIGN(UserCardView); }; diff --git a/ash/system/user/user_view.cc b/ash/system/user/user_view.cc index 3947138..7f7ece5 100644 --- a/ash/system/user/user_view.cc +++ b/ash/system/user/user_view.cc @@ -65,7 +65,7 @@ const int kTrayUserTileHoverBorderInset = 10; const int kPopupMessageOffset = 25; // Switch to a user with the given |user_index|. -void SwitchUser(ash::MultiProfileIndex user_index) { +void SwitchUser(ash::UserIndex user_index) { // Do not switch users when the log screen is presented. if (ash::Shell::GetInstance() ->session_state_delegate() @@ -193,9 +193,9 @@ void AddUserView::AddContent() { UserView::UserView(SystemTrayItem* owner, user::LoginStatus login, - MultiProfileIndex index, + UserIndex index, bool for_detailed_view) - : multiprofile_index_(index), + : user_index_(index), user_card_view_(NULL), owner_(owner), is_user_card_button_(false), @@ -216,7 +216,7 @@ UserView::UserView(SystemTrayItem* owner, // The logout button must be added before the user card so that the user card // can correctly calculate the remaining available width. // Note that only the current multiprofile user gets a button. - if (!multiprofile_index_) + if (!user_index_) AddLogoutButton(login); AddUserCard(login); } @@ -250,7 +250,7 @@ gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() { gfx::Size UserView::GetPreferredSize() const { gfx::Size size = views::View::GetPreferredSize(); // Only the active user panel will be forced to a certain height. - if (!multiprofile_index_) { + if (!user_index_) { size.set_height( std::max(size.height(), kTrayPopupItemHeight + GetInsets().height())); } @@ -313,16 +313,16 @@ void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { ash::UMA_STATUS_AREA_SIGN_OUT); RemoveAddUserMenuOption(); Shell::GetInstance()->system_tray_delegate()->SignOut(); - } else if (sender == user_card_view_ && !multiprofile_index_ && + } else if (sender == user_card_view_ && !user_index_ && IsMultiAccountSupportedAndUserActive()) { owner_->TransitionDetailedView(); } else if (sender == user_card_view_ && IsMultiProfileSupportedAndUserActive()) { - if (!multiprofile_index_) { + if (!user_index_) { ToggleAddUserMenuOption(); } else { RemoveAddUserMenuOption(); - SwitchUser(multiprofile_index_); + SwitchUser(user_index_); // Since the user list is about to change the system menu should get // closed. owner_->system_tray()->CloseSystemBubble(); @@ -390,8 +390,7 @@ void UserView::AddUserCard(user::LoginStatus login) { (2 * kTrayPopupPaddingHorizontal + kTrayPopupPaddingBetweenItems); if (logout_button_) max_card_width -= logout_button_->GetPreferredSize().width(); - user_card_view_ = - new UserCardView(login, max_card_width, multiprofile_index_); + user_card_view_ = new UserCardView(login, max_card_width, user_index_); // The entry is clickable when no system modal dialog is open and one of the // multi user options is active. bool clickable = !Shell::GetInstance()->IsSystemModalWindowOpen() && @@ -400,7 +399,7 @@ void UserView::AddUserCard(user::LoginStatus login) { if (clickable) { // To allow the border to start before the icon, reduce the size before and // add an inset to the icon to get the spacing. - if (!multiprofile_index_) { + if (!user_index_) { SetBorder(views::Border::CreateEmptyBorder( kTrayPopupUserCardVerticalPadding, kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset, @@ -413,7 +412,7 @@ void UserView::AddUserCard(user::LoginStatus login) { views::View* contents_view = user_card_view_; ButtonFromView* button = NULL; if (!for_detailed_view_) { - if (multiprofile_index_) { + if (user_index_) { // Since the activation border needs to be drawn around the tile, we // have to put the tile into another view which fills the menu panel, // but keeping the offsets of the content. @@ -428,10 +427,7 @@ void UserView::AddUserCard(user::LoginStatus login) { contents_view->AddChildView(user_card_view_); insets = gfx::Insets(1, 1, 1, 3); } - button = new ButtonFromView(contents_view, - this, - !multiprofile_index_, - insets); + button = new ButtonFromView(contents_view, this, !user_index_, insets); } else { // We want user card for detailed view to have exactly the same look // as user card for default view. That's why we wrap it in a button diff --git a/ash/system/user/user_view.h b/ash/system/user/user_view.h index 2c42f1d..562ce67 100644 --- a/ash/system/user/user_view.h +++ b/ash/system/user/user_view.h @@ -40,7 +40,7 @@ class UserView : public views::View, public: UserView(SystemTrayItem* owner, ash::user::LoginStatus login, - MultiProfileIndex index, + UserIndex index, bool for_detailed_view); ~UserView() override; @@ -75,7 +75,7 @@ class UserView : public views::View, // Removes the add user menu option. void RemoveAddUserMenuOption(); - MultiProfileIndex multiprofile_index_; + UserIndex user_index_; // The view of the user card. views::View* user_card_view_; |