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

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

Issue 298303002: Add option to install an ephemeral app to ChromeOS shelf context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed asargent's review comments Created 6 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_INCOGNITO_WINDOW)); 139 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_INCOGNITO_WINDOW));
140 } 140 }
141 } else if (item_.type == ash::TYPE_DIALOG) { 141 } else if (item_.type == ash::TYPE_DIALOG) {
142 AddItem(MENU_CLOSE, 142 AddItem(MENU_CLOSE,
143 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); 143 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
144 } else { 144 } else {
145 if (item_.type == ash::TYPE_PLATFORM_APP) { 145 if (item_.type == ash::TYPE_PLATFORM_APP) {
146 AddItem( 146 AddItem(
147 MENU_PIN, 147 MENU_PIN,
148 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN)); 148 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN));
149 AddItem(MENU_INSTALL, l10n_util::GetStringUTF16(IDS_APP_INSTALL_TITLE));
149 } 150 }
150 if (controller_->IsOpen(item_.id)) { 151 if (controller_->IsOpen(item_.id)) {
151 AddItem(MENU_CLOSE, 152 AddItem(MENU_CLOSE,
152 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); 153 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
153 } 154 }
154 } 155 }
155 AddSeparator(ui::NORMAL_SEPARATOR); 156 AddSeparator(ui::NORMAL_SEPARATOR);
156 if (item_.type == ash::TYPE_APP_SHORTCUT || 157 if (item_.type == ash::TYPE_APP_SHORTCUT ||
157 item_.type == ash::TYPE_WINDOWED_APP || 158 item_.type == ash::TYPE_WINDOWED_APP ||
158 item_.type == ash::TYPE_PLATFORM_APP) { 159 item_.type == ash::TYPE_PLATFORM_APP) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return controller_->CanUserModifyShelfAutoHideBehavior(root_window_); 254 return controller_->CanUserModifyShelfAutoHideBehavior(root_window_);
254 case MENU_NEW_INCOGNITO_WINDOW: 255 case MENU_NEW_INCOGNITO_WINDOW:
255 // Incognito windows are not allowed when incognito is disabled. 256 // Incognito windows are not allowed when incognito is disabled.
256 return IncognitoModePrefs::GetAvailability( 257 return IncognitoModePrefs::GetAvailability(
257 controller_->profile()->GetPrefs()) != IncognitoModePrefs::DISABLED; 258 controller_->profile()->GetPrefs()) != IncognitoModePrefs::DISABLED;
258 default: 259 default:
259 return extension_items_->IsCommandIdEnabled(command_id); 260 return extension_items_->IsCommandIdEnabled(command_id);
260 } 261 }
261 } 262 }
262 263
264 bool LauncherContextMenu::IsCommandIdVisible(int command_id) const {
265 if (item_.type != ash::TYPE_PLATFORM_APP)
266 return true;
267
268 switch (command_id) {
269 case MENU_PIN:
270 return !controller_->CanInstall(item_.id);
271 case MENU_INSTALL:
272 return controller_->CanInstall(item_.id);
273 default:
274 return true;
275 }
276 }
277
263 bool LauncherContextMenu::GetAcceleratorForCommandId( 278 bool LauncherContextMenu::GetAcceleratorForCommandId(
264 int command_id, 279 int command_id,
265 ui::Accelerator* accelerator) { 280 ui::Accelerator* accelerator) {
266 return false; 281 return false;
267 } 282 }
268 283
269 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { 284 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) {
270 switch (static_cast<MenuItem>(command_id)) { 285 switch (static_cast<MenuItem>(command_id)) {
271 case MENU_OPEN_NEW: 286 case MENU_OPEN_NEW:
272 controller_->Launch(item_.id, ui::EF_NONE); 287 controller_->Launch(item_.id, ui::EF_NONE);
273 break; 288 break;
274 case MENU_CLOSE: 289 case MENU_CLOSE:
275 if (item_.type == ash::TYPE_DIALOG) { 290 if (item_.type == ash::TYPE_DIALOG) {
276 DCHECK(item_delegate_); 291 DCHECK(item_delegate_);
277 item_delegate_->Close(); 292 item_delegate_->Close();
278 } else { 293 } else {
279 // TODO(simonhong): Use ShelfItemDelegate::Close(). 294 // TODO(simonhong): Use ShelfItemDelegate::Close().
280 controller_->Close(item_.id); 295 controller_->Close(item_.id);
281 } 296 }
282 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( 297 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
283 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU); 298 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU);
284 break; 299 break;
285 case MENU_PIN: 300 case MENU_PIN:
286 controller_->TogglePinned(item_.id); 301 controller_->TogglePinned(item_.id);
287 break; 302 break;
303 case MENU_INSTALL:
304 controller_->Install(item_.id);
305 break;
288 case LAUNCH_TYPE_PINNED_TAB: 306 case LAUNCH_TYPE_PINNED_TAB:
289 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_PINNED); 307 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_PINNED);
290 break; 308 break;
291 case LAUNCH_TYPE_REGULAR_TAB: { 309 case LAUNCH_TYPE_REGULAR_TAB: {
292 extensions::LaunchType launch_type = 310 extensions::LaunchType launch_type =
293 extensions::LAUNCH_TYPE_REGULAR; 311 extensions::LAUNCH_TYPE_REGULAR;
294 // Streamlined hosted apps can only toggle between LAUNCH_WINDOW and 312 // Streamlined hosted apps can only toggle between LAUNCH_WINDOW and
295 // LAUNCH_REGULAR. 313 // LAUNCH_REGULAR.
296 if (CommandLine::ForCurrentProcess()->HasSwitch( 314 if (CommandLine::ForCurrentProcess()->HasSwitch(
297 switches::kEnableStreamlinedHostedApps)) { 315 switches::kEnableStreamlinedHostedApps)) {
(...skipping 26 matching lines...) Expand all
324 case MENU_CHANGE_WALLPAPER: 342 case MENU_CHANGE_WALLPAPER:
325 ash::Shell::GetInstance()->user_wallpaper_delegate()-> 343 ash::Shell::GetInstance()->user_wallpaper_delegate()->
326 OpenSetWallpaperPage(); 344 OpenSetWallpaperPage();
327 break; 345 break;
328 #endif 346 #endif
329 default: 347 default:
330 extension_items_->ExecuteCommand(command_id, NULL, 348 extension_items_->ExecuteCommand(command_id, NULL,
331 content::ContextMenuParams()); 349 content::ContextMenuParams());
332 } 350 }
333 } 351 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698