| 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..6d48a70c6e466cbe0f1af4c617951e0826a09f1f 100644
|
| --- a/ui/app_list/app_list_menu.cc
|
| +++ b/ui/app_list/app_list_menu.cc
|
| @@ -7,6 +7,7 @@
|
| #include "grit/ui_strings.h"
|
| #include "ui/app_list/app_list_view_delegate.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/base/models/avatar_menu_item_model.h"
|
| #include "ui/base/models/menu_separator_types.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
|
|
| @@ -14,6 +15,7 @@ namespace app_list {
|
|
|
| AppListMenu::AppListMenu(AppListViewDelegate* delegate)
|
| : menu_model_(this),
|
| + profiles_model_(this),
|
| delegate_(delegate) {
|
| InitMenu();
|
| }
|
| @@ -21,7 +23,16 @@ AppListMenu::AppListMenu(AppListViewDelegate* delegate)
|
| AppListMenu::~AppListMenu() {}
|
|
|
| void AppListMenu::InitMenu() {
|
| - menu_model_.AddItem(CURRENT_USER, base::string16());
|
| + std::vector<AvatarMenuItemModel> items = delegate_->GetAvatarMenuItems();
|
| + // Don't show the profile selector submenu if there is only one profile.
|
| + if (items.size() == 1) {
|
| + menu_model_.AddItem(CURRENT_USER, base::string16());
|
| + } else {
|
| + for (size_t i = 0; i < items.size(); ++i) {
|
| + profiles_model_.AddItem(SELECT_PROFILE + i, items[i].name);
|
| + }
|
| + menu_model_.AddSubMenu(CURRENT_USER, base::string16(), &profiles_model_);
|
| + }
|
| menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
| menu_model_.AddItem(SHOW_SETTINGS, l10n_util::GetStringUTF16(
|
| @@ -48,6 +59,11 @@ bool AppListMenu::GetAcceleratorForCommandId(int command_id,
|
| }
|
|
|
| void AppListMenu::ExecuteCommand(int command_id, int event_flags) {
|
| + if (command_id >= SELECT_PROFILE) {
|
| + delegate_->ShowForProfileAtIndex(
|
| + static_cast<size_t>(command_id - SELECT_PROFILE));
|
| + return;
|
| + }
|
| switch (command_id) {
|
| case CURRENT_USER:
|
| break; // Do nothing.
|
|
|