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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 return menu_model_.get(); | 176 return menu_model_.get(); |
177 } | 177 } |
178 | 178 |
179 bool AppContextMenu::IsItemForCommandIdDynamic(int command_id) const { | 179 bool AppContextMenu::IsItemForCommandIdDynamic(int command_id) const { |
180 return command_id == TOGGLE_PIN || command_id == LAUNCH_NEW; | 180 return command_id == TOGGLE_PIN || command_id == LAUNCH_NEW; |
181 } | 181 } |
182 | 182 |
183 base::string16 AppContextMenu::GetLabelForCommandId(int command_id) const { | 183 base::string16 AppContextMenu::GetLabelForCommandId(int command_id) const { |
| 184 // If streamlined hosted apps are enabled, then we do not need to consider |
| 185 // the case when command_id == TOGGLE_PIN (see AppContextMenu::GetMenuModel). |
| 186 if (extensions::util::IsStreamlinedHostedAppsEnabled()) { |
| 187 DCHECK_EQ(LAUNCH_NEW, command_id); |
| 188 return IsCommandIdChecked(USE_LAUNCH_TYPE_REGULAR) ? |
| 189 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_TAB) : |
| 190 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW); |
| 191 } |
| 192 |
184 if (command_id == TOGGLE_PIN) { | 193 if (command_id == TOGGLE_PIN) { |
185 return controller_->IsAppPinned(app_id_) ? | 194 return controller_->IsAppPinned(app_id_) ? |
186 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : | 195 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : |
187 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_PIN); | 196 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_PIN); |
188 } else if (command_id == LAUNCH_NEW) { | 197 } else if (command_id == LAUNCH_NEW) { |
189 #if defined(OS_MACOSX) | 198 #if defined(OS_MACOSX) |
190 // Even fullscreen windows launch in a browser tab on Mac. | 199 // Even fullscreen windows launch in a browser tab on Mac. |
191 const bool launches_in_tab = true; | 200 const bool launches_in_tab = true; |
192 #else | 201 #else |
193 const bool launches_in_tab = IsCommandIdChecked(USE_LAUNCH_TYPE_PINNED) || | 202 const bool launches_in_tab = IsCommandIdChecked(USE_LAUNCH_TYPE_PINNED) || |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 extension_menu_items_->ExecuteCommand(command_id, NULL, | 287 extension_menu_items_->ExecuteCommand(command_id, NULL, |
279 content::ContextMenuParams()); | 288 content::ContextMenuParams()); |
280 } else if (command_id == MENU_NEW_WINDOW) { | 289 } else if (command_id == MENU_NEW_WINDOW) { |
281 controller_->CreateNewWindow(profile_, false); | 290 controller_->CreateNewWindow(profile_, false); |
282 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { | 291 } else if (command_id == MENU_NEW_INCOGNITO_WINDOW) { |
283 controller_->CreateNewWindow(profile_, true); | 292 controller_->CreateNewWindow(profile_, true); |
284 } | 293 } |
285 } | 294 } |
286 | 295 |
287 } // namespace app_list | 296 } // namespace app_list |
OLD | NEW |