OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_list/app_context_menu.h" | 5 #include "chrome/browser/ui/app_list/app_context_menu.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | |
9 #include "chrome/browser/extensions/context_menu_matcher.h" | 8 #include "chrome/browser/extensions/context_menu_matcher.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" |
10 #include "chrome/browser/extensions/menu_manager.h" | 10 #include "chrome/browser/extensions/menu_manager.h" |
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" | 13 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" |
14 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 14 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
15 #include "chrome/common/chrome_switches.h" | |
16 #include "chrome/common/extensions/manifest_url_handler.h" | 15 #include "chrome/common/extensions/manifest_url_handler.h" |
17 #include "chrome/grit/chromium_strings.h" | 16 #include "chrome/grit/chromium_strings.h" |
18 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
19 #include "content/public/common/context_menu_params.h" | 18 #include "content/public/common/context_menu_params.h" |
20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
21 | 20 |
22 #if defined(USE_ASH) | 21 #if defined(USE_ASH) |
23 #include "ash/shell.h" | 22 #include "ash/shell.h" |
24 #endif | 23 #endif |
25 | 24 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 110 |
112 if (controller_->CanDoCreateShortcutsFlow()) { | 111 if (controller_->CanDoCreateShortcutsFlow()) { |
113 menu_model_->AddItemWithStringId(CREATE_SHORTCUTS, | 112 menu_model_->AddItemWithStringId(CREATE_SHORTCUTS, |
114 IDS_NEW_TAB_APP_CREATE_SHORTCUT); | 113 IDS_NEW_TAB_APP_CREATE_SHORTCUT); |
115 } | 114 } |
116 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 115 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); |
117 | 116 |
118 if (!is_platform_app_) { | 117 if (!is_platform_app_) { |
119 // Streamlined hosted apps can only toggle between USE_LAUNCH_TYPE_WINDOW | 118 // Streamlined hosted apps can only toggle between USE_LAUNCH_TYPE_WINDOW |
120 // and USE_LAUNCH_TYPE_REGULAR. | 119 // and USE_LAUNCH_TYPE_REGULAR. |
121 if (CommandLine::ForCurrentProcess()->HasSwitch( | 120 if (extensions::util::IsStreamlinedHostedAppsEnabled()) { |
122 switches::kEnableStreamlinedHostedApps)) { | |
123 menu_model_->AddCheckItemWithStringId( | 121 menu_model_->AddCheckItemWithStringId( |
124 USE_LAUNCH_TYPE_REGULAR, | 122 USE_LAUNCH_TYPE_REGULAR, |
125 IDS_APP_CONTEXT_MENU_OPEN_TAB); | 123 IDS_APP_CONTEXT_MENU_OPEN_TAB); |
126 } else { | 124 } else { |
127 menu_model_->AddCheckItemWithStringId( | 125 menu_model_->AddCheckItemWithStringId( |
128 USE_LAUNCH_TYPE_REGULAR, | 126 USE_LAUNCH_TYPE_REGULAR, |
129 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); | 127 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); |
130 menu_model_->AddCheckItemWithStringId( | 128 menu_model_->AddCheckItemWithStringId( |
131 USE_LAUNCH_TYPE_PINNED, | 129 USE_LAUNCH_TYPE_PINNED, |
132 IDS_APP_CONTEXT_MENU_OPEN_PINNED); | 130 IDS_APP_CONTEXT_MENU_OPEN_PINNED); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } else if (command_id == CREATE_SHORTCUTS) { | 255 } else if (command_id == CREATE_SHORTCUTS) { |
258 controller_->DoCreateShortcutsFlow(profile_, app_id_); | 256 controller_->DoCreateShortcutsFlow(profile_, app_id_); |
259 } else if (command_id == SHOW_APP_INFO) { | 257 } else if (command_id == SHOW_APP_INFO) { |
260 controller_->DoShowAppInfoFlow(profile_, app_id_); | 258 controller_->DoShowAppInfoFlow(profile_, app_id_); |
261 } else if (command_id >= USE_LAUNCH_TYPE_COMMAND_START && | 259 } else if (command_id >= USE_LAUNCH_TYPE_COMMAND_START && |
262 command_id < USE_LAUNCH_TYPE_COMMAND_END) { | 260 command_id < USE_LAUNCH_TYPE_COMMAND_END) { |
263 extensions::LaunchType launch_type = static_cast<extensions::LaunchType>( | 261 extensions::LaunchType launch_type = static_cast<extensions::LaunchType>( |
264 command_id - USE_LAUNCH_TYPE_COMMAND_START); | 262 command_id - USE_LAUNCH_TYPE_COMMAND_START); |
265 // Streamlined hosted apps can only toggle between LAUNCH_TYPE_WINDOW and | 263 // Streamlined hosted apps can only toggle between LAUNCH_TYPE_WINDOW and |
266 // LAUNCH_TYPE_REGULAR. | 264 // LAUNCH_TYPE_REGULAR. |
267 if (CommandLine::ForCurrentProcess()->HasSwitch( | 265 if (extensions::util::IsStreamlinedHostedAppsEnabled()) { |
268 switches::kEnableStreamlinedHostedApps)) { | |
269 launch_type = (controller_->GetExtensionLaunchType(profile_, app_id_) == | 266 launch_type = (controller_->GetExtensionLaunchType(profile_, app_id_) == |
270 extensions::LAUNCH_TYPE_REGULAR) ? | 267 extensions::LAUNCH_TYPE_REGULAR) ? |
271 extensions::LAUNCH_TYPE_WINDOW : | 268 extensions::LAUNCH_TYPE_WINDOW : |
272 extensions::LAUNCH_TYPE_REGULAR; | 269 extensions::LAUNCH_TYPE_REGULAR; |
273 } | 270 } |
274 controller_->SetExtensionLaunchType(profile_, app_id_, launch_type); | 271 controller_->SetExtensionLaunchType(profile_, app_id_, launch_type); |
275 } else if (command_id == OPTIONS) { | 272 } else if (command_id == OPTIONS) { |
276 controller_->ShowOptionsPage(profile_, app_id_); | 273 controller_->ShowOptionsPage(profile_, app_id_); |
277 } else if (command_id == UNINSTALL) { | 274 } else if (command_id == UNINSTALL) { |
278 controller_->UninstallApp(profile_, app_id_); | 275 controller_->UninstallApp(profile_, app_id_); |
279 } else if (extensions::ContextMenuMatcher::IsExtensionsCustomCommandId( | 276 } else if (extensions::ContextMenuMatcher::IsExtensionsCustomCommandId( |
280 command_id)) { | 277 command_id)) { |
281 extension_menu_items_->ExecuteCommand(command_id, NULL, | 278 extension_menu_items_->ExecuteCommand(command_id, NULL, |
282 content::ContextMenuParams()); | 279 content::ContextMenuParams()); |
283 } else if (command_id == MENU_NEW_WINDOW) { | 280 } else if (command_id == MENU_NEW_WINDOW) { |
284 controller_->CreateNewWindow(profile_, false); | 281 controller_->CreateNewWindow(profile_, false); |
285 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { | 282 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { |
286 controller_->CreateNewWindow(profile_, true); | 283 controller_->CreateNewWindow(profile_, true); |
287 } | 284 } |
288 } | 285 } |
289 | 286 |
290 } // namespace app_list | 287 } // namespace app_list |
OLD | NEW |