OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/app_list/app_list_menu.h" | |
6 | |
7 #include <stddef.h> | |
8 | |
9 #include "build/build_config.h" | |
10 #include "ui/app_list/app_list_view_delegate.h" | |
11 #include "ui/app_list/resources/grit/app_list_resources.h" | |
12 #include "ui/base/l10n/l10n_util.h" | |
13 #include "ui/base/models/menu_separator_types.h" | |
14 #include "ui/base/resource/resource_bundle.h" | |
15 #include "ui/strings/grit/ui_strings.h" | |
16 | |
17 namespace app_list { | |
18 | |
19 AppListMenu::AppListMenu(AppListViewDelegate* delegate) | |
20 : menu_model_(this), | |
21 delegate_(delegate), | |
22 users_(delegate->GetUsers()) { | |
23 InitMenu(); | |
24 } | |
25 | |
26 AppListMenu::~AppListMenu() {} | |
27 | |
28 void AppListMenu::InitMenu() { | |
29 // User selector menu section. We don't show the user selector if there is | |
30 // only 1 user. | |
31 if (users_.size() > 1) { | |
32 for (size_t i = 0; i < users_.size(); ++i) { | |
33 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
34 menu_model_.AddItem(SELECT_PROFILE + i, users_[i].name); | |
35 int menu_index = menu_model_.GetIndexOfCommandId(SELECT_PROFILE + i); | |
36 menu_model_.SetSublabel(menu_index, users_[i].email); | |
37 // Use custom check mark. | |
38 if (users_[i].active) { | |
39 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
40 menu_model_.SetIcon(menu_index, gfx::Image(*rb.GetImageSkiaNamed( | |
41 IDR_APP_LIST_USER_INDICATOR))); | |
42 } | |
43 #endif | |
44 } | |
45 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | |
46 } | |
47 | |
48 menu_model_.AddItem(SHOW_HELP, l10n_util::GetStringUTF16( | |
49 IDS_APP_LIST_HELP)); | |
50 | |
51 menu_model_.AddItem(SHOW_FEEDBACK, l10n_util::GetStringUTF16( | |
52 IDS_APP_LIST_OPEN_FEEDBACK)); | |
53 } | |
54 | |
55 bool AppListMenu::IsCommandIdChecked(int command_id) const { | |
56 return false; | |
57 } | |
58 | |
59 bool AppListMenu::IsCommandIdEnabled(int command_id) const { | |
60 return true; | |
61 } | |
62 | |
63 void AppListMenu::ExecuteCommand(int command_id, int event_flags) { | |
64 if (command_id >= SELECT_PROFILE) { | |
65 delegate_->ShowForProfileByPath( | |
66 users_[command_id - SELECT_PROFILE].profile_path); | |
67 return; | |
68 } | |
69 switch (command_id) { | |
70 case SHOW_HELP: | |
71 delegate_->OpenHelp(); | |
72 break; | |
73 case SHOW_FEEDBACK: | |
74 delegate_->OpenFeedback(); | |
75 break; | |
76 default: | |
77 NOTREACHED(); | |
78 } | |
79 } | |
80 | |
81 } // namespace app_list | |
OLD | NEW |