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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Add comment. Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/ws/event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); 249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher));
250 // If an accelerator with the same id or matcher already exists, then abort. 250 // If an accelerator with the same id or matcher already exists, then abort.
251 for (const auto& pair : accelerators_) { 251 for (const auto& pair : accelerators_) {
252 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) 252 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get()))
253 return false; 253 return false;
254 } 254 }
255 accelerators_.insert(Entry(id, std::move(accelerator))); 255 accelerators_.insert(Entry(id, std::move(accelerator)));
256 return true; 256 return true;
257 } 257 }
258 258
259 bool EventDispatcher::AddAccelerators(
260 std::vector<ui::mojom::AcceleratorPtr> accelerators) {
261 bool all_new_accelerators = true;
262 for (auto iter = accelerators.begin(); iter != accelerators.end(); ++iter) {
263 if (!AddAccelerator(iter->get()->id, iter->get()->event_matcher.Clone()))
264 all_new_accelerators = false;
265 }
266 return all_new_accelerators;
267 }
268
259 void EventDispatcher::RemoveAccelerator(uint32_t id) { 269 void EventDispatcher::RemoveAccelerator(uint32_t id) {
260 auto it = accelerators_.find(id); 270 auto it = accelerators_.find(id);
261 // Clients may pass bogus ids. 271 // Clients may pass bogus ids.
262 if (it != accelerators_.end()) 272 if (it != accelerators_.end())
263 accelerators_.erase(it); 273 accelerators_.erase(it);
264 } 274 }
265 275
266 void EventDispatcher::ProcessEvent(const ui::Event& event, 276 void EventDispatcher::ProcessEvent(const ui::Event& event,
267 AcceleratorMatchPhase match_phase) { 277 AcceleratorMatchPhase match_phase) {
268 #if !defined(NDEBUG) 278 #if !defined(NDEBUG)
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (mouse_cursor_source_window_ == window) 626 if (mouse_cursor_source_window_ == window)
617 mouse_cursor_source_window_ = nullptr; 627 mouse_cursor_source_window_ = nullptr;
618 } 628 }
619 629
620 void EventDispatcher::OnDragCursorUpdated() { 630 void EventDispatcher::OnDragCursorUpdated() {
621 delegate_->UpdateNativeCursorFromDispatcher(); 631 delegate_->UpdateNativeCursorFromDispatcher();
622 } 632 }
623 633
624 } // namespace ws 634 } // namespace ws
625 } // namespace ui 635 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698