OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "ui/app_list/app_list_menu.h" | 5 #include "ui/app_list/app_list_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/app_list/app_list_view_delegate.h" | 10 #include "ui/app_list/app_list_view_delegate.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 InitMenu(); | 23 InitMenu(); |
24 } | 24 } |
25 | 25 |
26 AppListMenu::~AppListMenu() {} | 26 AppListMenu::~AppListMenu() {} |
27 | 27 |
28 void AppListMenu::InitMenu() { | 28 void AppListMenu::InitMenu() { |
29 // User selector menu section. We don't show the user selector if there is | 29 // User selector menu section. We don't show the user selector if there is |
30 // only 1 user. | 30 // only 1 user. |
31 if (users_.size() > 1) { | 31 if (users_.size() > 1) { |
32 for (size_t i = 0; i < users_.size(); ++i) { | 32 for (size_t i = 0; i < users_.size(); ++i) { |
33 #if defined(OS_MACOSX) | 33 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
34 menu_model_.AddRadioItem(SELECT_PROFILE + i, | |
35 users_[i].email.empty() ? users_[i].name | |
36 : users_[i].email, | |
37 0 /* group_id */); | |
38 #elif defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | |
39 menu_model_.AddItem(SELECT_PROFILE + i, users_[i].name); | 34 menu_model_.AddItem(SELECT_PROFILE + i, users_[i].name); |
40 int menu_index = menu_model_.GetIndexOfCommandId(SELECT_PROFILE + i); | 35 int menu_index = menu_model_.GetIndexOfCommandId(SELECT_PROFILE + i); |
41 menu_model_.SetSublabel(menu_index, users_[i].email); | 36 menu_model_.SetSublabel(menu_index, users_[i].email); |
42 // Use custom check mark. | 37 // Use custom check mark. |
43 if (users_[i].active) { | 38 if (users_[i].active) { |
44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 39 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
45 menu_model_.SetIcon(menu_index, gfx::Image(*rb.GetImageSkiaNamed( | 40 menu_model_.SetIcon(menu_index, gfx::Image(*rb.GetImageSkiaNamed( |
46 IDR_APP_LIST_USER_INDICATOR))); | 41 IDR_APP_LIST_USER_INDICATOR))); |
47 } | 42 } |
48 #endif | 43 #endif |
49 } | 44 } |
50 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 45 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
51 } | 46 } |
52 | 47 |
53 menu_model_.AddItem(SHOW_HELP, l10n_util::GetStringUTF16( | 48 menu_model_.AddItem(SHOW_HELP, l10n_util::GetStringUTF16( |
54 IDS_APP_LIST_HELP)); | 49 IDS_APP_LIST_HELP)); |
55 | 50 |
56 menu_model_.AddItem(SHOW_FEEDBACK, l10n_util::GetStringUTF16( | 51 menu_model_.AddItem(SHOW_FEEDBACK, l10n_util::GetStringUTF16( |
57 IDS_APP_LIST_OPEN_FEEDBACK)); | 52 IDS_APP_LIST_OPEN_FEEDBACK)); |
58 } | 53 } |
59 | 54 |
60 bool AppListMenu::IsCommandIdChecked(int command_id) const { | 55 bool AppListMenu::IsCommandIdChecked(int command_id) const { |
61 #if defined(OS_MACOSX) | |
62 DCHECK_LT(static_cast<unsigned>(command_id) - SELECT_PROFILE, users_.size()); | |
63 return users_[command_id - SELECT_PROFILE].active; | |
64 #else | |
65 return false; | 56 return false; |
66 #endif | |
67 } | 57 } |
68 | 58 |
69 bool AppListMenu::IsCommandIdEnabled(int command_id) const { | 59 bool AppListMenu::IsCommandIdEnabled(int command_id) const { |
70 return true; | 60 return true; |
71 } | 61 } |
72 | 62 |
73 bool AppListMenu::GetAcceleratorForCommandId( | 63 bool AppListMenu::GetAcceleratorForCommandId( |
74 int command_id, | 64 int command_id, |
75 ui::Accelerator* accelerator) const { | 65 ui::Accelerator* accelerator) const { |
76 return false; | 66 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
88 break; | 78 break; |
89 case SHOW_FEEDBACK: | 79 case SHOW_FEEDBACK: |
90 delegate_->OpenFeedback(); | 80 delegate_->OpenFeedback(); |
91 break; | 81 break; |
92 default: | 82 default: |
93 NOTREACHED(); | 83 NOTREACHED(); |
94 } | 84 } |
95 } | 85 } |
96 | 86 |
97 } // namespace app_list | 87 } // namespace app_list |
OLD | NEW |