| 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 "chrome/browser/extensions/context_menu_matcher.h" | 8 #include "chrome/browser/extensions/context_menu_matcher.h" |
| 9 #include "chrome/browser/extensions/extension_util.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" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (controller_->CanDoCreateShortcutsFlow()) { | 111 if (controller_->CanDoCreateShortcutsFlow()) { |
| 112 menu_model_->AddItemWithStringId(CREATE_SHORTCUTS, | 112 menu_model_->AddItemWithStringId(CREATE_SHORTCUTS, |
| 113 IDS_NEW_TAB_APP_CREATE_SHORTCUT); | 113 IDS_NEW_TAB_APP_CREATE_SHORTCUT); |
| 114 } | 114 } |
| 115 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 115 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 116 | 116 |
| 117 if (!is_platform_app_) { | 117 if (!is_platform_app_) { |
| 118 // When bookmark apps are enabled, hosted apps can only toggle between | 118 // When bookmark apps are enabled, hosted apps can only toggle between |
| 119 // USE_LAUNCH_TYPE_WINDOW and USE_LAUNCH_TYPE_REGULAR. | 119 // USE_LAUNCH_TYPE_WINDOW and USE_LAUNCH_TYPE_REGULAR. |
| 120 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 120 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
| 121 menu_model_->AddCheckItemWithStringId( | 121 menu_model_->AddCheckItemWithStringId(USE_LAUNCH_TYPE_WINDOW, |
| 122 USE_LAUNCH_TYPE_REGULAR, | 122 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); |
| 123 IDS_APP_CONTEXT_MENU_OPEN_TAB); | |
| 124 } else { | 123 } else { |
| 125 menu_model_->AddCheckItemWithStringId( | 124 menu_model_->AddCheckItemWithStringId( |
| 126 USE_LAUNCH_TYPE_REGULAR, | 125 USE_LAUNCH_TYPE_REGULAR, |
| 127 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); | 126 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); |
| 128 menu_model_->AddCheckItemWithStringId( | 127 menu_model_->AddCheckItemWithStringId( |
| 129 USE_LAUNCH_TYPE_PINNED, | 128 USE_LAUNCH_TYPE_PINNED, |
| 130 IDS_APP_CONTEXT_MENU_OPEN_PINNED); | 129 IDS_APP_CONTEXT_MENU_OPEN_PINNED); |
| 131 #if defined(OS_MACOSX) | 130 #if defined(OS_MACOSX) |
| 132 // Mac does not support standalone web app browser windows or maximize. | 131 // Mac does not support standalone web app browser windows or maximize. |
| 133 menu_model_->AddCheckItemWithStringId( | 132 menu_model_->AddCheckItemWithStringId( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : | 187 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : |
| 189 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_PIN); | 188 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_PIN); |
| 190 } | 189 } |
| 191 | 190 |
| 192 DCHECK_EQ(LAUNCH_NEW, command_id); | 191 DCHECK_EQ(LAUNCH_NEW, command_id); |
| 193 | 192 |
| 194 // If --enable-new-bookmark-apps is enabled, then only check if | 193 // If --enable-new-bookmark-apps is enabled, then only check if |
| 195 // USE_LAUNCH_TYPE_REGULAR is checked, as USE_LAUNCH_TYPE_PINNED (i.e. open | 194 // USE_LAUNCH_TYPE_REGULAR is checked, as USE_LAUNCH_TYPE_PINNED (i.e. open |
| 196 // as pinned tab) and fullscreen-by-default windows do not exist. | 195 // as pinned tab) and fullscreen-by-default windows do not exist. |
| 197 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 196 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
| 198 return IsCommandIdChecked(USE_LAUNCH_TYPE_REGULAR) ? | 197 return IsCommandIdChecked(USE_LAUNCH_TYPE_WINDOW) |
| 199 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_TAB) : | 198 ? l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW) |
| 200 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW); | 199 : l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_TAB); |
| 201 } | 200 } |
| 202 | 201 |
| 203 #if defined(OS_MACOSX) | 202 #if defined(OS_MACOSX) |
| 204 // Even fullscreen windows launch in a browser tab on Mac. | 203 // Even fullscreen windows launch in a browser tab on Mac. |
| 205 const bool launches_in_tab = true; | 204 const bool launches_in_tab = true; |
| 206 #else | 205 #else |
| 207 const bool launches_in_tab = IsCommandIdChecked(USE_LAUNCH_TYPE_PINNED) || | 206 const bool launches_in_tab = IsCommandIdChecked(USE_LAUNCH_TYPE_PINNED) || |
| 208 IsCommandIdChecked(USE_LAUNCH_TYPE_REGULAR); | 207 IsCommandIdChecked(USE_LAUNCH_TYPE_REGULAR); |
| 209 #endif | 208 #endif |
| 210 return launches_in_tab ? | 209 return launches_in_tab ? |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } else if (command_id == SHOW_APP_INFO) { | 266 } else if (command_id == SHOW_APP_INFO) { |
| 268 controller_->DoShowAppInfoFlow(profile_, app_id_); | 267 controller_->DoShowAppInfoFlow(profile_, app_id_); |
| 269 } else if (command_id >= USE_LAUNCH_TYPE_COMMAND_START && | 268 } else if (command_id >= USE_LAUNCH_TYPE_COMMAND_START && |
| 270 command_id < USE_LAUNCH_TYPE_COMMAND_END) { | 269 command_id < USE_LAUNCH_TYPE_COMMAND_END) { |
| 271 extensions::LaunchType launch_type = static_cast<extensions::LaunchType>( | 270 extensions::LaunchType launch_type = static_cast<extensions::LaunchType>( |
| 272 command_id - USE_LAUNCH_TYPE_COMMAND_START); | 271 command_id - USE_LAUNCH_TYPE_COMMAND_START); |
| 273 // When bookmark apps are enabled, hosted apps can only toggle between | 272 // When bookmark apps are enabled, hosted apps can only toggle between |
| 274 // LAUNCH_TYPE_WINDOW and LAUNCH_TYPE_REGULAR. | 273 // LAUNCH_TYPE_WINDOW and LAUNCH_TYPE_REGULAR. |
| 275 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 274 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
| 276 launch_type = (controller_->GetExtensionLaunchType(profile_, app_id_) == | 275 launch_type = (controller_->GetExtensionLaunchType(profile_, app_id_) == |
| 277 extensions::LAUNCH_TYPE_REGULAR) ? | 276 extensions::LAUNCH_TYPE_WINDOW) |
| 278 extensions::LAUNCH_TYPE_WINDOW : | 277 ? extensions::LAUNCH_TYPE_REGULAR |
| 279 extensions::LAUNCH_TYPE_REGULAR; | 278 : extensions::LAUNCH_TYPE_WINDOW; |
| 280 } | 279 } |
| 281 controller_->SetExtensionLaunchType(profile_, app_id_, launch_type); | 280 controller_->SetExtensionLaunchType(profile_, app_id_, launch_type); |
| 282 } else if (command_id == OPTIONS) { | 281 } else if (command_id == OPTIONS) { |
| 283 controller_->ShowOptionsPage(profile_, app_id_); | 282 controller_->ShowOptionsPage(profile_, app_id_); |
| 284 } else if (command_id == UNINSTALL) { | 283 } else if (command_id == UNINSTALL) { |
| 285 controller_->UninstallApp(profile_, app_id_); | 284 controller_->UninstallApp(profile_, app_id_); |
| 286 } else if (extensions::ContextMenuMatcher::IsExtensionsCustomCommandId( | 285 } else if (extensions::ContextMenuMatcher::IsExtensionsCustomCommandId( |
| 287 command_id)) { | 286 command_id)) { |
| 288 extension_menu_items_->ExecuteCommand(command_id, NULL, | 287 extension_menu_items_->ExecuteCommand(command_id, NULL, |
| 289 content::ContextMenuParams()); | 288 content::ContextMenuParams()); |
| 290 } else if (command_id == MENU_NEW_WINDOW) { | 289 } else if (command_id == MENU_NEW_WINDOW) { |
| 291 controller_->CreateNewWindow(profile_, false); | 290 controller_->CreateNewWindow(profile_, false); |
| 292 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { | 291 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { |
| 293 controller_->CreateNewWindow(profile_, true); | 292 controller_->CreateNewWindow(profile_, true); |
| 294 } | 293 } |
| 295 } | 294 } |
| 296 | 295 |
| 297 } // namespace app_list | 296 } // namespace app_list |
| OLD | NEW |