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/views/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
6 | 6 |
7 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
9 #include "ash/common/wm_shell.h" | |
10 #include "ash/shell.h" | 9 #include "ash/shell.h" |
11 #include "ash/wm/window_state_aura.h" | 10 #include "ash/wm/window_state_aura.h" |
12 #include "base/bind.h" | 11 #include "base/bind.h" |
13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
15 #include "chrome/browser/ui/ash/ash_util.h" | 14 #include "chrome/browser/ui/ash/ash_util.h" |
16 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
17 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) { | 20 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) { |
22 // TODO(afakhry): See if we need here to send the accelerator to the | 21 // TODO(afakhry): See if we need here to send the accelerator to the |
23 // FocusManager of the active window in a follow-up CL. | 22 // FocusManager of the active window in a follow-up CL. |
24 ash::WmShell::Get()->accelerator_controller()->Process(accelerator); | 23 ash::Shell::Get()->accelerator_controller()->Process(accelerator); |
25 } | 24 } |
26 | 25 |
27 } // namespace | 26 } // namespace |
28 | 27 |
29 views::ViewsDelegate::ProcessMenuAcceleratorResult | 28 views::ViewsDelegate::ProcessMenuAcceleratorResult |
30 ChromeViewsDelegate::ProcessAcceleratorWhileMenuShowing( | 29 ChromeViewsDelegate::ProcessAcceleratorWhileMenuShowing( |
31 const ui::Accelerator& accelerator) { | 30 const ui::Accelerator& accelerator) { |
32 DCHECK(base::MessageLoopForUI::IsCurrent()); | 31 DCHECK(base::MessageLoopForUI::IsCurrent()); |
33 | 32 |
34 // Early return because mash chrome does not have access to ash::Shell | 33 // Early return because mash chrome does not have access to ash::Shell |
35 if (ash_util::IsRunningInMash()) | 34 if (ash_util::IsRunningInMash()) |
36 return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN; | 35 return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN; |
37 | 36 |
38 ash::AcceleratorController* accelerator_controller = | 37 ash::AcceleratorController* accelerator_controller = |
39 ash::WmShell::Get()->accelerator_controller(); | 38 ash::Shell::Get()->accelerator_controller(); |
40 | 39 |
41 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( | 40 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( |
42 accelerator); | 41 accelerator); |
43 if (accelerator_controller->ShouldCloseMenuAndRepostAccelerator( | 42 if (accelerator_controller->ShouldCloseMenuAndRepostAccelerator( |
44 accelerator)) { | 43 accelerator)) { |
45 base::ThreadTaskRunnerHandle::Get()->PostTask( | 44 base::ThreadTaskRunnerHandle::Get()->PostTask( |
46 FROM_HERE, base::Bind(ProcessAcceleratorNow, accelerator)); | 45 FROM_HERE, base::Bind(ProcessAcceleratorNow, accelerator)); |
47 return views::ViewsDelegate::ProcessMenuAcceleratorResult::CLOSE_MENU; | 46 return views::ViewsDelegate::ProcessMenuAcceleratorResult::CLOSE_MENU; |
48 } | 47 } |
49 | 48 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 params->context = params->context->GetRootWindow(); | 86 params->context = params->context->GetRootWindow(); |
88 DCHECK(params->parent || params->context || !params->child) | 87 DCHECK(params->parent || params->context || !params->child) |
89 << "Please provide a parent or context for this widget."; | 88 << "Please provide a parent or context for this widget."; |
90 if (!params->parent && !params->context) | 89 if (!params->parent && !params->context) |
91 params->context = ash::Shell::GetPrimaryRootWindow(); | 90 params->context = ash::Shell::GetPrimaryRootWindow(); |
92 | 91 |
93 // By returning null Widget creates the default NativeWidget implementation, | 92 // By returning null Widget creates the default NativeWidget implementation, |
94 // which for chromeos is NativeWidgetAura. | 93 // which for chromeos is NativeWidgetAura. |
95 return nullptr; | 94 return nullptr; |
96 } | 95 } |
OLD | NEW |