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 "ash/launcher/launcher_context_menu.h" | 7 #include "ash/launcher/launcher_context_menu.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 | 16 |
17 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, | 17 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, |
18 const ash::LauncherItem* item) | 18 const ash::LauncherItem* item) |
19 : ui::SimpleMenuModel(NULL), | 19 : ui::SimpleMenuModel(NULL), |
20 controller_(controller), | 20 controller_(controller), |
21 item_(item ? *item : ash::LauncherItem()) { | 21 item_(item ? *item : ash::LauncherItem()) { |
22 set_delegate(this); | 22 set_delegate(this); |
23 | 23 |
24 if (is_valid_item()) { | 24 if (is_valid_item()) { |
25 if (item_.type == ash::TYPE_APP_SHORTCUT) { | 25 if (item_.type == ash::TYPE_APP_SHORTCUT) { |
26 DCHECK(controller->IsPinned(item_.id)); | 26 DCHECK(controller->IsPinned(item_.id)); |
27 AddItem( | 27 AddItem( |
28 MENU_PIN, | 28 MENU_PIN, |
29 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN)); | 29 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN)); |
30 AddSeparator(); | 30 // No open actions for pending app shortcut. |
31 AddCheckItemWithStringId( | 31 if (item->status != ash::STATUS_IS_PENDING) { |
32 LAUNCH_TYPE_REGULAR_TAB, | 32 AddSeparator(); |
33 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); | 33 AddCheckItemWithStringId( |
34 AddCheckItemWithStringId( | 34 LAUNCH_TYPE_REGULAR_TAB, |
35 LAUNCH_TYPE_PINNED_TAB, | 35 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); |
36 IDS_APP_CONTEXT_MENU_OPEN_PINNED); | 36 AddCheckItemWithStringId( |
37 AddCheckItemWithStringId( | 37 LAUNCH_TYPE_PINNED_TAB, |
38 LAUNCH_TYPE_WINDOW, | 38 IDS_APP_CONTEXT_MENU_OPEN_PINNED); |
39 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); | 39 AddCheckItemWithStringId( |
40 // Even though the launch type is Full Screen it is more accurately | 40 LAUNCH_TYPE_WINDOW, |
41 // described as Maximized in Ash. | 41 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); |
42 AddCheckItemWithStringId( | 42 // Even though the launch type is Full Screen it is more accurately |
43 LAUNCH_TYPE_FULLSCREEN, | 43 // described as Maximized in Ash. |
44 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); | 44 AddCheckItemWithStringId( |
| 45 LAUNCH_TYPE_FULLSCREEN, |
| 46 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); |
| 47 } |
45 } else if (item_.type == ash::TYPE_BROWSER_SHORTCUT) { | 48 } else if (item_.type == ash::TYPE_BROWSER_SHORTCUT) { |
46 AddItem(MENU_NEW_WINDOW, | 49 AddItem(MENU_NEW_WINDOW, |
47 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_WINDOW)); | 50 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_WINDOW)); |
48 if (!controller_->IsLoggedInAsGuest()) { | 51 if (!controller_->IsLoggedInAsGuest()) { |
49 AddItem(MENU_NEW_INCOGNITO_WINDOW, | 52 AddItem(MENU_NEW_INCOGNITO_WINDOW, |
50 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_INCOGNITO_WINDOW)); | 53 l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_INCOGNITO_WINDOW)); |
51 } | 54 } |
52 } else { | 55 } else { |
53 AddItem(MENU_OPEN, controller->GetTitle(item_)); | 56 AddItem(MENU_OPEN, controller->GetTitle(item_)); |
54 if (item_.type == ash::TYPE_PLATFORM_APP) { | 57 if (item_.type == ash::TYPE_PLATFORM_APP) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 case MENU_NEW_WINDOW: | 150 case MENU_NEW_WINDOW: |
148 controller_->CreateNewWindow(); | 151 controller_->CreateNewWindow(); |
149 break; | 152 break; |
150 case MENU_NEW_INCOGNITO_WINDOW: | 153 case MENU_NEW_INCOGNITO_WINDOW: |
151 controller_->CreateNewIncognitoWindow(); | 154 controller_->CreateNewIncognitoWindow(); |
152 break; | 155 break; |
153 case MENU_ALIGNMENT_MENU: | 156 case MENU_ALIGNMENT_MENU: |
154 break; | 157 break; |
155 } | 158 } |
156 } | 159 } |
OLD | NEW |