15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/ash_export.h"
97dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "base/message_loop/message_loop.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/window.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/window_observer.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ash {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Dispatcher for handling accelerators from menu.
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Wraps a nested dispatcher to which control is passed if no accelerator key
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// has been pressed.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(pkotwicz): Port AcceleratorDispatcher to mac.
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(pkotwicz): Add support for a |nested_dispatcher| which sends
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//  events to a system IME.
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class ASH_EXPORT AcceleratorDispatcher : public base::MessageLoop::Dispatcher,
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         public aura::WindowObserver {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  AcceleratorDispatcher(base::MessageLoop::Dispatcher* nested_dispatcher,
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        aura::Window* associated_window);
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~AcceleratorDispatcher();
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // MessageLoop::Dispatcher overrides:
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // aura::WindowObserver overrides:
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  base::MessageLoop::Dispatcher* nested_dispatcher_;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Window associated with |nested_dispatcher_| which is used to determine
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // whether the |nested_dispatcher_| is allowed to receive events.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  aura::Window* associated_window_;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher);
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace ash
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
48