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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Address comments. Created 4 years, 2 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/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/shelf_model.h" 10 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/common/shelf/shelf_widget.h"
12 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
13 #include "ash/common/strings/grit/ash_strings.h" 12 #include "ash/common/strings/grit/ash_strings.h"
14 #include "ash/common/wallpaper/wallpaper_delegate.h" 13 #include "ash/common/wallpaper/wallpaper_delegate.h"
15 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
16 #include "build/build_config.h" 15 #include "build/build_config.h"
17 #include "chrome/browser/fullscreen.h" 16 #include "chrome/browser/fullscreen.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 18 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
20 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" 19 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h"
21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
(...skipping 21 matching lines...) Expand all
43 const ash::ShelfItem* item, 42 const ash::ShelfItem* item,
44 ash::WmShelf* wm_shelf) { 43 ash::WmShelf* wm_shelf) {
45 DCHECK(controller); 44 DCHECK(controller);
46 DCHECK(wm_shelf); 45 DCHECK(wm_shelf);
47 // Create DesktopShellLauncherContextMenu if no item is selected. 46 // Create DesktopShellLauncherContextMenu if no item is selected.
48 if (!item || item->id == 0) 47 if (!item || item->id == 0)
49 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf); 48 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf);
50 49
51 // Create ArcLauncherContextMenu if the item is an Arc app. 50 // Create ArcLauncherContextMenu if the item is an Arc app.
52 const std::string& app_id = controller->GetAppIDForShelfID(item->id); 51 const std::string& app_id = controller->GetAppIDForShelfID(item->id);
53 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(controller->GetProfile()); 52 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(controller->profile());
54 if (arc_prefs && arc_prefs->IsRegistered(app_id)) 53 if (arc_prefs && arc_prefs->IsRegistered(app_id))
55 return new ArcLauncherContextMenu(controller, item, wm_shelf); 54 return new ArcLauncherContextMenu(controller, item, wm_shelf);
56 55
57 // Create ExtensionLauncherContextMenu for the item. 56 // Create ExtensionLauncherContextMenu for the item.
58 return new ExtensionLauncherContextMenu(controller, item, wm_shelf); 57 return new ExtensionLauncherContextMenu(controller, item, wm_shelf);
59 } 58 }
60 59
61 LauncherContextMenu::LauncherContextMenu( 60 LauncherContextMenu::LauncherContextMenu(
62 ChromeLauncherControllerImpl* controller, 61 ChromeLauncherControllerImpl* controller,
63 const ash::ShelfItem* item, 62 const ash::ShelfItem* item,
(...skipping 29 matching lines...) Expand all
93 92
94 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { 93 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
95 switch (command_id) { 94 switch (command_id) {
96 case MENU_PIN: 95 case MENU_PIN:
97 return controller_->IsPinnable(item_.id); 96 return controller_->IsPinnable(item_.id);
98 case MENU_CHANGE_WALLPAPER: 97 case MENU_CHANGE_WALLPAPER:
99 return ash::WmShell::Get() 98 return ash::WmShell::Get()
100 ->wallpaper_delegate() 99 ->wallpaper_delegate()
101 ->CanOpenSetWallpaperPage(); 100 ->CanOpenSetWallpaperPage();
102 case MENU_AUTO_HIDE: 101 case MENU_AUTO_HIDE:
103 return CanUserModifyShelfAutoHideBehavior(controller_->GetProfile()); 102 return CanUserModifyShelfAutoHideBehavior(controller_->profile());
104 default: 103 default:
105 DCHECK(command_id < MENU_ITEM_COUNT); 104 DCHECK(command_id < MENU_ITEM_COUNT);
106 return true; 105 return true;
107 } 106 }
108 } 107 }
109 108
110 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { 109 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) {
111 switch (static_cast<MenuItem>(command_id)) { 110 switch (static_cast<MenuItem>(command_id)) {
112 case MENU_OPEN_NEW: 111 case MENU_OPEN_NEW:
113 controller_->Launch(item_.id, ui::EF_NONE); 112 controller_->Launch(item_.id, ui::EF_NONE);
(...skipping 29 matching lines...) Expand all
143 default: 142 default:
144 NOTREACHED(); 143 NOTREACHED();
145 } 144 }
146 } 145 }
147 146
148 void LauncherContextMenu::AddPinMenu() { 147 void LauncherContextMenu::AddPinMenu() {
149 // Expect an item with a none zero id to add pin/unpin menu item. 148 // Expect an item with a none zero id to add pin/unpin menu item.
150 DCHECK(item_.id); 149 DCHECK(item_.id);
151 int menu_pin_string_id; 150 int menu_pin_string_id;
152 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); 151 const std::string app_id = controller_->GetAppIDForShelfID(item_.id);
153 switch (GetPinnableForAppID(app_id, controller_->GetProfile())) { 152 switch (GetPinnableForAppID(app_id, controller_->profile())) {
154 case AppListControllerDelegate::PIN_EDITABLE: 153 case AppListControllerDelegate::PIN_EDITABLE:
155 menu_pin_string_id = controller_->IsPinned(item_.id) 154 menu_pin_string_id = controller_->IsPinned(item_.id)
156 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN 155 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN
157 : IDS_LAUNCHER_CONTEXT_MENU_PIN; 156 : IDS_LAUNCHER_CONTEXT_MENU_PIN;
158 break; 157 break;
159 case AppListControllerDelegate::PIN_FIXED: 158 case AppListControllerDelegate::PIN_FIXED:
160 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; 159 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY;
161 break; 160 break;
162 case AppListControllerDelegate::NO_PIN: 161 case AppListControllerDelegate::NO_PIN:
163 return; 162 return;
164 default: 163 default:
165 NOTREACHED(); 164 NOTREACHED();
166 return; 165 return;
167 } 166 }
168 AddItemWithStringId(MENU_PIN, menu_pin_string_id); 167 AddItemWithStringId(MENU_PIN, menu_pin_string_id);
169 } 168 }
170 169
171 void LauncherContextMenu::AddShelfOptionsMenu() { 170 void LauncherContextMenu::AddShelfOptionsMenu() {
172 // In fullscreen, the launcher is either hidden or autohidden depending 171 // In fullscreen, the launcher is either hidden or autohidden depending
173 // on thethe type of fullscreen. Do not show the auto-hide menu item while in 172 // on thethe type of fullscreen. Do not show the auto-hide menu item while in
174 // while in fullscreen because it is confusing when the preference appears 173 // while in fullscreen because it is confusing when the preference appears
175 // not to apply. 174 // not to apply.
176 if (!IsFullScreenMode() && 175 if (!IsFullScreenMode() &&
177 CanUserModifyShelfAutoHideBehavior(controller_->GetProfile())) { 176 CanUserModifyShelfAutoHideBehavior(controller_->profile())) {
178 AddCheckItemWithStringId(MENU_AUTO_HIDE, 177 AddCheckItemWithStringId(MENU_AUTO_HIDE,
179 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); 178 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
180 } 179 }
181 if (ash::ShelfWidget::ShelfAlignmentAllowed() && 180 if (ash::WmShelf::CanChangeShelfAlignment() &&
182 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) { 181 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) {
183 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, 182 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
184 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, 183 IDS_ASH_SHELF_CONTEXT_MENU_POSITION,
185 &shelf_alignment_menu_); 184 &shelf_alignment_menu_);
186 } 185 }
187 if (!controller_->GetProfile()->IsGuestSession()) 186 if (!controller_->profile()->IsGuestSession())
188 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); 187 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER);
189 } 188 }
190 189
191 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, 190 bool LauncherContextMenu::ExecuteCommonCommand(int command_id,
192 int event_flags) { 191 int event_flags) {
193 switch (command_id) { 192 switch (command_id) {
194 case MENU_OPEN_NEW: 193 case MENU_OPEN_NEW:
195 case MENU_CLOSE: 194 case MENU_CLOSE:
196 case MENU_PIN: 195 case MENU_PIN:
197 case MENU_AUTO_HIDE: 196 case MENU_AUTO_HIDE:
198 case MENU_ALIGNMENT_MENU: 197 case MENU_ALIGNMENT_MENU:
199 case MENU_CHANGE_WALLPAPER: 198 case MENU_CHANGE_WALLPAPER:
200 LauncherContextMenu::ExecuteCommand(command_id, event_flags); 199 LauncherContextMenu::ExecuteCommand(command_id, event_flags);
201 return true; 200 return true;
202 default: 201 default:
203 return false; 202 return false;
204 } 203 }
205 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698