OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/desktop_background/user_wallpaper_delegate.h" | 9 #include "ash/desktop_background/user_wallpaper_delegate.h" |
10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 OpenSetWallpaperPage(); | 153 OpenSetWallpaperPage(); |
154 break; | 154 break; |
155 default: | 155 default: |
156 NOTREACHED(); | 156 NOTREACHED(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void LauncherContextMenu::AddPinMenu() { | 160 void LauncherContextMenu::AddPinMenu() { |
161 // Expect an item with a none zero id to add pin/unpin menu item. | 161 // Expect an item with a none zero id to add pin/unpin menu item. |
162 DCHECK(item_.id); | 162 DCHECK(item_.id); |
| 163 int menu_pin_string_id; |
163 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); | 164 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); |
164 int menu_pin_string_id; | 165 switch (controller_->GetPinnable(app_id)) { |
165 if (!controller_->CanPin(app_id)) | 166 case AppListControllerDelegate::PIN_EDITABLE: |
166 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; | 167 menu_pin_string_id = controller_->IsPinned(item_.id) |
167 else if (controller_->IsPinned(item_.id)) | 168 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN |
168 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_UNPIN; | 169 : IDS_LAUNCHER_CONTEXT_MENU_PIN; |
169 else | 170 break; |
170 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN; | 171 case AppListControllerDelegate::PIN_FIXED: |
| 172 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; |
| 173 break; |
| 174 case AppListControllerDelegate::NO_PIN: |
| 175 return; |
| 176 default: |
| 177 NOTREACHED(); |
| 178 return; |
| 179 } |
171 AddItemWithStringId(MENU_PIN, menu_pin_string_id); | 180 AddItemWithStringId(MENU_PIN, menu_pin_string_id); |
172 } | 181 } |
173 | 182 |
174 void LauncherContextMenu::AddShelfOptionsMenu() { | 183 void LauncherContextMenu::AddShelfOptionsMenu() { |
175 // In fullscreen, the launcher is either hidden or autohidden depending | 184 // In fullscreen, the launcher is either hidden or autohidden depending |
176 // on thethe type of fullscreen. Do not show the auto-hide menu item while in | 185 // on thethe type of fullscreen. Do not show the auto-hide menu item while in |
177 // while in fullscreen because it is confusing when the preference appears | 186 // while in fullscreen because it is confusing when the preference appears |
178 // not to apply. | 187 // not to apply. |
179 if (!IsFullScreenMode() && | 188 if (!IsFullScreenMode() && |
180 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { | 189 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { |
(...skipping 20 matching lines...) Expand all Loading... |
201 case MENU_PIN: | 210 case MENU_PIN: |
202 case MENU_AUTO_HIDE: | 211 case MENU_AUTO_HIDE: |
203 case MENU_ALIGNMENT_MENU: | 212 case MENU_ALIGNMENT_MENU: |
204 case MENU_CHANGE_WALLPAPER: | 213 case MENU_CHANGE_WALLPAPER: |
205 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 214 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
206 return true; | 215 return true; |
207 default: | 216 default: |
208 return false; | 217 return false; |
209 } | 218 } |
210 } | 219 } |
OLD | NEW |