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

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_context_menu.cc

Issue 2870683002: ash: Remove ShelfModel id conversion functions. (Closed)
Patch Set: Address comments. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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/shelf/shelf_model.h" 9 #include "ash/shelf/shelf_model.h"
10 #include "ash/shelf/wm_shelf.h" 10 #include "ash/shelf/wm_shelf.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 ChromeLauncherController* controller, 45 ChromeLauncherController* controller,
46 const ash::ShelfItem* item, 46 const ash::ShelfItem* item,
47 ash::WmShelf* wm_shelf) { 47 ash::WmShelf* wm_shelf) {
48 DCHECK(controller); 48 DCHECK(controller);
49 DCHECK(wm_shelf); 49 DCHECK(wm_shelf);
50 // Create DesktopShellLauncherContextMenu if no item is selected. 50 // Create DesktopShellLauncherContextMenu if no item is selected.
51 if (!item || item->id.IsNull()) 51 if (!item || item->id.IsNull())
52 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf); 52 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf);
53 53
54 // Create ArcLauncherContextMenu if the item is an ARC app. 54 // Create ArcLauncherContextMenu if the item is an ARC app.
55 const std::string& app_id = controller->GetAppIDForShelfID(item->id); 55 if (arc::IsArcItem(controller->profile(), item->id.app_id))
56 if (arc::IsArcItem(controller->profile(), app_id))
57 return new ArcLauncherContextMenu(controller, item, wm_shelf); 56 return new ArcLauncherContextMenu(controller, item, wm_shelf);
58 57
59 // Create ExtensionLauncherContextMenu for the item. 58 // Create ExtensionLauncherContextMenu for the item.
60 return new ExtensionLauncherContextMenu(controller, item, wm_shelf); 59 return new ExtensionLauncherContextMenu(controller, item, wm_shelf);
61 } 60 }
62 61
63 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, 62 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller,
64 const ash::ShelfItem* item, 63 const ash::ShelfItem* item,
65 ash::WmShelf* wm_shelf) 64 ash::WmShelf* wm_shelf)
66 : ui::SimpleMenuModel(nullptr), 65 : ui::SimpleMenuModel(nullptr),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 break; 144 break;
146 default: 145 default:
147 NOTREACHED(); 146 NOTREACHED();
148 } 147 }
149 } 148 }
150 149
151 void LauncherContextMenu::AddPinMenu() { 150 void LauncherContextMenu::AddPinMenu() {
152 // Expect a valid ShelfID to add pin/unpin menu item. 151 // Expect a valid ShelfID to add pin/unpin menu item.
153 DCHECK(!item_.id.IsNull()); 152 DCHECK(!item_.id.IsNull());
154 int menu_pin_string_id; 153 int menu_pin_string_id;
155 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); 154 switch (GetPinnableForAppID(item_.id.app_id, controller_->profile())) {
156 switch (GetPinnableForAppID(app_id, controller_->profile())) {
157 case AppListControllerDelegate::PIN_EDITABLE: 155 case AppListControllerDelegate::PIN_EDITABLE:
158 menu_pin_string_id = controller_->IsPinned(item_.id) 156 menu_pin_string_id = controller_->IsPinned(item_.id)
159 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN 157 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN
160 : IDS_LAUNCHER_CONTEXT_MENU_PIN; 158 : IDS_LAUNCHER_CONTEXT_MENU_PIN;
161 break; 159 break;
162 case AppListControllerDelegate::PIN_FIXED: 160 case AppListControllerDelegate::PIN_FIXED:
163 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; 161 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY;
164 break; 162 break;
165 case AppListControllerDelegate::NO_PIN: 163 case AppListControllerDelegate::NO_PIN:
166 return; 164 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 case MENU_PIN: 198 case MENU_PIN:
201 case MENU_AUTO_HIDE: 199 case MENU_AUTO_HIDE:
202 case MENU_ALIGNMENT_MENU: 200 case MENU_ALIGNMENT_MENU:
203 case MENU_CHANGE_WALLPAPER: 201 case MENU_CHANGE_WALLPAPER:
204 LauncherContextMenu::ExecuteCommand(command_id, event_flags); 202 LauncherContextMenu::ExecuteCommand(command_id, event_flags);
205 return true; 203 return true;
206 default: 204 default:
207 return false; 205 return false;
208 } 206 }
209 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698