| OLD | NEW |
| 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" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shelf/shelf_item_delegate.h" | 12 #include "ash/shelf/shelf_item_delegate.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/command_line.h" | |
| 17 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 18 #include "chrome/browser/extensions/context_menu_matcher.h" | 17 #include "chrome/browser/extensions/context_menu_matcher.h" |
| 18 #include "chrome/browser/extensions/extension_util.h" |
| 19 #include "chrome/browser/fullscreen.h" | 19 #include "chrome/browser/fullscreen.h" |
| 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 22 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 24 #include "chrome/common/chrome_switches.h" | |
| 25 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
| 26 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 27 #include "content/public/common/context_menu_params.h" | 26 #include "content/public/common/context_menu_params.h" |
| 28 #include "grit/ash_strings.h" | 27 #include "grit/ash_strings.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 bool MenuItemHasLauncherContext(const extensions::MenuItem* item) { | 32 bool MenuItemHasLauncherContext(const extensions::MenuItem* item) { |
| 34 return item->contexts().Contains(extensions::MenuItem::LAUNCHER); | 33 return item->contexts().Contains(extensions::MenuItem::LAUNCHER); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 l10n_util::GetStringUTF16(controller_->IsPinned(item_.id) ? | 98 l10n_util::GetStringUTF16(controller_->IsPinned(item_.id) ? |
| 100 IDS_LAUNCHER_CONTEXT_MENU_UNPIN : | 99 IDS_LAUNCHER_CONTEXT_MENU_UNPIN : |
| 101 IDS_LAUNCHER_CONTEXT_MENU_PIN)); | 100 IDS_LAUNCHER_CONTEXT_MENU_PIN)); |
| 102 if (controller_->IsOpen(item_.id)) { | 101 if (controller_->IsOpen(item_.id)) { |
| 103 AddItem(MENU_CLOSE, | 102 AddItem(MENU_CLOSE, |
| 104 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | 103 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); |
| 105 } | 104 } |
| 106 if (!controller_->IsPlatformApp(item_.id) && | 105 if (!controller_->IsPlatformApp(item_.id) && |
| 107 item_.type != ash::TYPE_WINDOWED_APP) { | 106 item_.type != ash::TYPE_WINDOWED_APP) { |
| 108 AddSeparator(ui::NORMAL_SEPARATOR); | 107 AddSeparator(ui::NORMAL_SEPARATOR); |
| 109 if (CommandLine::ForCurrentProcess()->HasSwitch( | 108 if (extensions::util::IsStreamlinedHostedAppsEnabled()) { |
| 110 switches::kEnableStreamlinedHostedApps)) { | |
| 111 // Streamlined hosted apps launch in a window by default. This menu | 109 // Streamlined hosted apps launch in a window by default. This menu |
| 112 // item is re-interpreted as a single, toggle-able option to launch | 110 // item is re-interpreted as a single, toggle-able option to launch |
| 113 // the hosted app as a tab. | 111 // the hosted app as a tab. |
| 114 AddCheckItemWithStringId( | 112 AddCheckItemWithStringId( |
| 115 LAUNCH_TYPE_REGULAR_TAB, | 113 LAUNCH_TYPE_REGULAR_TAB, |
| 116 IDS_APP_CONTEXT_MENU_OPEN_TAB); | 114 IDS_APP_CONTEXT_MENU_OPEN_TAB); |
| 117 } else { | 115 } else { |
| 118 AddCheckItemWithStringId( | 116 AddCheckItemWithStringId( |
| 119 LAUNCH_TYPE_REGULAR_TAB, | 117 LAUNCH_TYPE_REGULAR_TAB, |
| 120 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); | 118 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 controller_->Install(item_.id); | 304 controller_->Install(item_.id); |
| 307 break; | 305 break; |
| 308 case LAUNCH_TYPE_PINNED_TAB: | 306 case LAUNCH_TYPE_PINNED_TAB: |
| 309 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_PINNED); | 307 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_PINNED); |
| 310 break; | 308 break; |
| 311 case LAUNCH_TYPE_REGULAR_TAB: { | 309 case LAUNCH_TYPE_REGULAR_TAB: { |
| 312 extensions::LaunchType launch_type = | 310 extensions::LaunchType launch_type = |
| 313 extensions::LAUNCH_TYPE_REGULAR; | 311 extensions::LAUNCH_TYPE_REGULAR; |
| 314 // Streamlined hosted apps can only toggle between LAUNCH_WINDOW and | 312 // Streamlined hosted apps can only toggle between LAUNCH_WINDOW and |
| 315 // LAUNCH_REGULAR. | 313 // LAUNCH_REGULAR. |
| 316 if (CommandLine::ForCurrentProcess()->HasSwitch( | 314 if (extensions::util::IsStreamlinedHostedAppsEnabled()) { |
| 317 switches::kEnableStreamlinedHostedApps)) { | |
| 318 launch_type = controller_->GetLaunchType(item_.id) == | 315 launch_type = controller_->GetLaunchType(item_.id) == |
| 319 extensions::LAUNCH_TYPE_REGULAR | 316 extensions::LAUNCH_TYPE_REGULAR |
| 320 ? extensions::LAUNCH_TYPE_WINDOW | 317 ? extensions::LAUNCH_TYPE_WINDOW |
| 321 : extensions::LAUNCH_TYPE_REGULAR; | 318 : extensions::LAUNCH_TYPE_REGULAR; |
| 322 } | 319 } |
| 323 controller_->SetLaunchType(item_.id, launch_type); | 320 controller_->SetLaunchType(item_.id, launch_type); |
| 324 break; | 321 break; |
| 325 } | 322 } |
| 326 case LAUNCH_TYPE_WINDOW: | 323 case LAUNCH_TYPE_WINDOW: |
| 327 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_WINDOW); | 324 controller_->SetLaunchType(item_.id, extensions::LAUNCH_TYPE_WINDOW); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 344 case MENU_CHANGE_WALLPAPER: | 341 case MENU_CHANGE_WALLPAPER: |
| 345 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 342 ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
| 346 OpenSetWallpaperPage(); | 343 OpenSetWallpaperPage(); |
| 347 break; | 344 break; |
| 348 #endif | 345 #endif |
| 349 default: | 346 default: |
| 350 extension_items_->ExecuteCommand(command_id, NULL, | 347 extension_items_->ExecuteCommand(command_id, NULL, |
| 351 content::ContextMenuParams()); | 348 content::ContextMenuParams()); |
| 352 } | 349 } |
| 353 } | 350 } |
| OLD | NEW |