Chromium Code Reviews| Index: ui/app_list/app_list_menu.cc |
| diff --git a/ui/app_list/app_list_menu.cc b/ui/app_list/app_list_menu.cc |
| index 95d6ac38d91b3acc2f6355b56a68e241dd00d953..645541ea90d205956c3ab8038bb9e3242a94f84a 100644 |
| --- a/ui/app_list/app_list_menu.cc |
| +++ b/ui/app_list/app_list_menu.cc |
| @@ -4,6 +4,7 @@ |
| #include "ui/app_list/app_list_menu.h" |
| +#include "grit/ui_resources.h" |
| #include "grit/ui_strings.h" |
| #include "ui/app_list/app_list_view_delegate.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -12,17 +13,30 @@ |
| namespace app_list { |
| -AppListMenu::AppListMenu(AppListViewDelegate* delegate) |
| +AppListMenu::AppListMenu(AppListViewDelegate* delegate, |
| + const AppListModel::Users& users) |
| : menu_model_(this), |
| - delegate_(delegate) { |
| + delegate_(delegate), |
| + users_(users) { |
| InitMenu(); |
| } |
| AppListMenu::~AppListMenu() {} |
| void AppListMenu::InitMenu() { |
| - menu_model_.AddItem(CURRENT_USER, base::string16()); |
| - menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| + // User selector menu section. |
|
tapted
2013/09/10 00:29:26
nit: perhaps mention that when there is exactly 1
calamity
2013/09/10 22:50:46
Done.
|
| + if (users_.size() > 1) { |
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| + for (size_t i = 0; i < users_.size(); ++i) { |
| + menu_model_.AddItem(SELECT_PROFILE + i, users_[i]->name); |
| + menu_model_.SetSublabel(i, users_[i]->email); |
|
tapted
2013/09/10 00:29:26
You should do
int menu_index = GetIndexOfCommandI
calamity
2013/09/10 22:50:46
Done. What was GetSublabelAt() for?
|
| + if (users_[i]->active) { |
|
tapted
2013/09/10 00:29:26
Also, why not IsCommandIdChecked? Maybe a comment
calamity
2013/09/10 22:50:46
Done.
|
| + menu_model_.SetIcon(i, gfx::Image(*rb.GetImageSkiaNamed( |
| + IDR_APP_LIST_CURRENT_USER_INDICATOR))); |
| + } |
| + } |
| + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| + } |
| menu_model_.AddItem(SHOW_SETTINGS, l10n_util::GetStringUTF16( |
| IDS_APP_LIST_OPEN_SETTINGS)); |
| @@ -48,6 +62,11 @@ bool AppListMenu::GetAcceleratorForCommandId(int command_id, |
| } |
| void AppListMenu::ExecuteCommand(int command_id, int event_flags) { |
| + if (command_id >= SELECT_PROFILE) { |
| + delegate_->ShowForProfileByPath( |
| + users_[command_id - SELECT_PROFILE]->profile_path); |
| + return; |
| + } |
| switch (command_id) { |
| case CURRENT_USER: |
| break; // Do nothing. |