Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_context_menu.cc

Issue 10984034: Revert 158691 - Give platform apps control over launcher right-click context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/context_menu_matcher.h"
11 #include "chrome/browser/extensions/extension_prefs.h" 10 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
13 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
14 #include "content/public/common/context_menu_params.h"
15 #include "grit/ash_strings.h" 13 #include "grit/ash_strings.h"
16 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
18 16
19 namespace {
20
21 bool MenuItemHasLauncherContext(const extensions::MenuItem* item) {
22 return item->contexts().Contains(extensions::MenuItem::LAUNCHER);
23 }
24
25 } // namespace
26
27 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, 17 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller,
28 const ash::LauncherItem* item) 18 const ash::LauncherItem* item)
29 : ui::SimpleMenuModel(NULL), 19 : ui::SimpleMenuModel(NULL),
30 controller_(controller), 20 controller_(controller),
31 item_(item ? *item : ash::LauncherItem()), 21 item_(item ? *item : ash::LauncherItem()) {
32 extension_items_(new extensions::ContextMenuMatcher(
33 controller->profile(), this, this,
34 base::Bind(MenuItemHasLauncherContext))) {
35 set_delegate(this); 22 set_delegate(this);
36 23
37 if (is_valid_item()) { 24 if (is_valid_item()) {
38 if (item_.type == ash::TYPE_APP_SHORTCUT) { 25 if (item_.type == ash::TYPE_APP_SHORTCUT) {
39 DCHECK(controller->IsPinned(item_.id)); 26 DCHECK(controller->IsPinned(item_.id));
40 AddItem( 27 AddItem(
41 MENU_PIN, 28 MENU_PIN,
42 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN)); 29 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN));
43 if (controller->IsOpen(item->id)) { 30 if (controller->IsOpen(item->id)) {
44 AddItem(MENU_CLOSE, 31 AddItem(MENU_CLOSE,
(...skipping 28 matching lines...) Expand all
73 MENU_PIN, 60 MENU_PIN,
74 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN)); 61 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN));
75 } 62 }
76 if (controller->IsOpen(item_.id)) { 63 if (controller->IsOpen(item_.id)) {
77 AddItem(MENU_CLOSE, 64 AddItem(MENU_CLOSE,
78 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); 65 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
79 } 66 }
80 } 67 }
81 AddSeparator(ui::NORMAL_SEPARATOR); 68 AddSeparator(ui::NORMAL_SEPARATOR);
82 } 69 }
83 std::string app_id = controller->GetAppIDForLauncherID(item_.id);
84 if (!app_id.empty()) {
85 int index = 0;
86 extension_items_->AppendExtensionItems(
87 app_id, string16(), &index);
88 if (index > 0)
89 AddSeparator(ui::NORMAL_SEPARATOR);
90 }
91 AddCheckItemWithStringId( 70 AddCheckItemWithStringId(
92 MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId()); 71 MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId());
93 if (CommandLine::ForCurrentProcess()->HasSwitch( 72 if (CommandLine::ForCurrentProcess()->HasSwitch(
94 switches::kShowLauncherAlignmentMenu)) { 73 switches::kShowLauncherAlignmentMenu)) {
95 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, 74 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
96 IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION, 75 IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION,
97 &alignment_menu_); 76 &alignment_menu_);
98 } 77 }
99 } 78 }
100 79
(...skipping 10 matching lines...) Expand all
111 extensions::ExtensionPrefs::LAUNCH_REGULAR; 90 extensions::ExtensionPrefs::LAUNCH_REGULAR;
112 case LAUNCH_TYPE_WINDOW: 91 case LAUNCH_TYPE_WINDOW:
113 return controller_->GetLaunchType(item_.id) == 92 return controller_->GetLaunchType(item_.id) ==
114 extensions::ExtensionPrefs::LAUNCH_WINDOW; 93 extensions::ExtensionPrefs::LAUNCH_WINDOW;
115 case LAUNCH_TYPE_FULLSCREEN: 94 case LAUNCH_TYPE_FULLSCREEN:
116 return controller_->GetLaunchType(item_.id) == 95 return controller_->GetLaunchType(item_.id) ==
117 extensions::ExtensionPrefs::LAUNCH_FULLSCREEN; 96 extensions::ExtensionPrefs::LAUNCH_FULLSCREEN;
118 case MENU_AUTO_HIDE: 97 case MENU_AUTO_HIDE:
119 return ash::LauncherContextMenu::IsAutoHideMenuHideChecked(); 98 return ash::LauncherContextMenu::IsAutoHideMenuHideChecked();
120 default: 99 default:
121 return extension_items_->IsCommandIdChecked(command_id); 100 return false;
122 } 101 }
123 } 102 }
124 103
125 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { 104 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
126 switch (command_id) { 105 switch (command_id) {
127 case MENU_PIN: 106 case MENU_PIN:
128 return item_.type == ash::TYPE_PLATFORM_APP || 107 return item_.type == ash::TYPE_PLATFORM_APP ||
129 controller_->IsPinnable(item_.id); 108 controller_->IsPinnable(item_.id);
130 default: 109 default:
131 return extension_items_->IsCommandIdEnabled(command_id); 110 return true;
132 } 111 }
133 } 112 }
134 113
135 bool LauncherContextMenu::GetAcceleratorForCommandId( 114 bool LauncherContextMenu::GetAcceleratorForCommandId(
136 int command_id, 115 int command_id,
137 ui::Accelerator* accelerator) { 116 ui::Accelerator* accelerator) {
138 return false; 117 return false;
139 } 118 }
140 119
141 void LauncherContextMenu::ExecuteCommand(int command_id) { 120 void LauncherContextMenu::ExecuteCommand(int command_id) {
(...skipping 28 matching lines...) Expand all
170 ash::LauncherContextMenu::GetToggledAutoHideBehavior()); 149 ash::LauncherContextMenu::GetToggledAutoHideBehavior());
171 break; 150 break;
172 case MENU_NEW_WINDOW: 151 case MENU_NEW_WINDOW:
173 controller_->CreateNewWindow(); 152 controller_->CreateNewWindow();
174 break; 153 break;
175 case MENU_NEW_INCOGNITO_WINDOW: 154 case MENU_NEW_INCOGNITO_WINDOW:
176 controller_->CreateNewIncognitoWindow(); 155 controller_->CreateNewIncognitoWindow();
177 break; 156 break;
178 case MENU_ALIGNMENT_MENU: 157 case MENU_ALIGNMENT_MENU:
179 break; 158 break;
180 default:
181 extension_items_->ExecuteCommand(command_id,
182 content::ContextMenuParams());
183 } 159 }
184 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698