Home | History | Annotate | Download | only in accelerators
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
      6 #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "base/message_loop/message_loop.h"
     10 #include "ui/aura/window.h"
     11 #include "ui/aura/window_observer.h"
     12 
     13 namespace ash {
     14 
     15 // Dispatcher for handling accelerators from menu.
     16 //
     17 // Wraps a nested dispatcher to which control is passed if no accelerator key
     18 // has been pressed.
     19 // TODO(pkotwicz): Port AcceleratorDispatcher to mac.
     20 // TODO(pkotwicz): Add support for a |nested_dispatcher| which sends
     21 //  events to a system IME.
     22 class ASH_EXPORT AcceleratorDispatcher : public base::MessageLoop::Dispatcher,
     23                                          public aura::WindowObserver {
     24  public:
     25   AcceleratorDispatcher(base::MessageLoop::Dispatcher* nested_dispatcher,
     26                         aura::Window* associated_window);
     27   virtual ~AcceleratorDispatcher();
     28 
     29   // MessageLoop::Dispatcher overrides:
     30   virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
     31 
     32   // aura::WindowObserver overrides:
     33   virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
     34 
     35  private:
     36   base::MessageLoop::Dispatcher* nested_dispatcher_;
     37 
     38   // Window associated with |nested_dispatcher_| which is used to determine
     39   // whether the |nested_dispatcher_| is allowed to receive events.
     40   aura::Window* associated_window_;
     41 
     42   DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher);
     43 };
     44 
     45 }  // namespace ash
     46 
     47 #endif  // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
     48