| OLD | NEW |
| 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/accounts_detailed_view.h" | 5 #include "ash/system/user/accounts_detailed_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/multi_profile_uma.h" | 9 #include "ash/multi_profile_uma.h" |
| 10 #include "ash/session/user_info.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/system/tray/fixed_sized_scroll_view.h" | 12 #include "ash/system/tray/fixed_sized_scroll_view.h" |
| 12 #include "ash/system/tray/hover_highlight_view.h" | 13 #include "ash/system/tray/hover_highlight_view.h" |
| 13 #include "ash/system/tray/system_tray.h" | 14 #include "ash/system/tray/system_tray.h" |
| 14 #include "ash/system/tray/system_tray_delegate.h" | 15 #include "ash/system/tray/system_tray_delegate.h" |
| 15 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
| 16 #include "ash/system/tray/tray_popup_header_button.h" | 17 #include "ash/system/tray/tray_popup_header_button.h" |
| 17 #include "ash/system/user/config.h" | 18 #include "ash/system/user/config.h" |
| 18 #include "ash/system/user/tray_user.h" | 19 #include "ash/system/user/tray_user.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 AccountsDetailedView::AccountsDetailedView(TrayUser* owner, | 40 AccountsDetailedView::AccountsDetailedView(TrayUser* owner, |
| 40 user::LoginStatus login_status) | 41 user::LoginStatus login_status) |
| 41 : TrayDetailsView(owner), | 42 : TrayDetailsView(owner), |
| 42 delegate_(NULL), | 43 delegate_(NULL), |
| 43 account_list_(NULL), | 44 account_list_(NULL), |
| 44 add_account_button_(NULL), | 45 add_account_button_(NULL), |
| 45 add_user_button_(NULL) { | 46 add_user_button_(NULL) { |
| 46 std::string user_id = | 47 std::string user_id = |
| 47 Shell::GetInstance()->session_state_delegate()->GetUserID(0); | 48 Shell::GetInstance()->session_state_delegate()->GetUserInfo(0)->GetID(); |
| 48 delegate_ = | 49 delegate_ = |
| 49 Shell::GetInstance()->system_tray_delegate()->GetUserAccountsDelegate( | 50 Shell::GetInstance()->system_tray_delegate()->GetUserAccountsDelegate( |
| 50 user_id); | 51 user_id); |
| 51 delegate_->AddObserver(this); | 52 delegate_->AddObserver(this); |
| 52 AddHeader(login_status); | 53 AddHeader(login_status); |
| 53 CreateScrollableList(); | 54 CreateScrollableList(); |
| 54 AddAccountList(); | 55 AddAccountList(); |
| 55 AddAddAccountButton(); | 56 AddAddAccountButton(); |
| 56 AddFooter(); | 57 AddFooter(); |
| 57 } | 58 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 scroll_content()->AddChildView(account_list_title); | 111 scroll_content()->AddChildView(account_list_title); |
| 111 account_list_ = new views::View(); | 112 account_list_ = new views::View(); |
| 112 UpdateAccountList(); | 113 UpdateAccountList(); |
| 113 scroll_content()->AddChildView(account_list_); | 114 scroll_content()->AddChildView(account_list_); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void AccountsDetailedView::AddAddAccountButton() { | 117 void AccountsDetailedView::AddAddAccountButton() { |
| 117 SessionStateDelegate* session_state_delegate = | 118 SessionStateDelegate* session_state_delegate = |
| 118 Shell::GetInstance()->session_state_delegate(); | 119 Shell::GetInstance()->session_state_delegate(); |
| 119 HoverHighlightView* add_account_button = new HoverHighlightView(this); | 120 HoverHighlightView* add_account_button = new HoverHighlightView(this); |
| 120 base::string16 user_name = session_state_delegate->GetUserGivenName(0); | 121 const UserInfo* user_info = session_state_delegate->GetUserInfo(0); |
| 122 base::string16 user_name = user_info->GetGivenName(); |
| 121 if (user_name.empty()) | 123 if (user_name.empty()) |
| 122 user_name = session_state_delegate->GetUserDisplayName(0); | 124 user_name = user_info->GetDisplayName(); |
| 123 if (user_name.empty()) | 125 if (user_name.empty()) |
| 124 user_name = base::ASCIIToUTF16(session_state_delegate->GetUserEmail(0)); | 126 user_name = base::ASCIIToUTF16(user_info->GetEmail()); |
| 125 add_account_button->AddLabel( | 127 add_account_button->AddLabel( |
| 126 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ADD_ACCOUNT_LABEL, | 128 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ADD_ACCOUNT_LABEL, |
| 127 user_name), | 129 user_name), |
| 128 gfx::ALIGN_CENTER, | 130 gfx::ALIGN_CENTER, |
| 129 gfx::Font::NORMAL); | 131 gfx::Font::NORMAL); |
| 130 AddChildView(add_account_button); | 132 AddChildView(add_account_button); |
| 131 add_account_button_ = add_account_button; | 133 add_account_button_ = add_account_button; |
| 132 } | 134 } |
| 133 | 135 |
| 134 void AccountsDetailedView::AddFooter() { | 136 void AccountsDetailedView::AddFooter() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | 220 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); |
| 219 delete_button->SetImage(views::Button::STATE_HOVERED, | 221 delete_button->SetImage(views::Button::STATE_HOVERED, |
| 220 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | 222 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); |
| 221 delete_button->SetImage(views::Button::STATE_PRESSED, | 223 delete_button->SetImage(views::Button::STATE_PRESSED, |
| 222 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | 224 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); |
| 223 return delete_button; | 225 return delete_button; |
| 224 } | 226 } |
| 225 | 227 |
| 226 } // namespace tray | 228 } // namespace tray |
| 227 } // namespace ash | 229 } // namespace ash |
| OLD | NEW |