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

Unified Diff: ui/app_list/app_list_menu.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove junk from list_model.h Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
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..7a73ef43b8837e2e7cc44b1e1edd22e8b95093a1 100644
--- a/ui/app_list/app_list_menu.cc
+++ b/ui/app_list/app_list_menu.cc
@@ -8,20 +8,33 @@
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/menu_separator_types.h"
+#include "ui/base/profile_selector/avatar_menu_item_model.h"
#include "ui/base/resource/resource_bundle.h"
namespace app_list {
-AppListMenu::AppListMenu(AppListViewDelegate* delegate)
- : menu_model_(this),
- delegate_(delegate) {
+AppListMenu::AppListMenu(
+ AppListViewDelegate* delegate,
+ const app_list::AppListModel::ProfileMenuItems& profile_menu_items)
+ : menu_model_(this),
+ profiles_model_(this),
+ delegate_(delegate),
+ profile_menu_items_(profile_menu_items) {
InitMenu();
}
AppListMenu::~AppListMenu() {}
void AppListMenu::InitMenu() {
- menu_model_.AddItem(CURRENT_USER, base::string16());
+ // Don't show the profile selector submenu if there is only one profile.
+ if (profile_menu_items_.size() == 1) {
+ menu_model_.AddItem(CURRENT_USER, base::string16());
+ } else {
+ for (size_t i = 0; i < profile_menu_items_.size(); ++i) {
+ profiles_model_.AddItem(SELECT_PROFILE + i, profile_menu_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 +61,11 @@ bool AppListMenu::GetAcceleratorForCommandId(int command_id,
}
void AppListMenu::ExecuteCommand(int command_id, int event_flags) {
+ if (command_id >= SELECT_PROFILE) {
+ delegate_->ShowForProfileByPath(
+ profile_menu_items_[command_id - SELECT_PROFILE]->profile_path);
+ return;
+ }
switch (command_id) {
case CURRENT_USER:
break; // Do nothing.

Powered by Google App Engine
This is Rietveld 408576698