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

Side by Side Diff: ui/wm/core/nested_accelerator_dispatcher_win.cc

Issue 301743002: Revert of Refactor and move ash independent nested accelerator code to ui/wm/core (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/wm/core/nested_accelerator_dispatcher_linux.cc ('k') | ui/wm/wm.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/wm/core/nested_accelerator_dispatcher.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_pump_dispatcher.h"
9 #include "base/run_loop.h"
10 #include "ui/events/event.h"
11 #include "ui/wm/core/nested_accelerator_delegate.h"
12
13 using base::MessagePumpDispatcher;
14
15 namespace wm {
16
17 namespace {
18
19 bool IsKeyEvent(const MSG& msg) {
20 return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ||
21 msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP;
22 }
23
24 } // namespace
25
26 class NestedAcceleratorDispatcherWin : public NestedAcceleratorDispatcher,
27 public MessagePumpDispatcher {
28 public:
29 NestedAcceleratorDispatcherWin(NestedAcceleratorDelegate* delegate,
30 MessagePumpDispatcher* nested)
31 : NestedAcceleratorDispatcher(delegate), nested_dispatcher_(nested) {}
32 virtual ~NestedAcceleratorDispatcherWin() {}
33
34 private:
35 // NestedAcceleratorDispatcher:
36 virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE {
37 return scoped_ptr<base::RunLoop>(new base::RunLoop(this));
38 }
39
40 // MessagePumpDispatcher:
41 virtual uint32_t Dispatch(const MSG& event) OVERRIDE {
42 if (IsKeyEvent(event)) {
43 ui::KeyEvent key_event(event, false);
44 if (!delegate_->ShouldProcessEventNow(key_event))
45 return POST_DISPATCH_QUIT_LOOP;
46
47 if (delegate_->ProcessEvent(key_event))
48 return POST_DISPATCH_NONE;
49 }
50
51 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
52 : POST_DISPATCH_PERFORM_DEFAULT;
53 }
54
55 MessagePumpDispatcher* nested_dispatcher_;
56
57 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherWin);
58 };
59
60 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create(
61 NestedAcceleratorDelegate* delegate,
62 MessagePumpDispatcher* nested_dispatcher) {
63 return scoped_ptr<NestedAcceleratorDispatcher>(
64 new NestedAcceleratorDispatcherWin(delegate, nested_dispatcher));
65 }
66
67 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/nested_accelerator_dispatcher_linux.cc ('k') | ui/wm/wm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698