OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/input/accelerator_manager_impl.h" | 5 #include "athena/input/accelerator_manager_impl.h" |
6 | 6 |
7 #include "athena/input/public/input_manager.h" | 7 #include "athena/input/public/input_manager.h" |
8 #include "athena/util/switches.h" | 8 #include "athena/util/switches.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 virtual ~FocusManagerDelegate() {} | 95 virtual ~FocusManagerDelegate() {} |
96 | 96 |
97 virtual bool ProcessAccelerator(const ui::Accelerator& accelerator) override { | 97 virtual bool ProcessAccelerator(const ui::Accelerator& accelerator) override { |
98 return accelerator_manager_->Process(accelerator); | 98 return accelerator_manager_->Process(accelerator); |
99 } | 99 } |
100 | 100 |
101 virtual ui::AcceleratorTarget* GetCurrentTargetForAccelerator( | 101 virtual ui::AcceleratorTarget* GetCurrentTargetForAccelerator( |
102 const ui::Accelerator& accelerator) const override { | 102 const ui::Accelerator& accelerator) const override { |
103 return accelerator_manager_->IsRegistered(accelerator, AF_NONE) | 103 return accelerator_manager_->IsRegistered(accelerator, AF_NONE) |
104 ? accelerator_manager_ | 104 ? accelerator_manager_ |
105 : NULL; | 105 : nullptr; |
106 } | 106 } |
107 | 107 |
108 private: | 108 private: |
109 AcceleratorManagerImpl* accelerator_manager_; | 109 AcceleratorManagerImpl* accelerator_manager_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(FocusManagerDelegate); | 111 DISALLOW_COPY_AND_ASSIGN(FocusManagerDelegate); |
112 }; | 112 }; |
113 | 113 |
114 // Key strokes must be sent to web contents to give them a chance to | 114 // Key strokes must be sent to web contents to give them a chance to |
115 // consume them unless they are reserved, and unhandled key events are | 115 // consume them unless they are reserved, and unhandled key events are |
116 // sent back to focus manager asynchronously. This installs the athena's | 116 // sent back to focus manager asynchronously. This installs the athena's |
117 // focus manager that handles athena shell's accelerators. | 117 // focus manager that handles athena shell's accelerators. |
118 class FocusManagerFactory : public views::FocusManagerFactory { | 118 class FocusManagerFactory : public views::FocusManagerFactory { |
119 public: | 119 public: |
120 explicit FocusManagerFactory(AcceleratorManagerImpl* accelerator_manager) | 120 explicit FocusManagerFactory(AcceleratorManagerImpl* accelerator_manager) |
121 : accelerator_manager_(accelerator_manager) {} | 121 : accelerator_manager_(accelerator_manager) {} |
122 virtual ~FocusManagerFactory() {} | 122 virtual ~FocusManagerFactory() {} |
123 | 123 |
124 virtual views::FocusManager* CreateFocusManager( | 124 virtual views::FocusManager* CreateFocusManager( |
125 views::Widget* widget, | 125 views::Widget* widget, |
126 bool desktop_widget) override { | 126 bool desktop_widget) override { |
127 return new views::FocusManager( | 127 return new views::FocusManager( |
128 widget, | 128 widget, |
129 desktop_widget ? NULL : new FocusManagerDelegate(accelerator_manager_)); | 129 desktop_widget ? nullptr |
| 130 : new FocusManagerDelegate(accelerator_manager_)); |
130 } | 131 } |
131 | 132 |
132 private: | 133 private: |
133 AcceleratorManagerImpl* accelerator_manager_; | 134 AcceleratorManagerImpl* accelerator_manager_; |
134 | 135 |
135 DISALLOW_COPY_AND_ASSIGN(FocusManagerFactory); | 136 DISALLOW_COPY_AND_ASSIGN(FocusManagerFactory); |
136 }; | 137 }; |
137 | 138 |
138 class UIAcceleratorManagerWrapper | 139 class UIAcceleratorManagerWrapper |
139 : public AcceleratorManagerImpl::AcceleratorWrapper { | 140 : public AcceleratorManagerImpl::AcceleratorWrapper { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return scoped_ptr<AcceleratorManager>( | 240 return scoped_ptr<AcceleratorManager>( |
240 new AcceleratorManagerImpl(new FocusManagerWrapper(focus_manager))) | 241 new AcceleratorManagerImpl(new FocusManagerWrapper(focus_manager))) |
241 .Pass(); | 242 .Pass(); |
242 } | 243 } |
243 | 244 |
244 AcceleratorManagerImpl::~AcceleratorManagerImpl() { | 245 AcceleratorManagerImpl::~AcceleratorManagerImpl() { |
245 nested_accelerator_controller_.reset(); | 246 nested_accelerator_controller_.reset(); |
246 accelerator_filter_.reset(); | 247 accelerator_filter_.reset(); |
247 // Reset to use the default focus manager because the athena's | 248 // Reset to use the default focus manager because the athena's |
248 // FocusManager has the reference to this object. | 249 // FocusManager has the reference to this object. |
249 views::FocusManagerFactory::Install(NULL); | 250 views::FocusManagerFactory::Install(nullptr); |
250 } | 251 } |
251 | 252 |
252 void AcceleratorManagerImpl::Init() { | 253 void AcceleratorManagerImpl::Init() { |
253 views::FocusManagerFactory::Install(new FocusManagerFactory(this)); | 254 views::FocusManagerFactory::Install(new FocusManagerFactory(this)); |
254 | 255 |
255 ui::EventTarget* toplevel = InputManager::Get()->GetTopmostEventTarget(); | 256 ui::EventTarget* toplevel = InputManager::Get()->GetTopmostEventTarget(); |
256 nested_accelerator_controller_.reset( | 257 nested_accelerator_controller_.reset( |
257 new wm::NestedAcceleratorController(new NestedAcceleratorDelegate(this))); | 258 new wm::NestedAcceleratorController(new NestedAcceleratorDelegate(this))); |
258 | 259 |
259 scoped_ptr<wm::AcceleratorDelegate> accelerator_delegate( | 260 scoped_ptr<wm::AcceleratorDelegate> accelerator_delegate( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return InputManager::Get()->GetAcceleratorManager(); | 354 return InputManager::Get()->GetAcceleratorManager(); |
354 } | 355 } |
355 | 356 |
356 // static | 357 // static |
357 scoped_ptr<AcceleratorManager> AcceleratorManager::CreateForFocusManager( | 358 scoped_ptr<AcceleratorManager> AcceleratorManager::CreateForFocusManager( |
358 views::FocusManager* focus_manager) { | 359 views::FocusManager* focus_manager) { |
359 return AcceleratorManagerImpl::CreateForFocusManager(focus_manager).Pass(); | 360 return AcceleratorManagerImpl::CreateForFocusManager(focus_manager).Pass(); |
360 } | 361 } |
361 | 362 |
362 } // namespace athena | 363 } // namespace athena |
OLD | NEW |