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

Side by Side Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 1138523006: Enable keyboard accelerators while a menu is open (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 3 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
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/views/chrome_views_delegate.h" 5 #include "chrome/browser/ui/views/chrome_views_delegate.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/browser_window_state.h" 15 #include "chrome/browser/ui/browser_window_state.h"
16 #include "components/version_info/version_info.h" 16 #include "components/version_info/version_info.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/context_factory.h" 18 #include "content/public/browser/context_factory.h"
19 #include "grit/chrome_unscaled_resources.h" 19 #include "grit/chrome_unscaled_resources.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/ui_base_switches.h" 21 #include "ui/base/ui_base_switches.h"
22 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
24 #include "ui/views/controls/menu/menu_controller.h"
24 #include "ui/views/widget/native_widget.h" 25 #include "ui/views/widget/native_widget.h"
25 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
26 27
27 #if defined(OS_WIN) 28 #if defined(OS_WIN)
28 #include <dwmapi.h> 29 #include <dwmapi.h>
29 #include <shellapi.h> 30 #include <shellapi.h>
30 #include "base/profiler/scoped_tracker.h" 31 #include "base/profiler/scoped_tracker.h"
31 #include "base/task_runner_util.h" 32 #include "base/task_runner_util.h"
32 #include "base/win/windows_version.h" 33 #include "base/win/windows_version.h"
33 #include "chrome/browser/app_icon_win.h" 34 #include "chrome/browser/app_icon_win.h"
(...skipping 11 matching lines...) Expand all
45 #include "chrome/browser/ui/host_desktop.h" 46 #include "chrome/browser/ui/host_desktop.h"
46 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 47 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
47 #include "ui/views/widget/native_widget_aura.h" 48 #include "ui/views/widget/native_widget_aura.h"
48 #endif 49 #endif
49 50
50 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 51 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
51 #include "ui/views/linux_ui/linux_ui.h" 52 #include "ui/views/linux_ui/linux_ui.h"
52 #endif 53 #endif
53 54
54 #if defined(USE_ASH) 55 #if defined(USE_ASH)
56 #include "ash/accelerators/accelerator_controller.h"
55 #include "ash/shell.h" 57 #include "ash/shell.h"
56 #include "ash/wm/window_state.h" 58 #include "ash/wm/window_state.h"
57 #include "chrome/browser/ui/ash/ash_init.h" 59 #include "chrome/browser/ui/ash/ash_init.h"
58 #include "chrome/browser/ui/ash/ash_util.h" 60 #include "chrome/browser/ui/ash/ash_util.h"
59 #endif 61 #endif
60 62
61 63
62 // Helpers -------------------------------------------------------------------- 64 // Helpers --------------------------------------------------------------------
63 65
64 namespace { 66 namespace {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_TOP, monitor)) 121 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_TOP, monitor))
120 edges |= views::ViewsDelegate::EDGE_TOP; 122 edges |= views::ViewsDelegate::EDGE_TOP;
121 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_RIGHT, monitor)) 123 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_RIGHT, monitor))
122 edges |= views::ViewsDelegate::EDGE_RIGHT; 124 edges |= views::ViewsDelegate::EDGE_RIGHT;
123 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) 125 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_BOTTOM, monitor))
124 edges |= views::ViewsDelegate::EDGE_BOTTOM; 126 edges |= views::ViewsDelegate::EDGE_BOTTOM;
125 return edges; 127 return edges;
126 } 128 }
127 #endif 129 #endif
128 130
131 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) {
132 #if defined(USE_ASH)
oshima 2015/09/08 21:43:08 entire ProcessAcceleratorNow function can be ifdef
afakhry 2015/09/08 23:34:37 Done.
133 // TODO(afakhry): See if we need here to send the accelerator to the
134 // FocusManager of the active window in a follow-up CL.
135 ash::Shell::GetInstance()->accelerator_controller()->Process(accelerator);
136 #endif // defined(USE_ASH)
137 }
138
129 } // namespace 139 } // namespace
130 140
131 141
132 // ChromeViewsDelegate -------------------------------------------------------- 142 // ChromeViewsDelegate --------------------------------------------------------
133 143
134 #if defined(OS_WIN) 144 #if defined(OS_WIN)
135 ChromeViewsDelegate::ChromeViewsDelegate() 145 ChromeViewsDelegate::ChromeViewsDelegate()
136 : in_autohide_edges_callback_(false), 146 : in_autohide_edges_callback_(false),
137 weak_factory_(this) { 147 weak_factory_(this) {
138 #else 148 #else
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 223 }
214 224
215 void ChromeViewsDelegate::NotifyAccessibilityEvent( 225 void ChromeViewsDelegate::NotifyAccessibilityEvent(
216 views::View* view, ui::AXEvent event_type) { 226 views::View* view, ui::AXEvent event_type) {
217 #if defined(USE_AURA) 227 #if defined(USE_AURA)
218 AutomationManagerAura::GetInstance()->HandleEvent( 228 AutomationManagerAura::GetInstance()->HandleEvent(
219 GetProfileForWindow(view->GetWidget()), view, event_type); 229 GetProfileForWindow(view->GetWidget()), view, event_type);
220 #endif 230 #endif
221 } 231 }
222 232
233 void ChromeViewsDelegate::HandleKeyEventOnMenu(ui::KeyEvent* event) {
234 #if defined(USE_ASH)
235 views::MenuController* menu_controller =
236 views::MenuController::GetActiveInstance();
237
238 if (!menu_controller)
239 return;
240
241 ui::Accelerator accelerator(*event);
242 ash::AcceleratorController* accelerator_controller =
243 ash::Shell::GetInstance()->accelerator_controller();
244
245 accelerator_controller->accelerator_history()->StoreCurrentAccelerator(
246 accelerator);
247 if (accelerator_controller->ShouldCloseMenuAndRepostAccelerator(
248 accelerator)) {
249 menu_controller->CancelAll();
250 base::MessageLoopForUI::current()->PostTask(
251 FROM_HERE,
252 base::Bind(ProcessAcceleratorNow, accelerator));
253 } else {
254 ProcessAcceleratorNow(accelerator);
255 }
256 #endif // defined(USE_ASH)
257 }
258
223 #if defined(OS_WIN) 259 #if defined(OS_WIN)
224 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { 260 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const {
225 return GetAppIcon(); 261 return GetAppIcon();
226 } 262 }
227 263
228 HICON ChromeViewsDelegate::GetSmallWindowIcon() const { 264 HICON ChromeViewsDelegate::GetSmallWindowIcon() const {
229 return GetSmallAppIcon(); 265 return GetSmallAppIcon();
230 } 266 }
231 267
232 bool ChromeViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { 268 bool ChromeViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 return content::BrowserThread::GetBlockingPool(); 470 return content::BrowserThread::GetBlockingPool();
435 } 471 }
436 472
437 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) 473 #if !defined(USE_AURA) && !defined(USE_CHROMEOS)
438 views::Widget::InitParams::WindowOpacity 474 views::Widget::InitParams::WindowOpacity
439 ChromeViewsDelegate::GetOpacityForInitParams( 475 ChromeViewsDelegate::GetOpacityForInitParams(
440 const views::Widget::InitParams& params) { 476 const views::Widget::InitParams& params) {
441 return views::Widget::InitParams::OPAQUE_WINDOW; 477 return views::Widget::InitParams::OPAQUE_WINDOW;
442 } 478 }
443 #endif 479 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698