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

Side by Side Diff: ash/accelerators/accelerator_dispatcher.cc

Issue 182143002: Use the default dispatcher where possible for nested message loops. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar-fix Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ash/accelerators/accelerator_dispatcher.h" 5 #include "ash/accelerators/accelerator_dispatcher.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Xlib defines RootWindow 10 // Xlib defines RootWindow
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return false; 63 return false;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 AcceleratorDispatcher::AcceleratorDispatcher( 68 AcceleratorDispatcher::AcceleratorDispatcher(
69 base::MessagePumpDispatcher* nested_dispatcher, 69 base::MessagePumpDispatcher* nested_dispatcher,
70 aura::Window* associated_window) 70 aura::Window* associated_window)
71 : nested_dispatcher_(nested_dispatcher), 71 : nested_dispatcher_(nested_dispatcher),
72 associated_window_(associated_window) { 72 associated_window_(associated_window) {
73 DCHECK(nested_dispatcher_);
74 associated_window_->AddObserver(this); 73 associated_window_->AddObserver(this);
75 } 74 }
76 75
77 AcceleratorDispatcher::~AcceleratorDispatcher() { 76 AcceleratorDispatcher::~AcceleratorDispatcher() {
78 if (associated_window_) 77 if (associated_window_)
79 associated_window_->RemoveObserver(this); 78 associated_window_->RemoveObserver(this);
80 } 79 }
81 80
82 void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) { 81 void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) {
83 if (associated_window_ == window) 82 if (associated_window_ == window)
(...skipping 30 matching lines...) Expand all
114 if (key_event.type() == ui::ET_KEY_RELEASED) 113 if (key_event.type() == ui::ET_KEY_RELEASED)
115 accelerator.set_type(ui::ET_KEY_RELEASED); 114 accelerator.set_type(ui::ET_KEY_RELEASED);
116 // Fill out context object so AcceleratorController will know what 115 // Fill out context object so AcceleratorController will know what
117 // was the previous accelerator or if the current accelerator is repeated. 116 // was the previous accelerator or if the current accelerator is repeated.
118 Shell::GetInstance()->accelerator_controller()->context()-> 117 Shell::GetInstance()->accelerator_controller()->context()->
119 UpdateContext(accelerator); 118 UpdateContext(accelerator);
120 if (accelerator_controller->Process(accelerator)) 119 if (accelerator_controller->Process(accelerator))
121 return POST_DISPATCH_NONE; 120 return POST_DISPATCH_NONE;
122 } 121 }
123 122
124 return nested_dispatcher_->Dispatch(key_event.native_event()); 123 return nested_dispatcher_
124 ? nested_dispatcher_->Dispatch(key_event.native_event())
125 : POST_DISPATCH_PERFORM_DEFAULT;
125 } 126 }
126 127
127 return nested_dispatcher_->Dispatch(event); 128 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
129 : POST_DISPATCH_PERFORM_DEFAULT;
128 } 130 }
129 131
130 } // namespace ash 132 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_dispatcher.h ('k') | ash/accelerators/nested_dispatcher_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698