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

Side by Side Diff: ui/views/event_monitor_mac.mm

Issue 981693002: MacViews: Fix crash when EventMonitorMac receives a NSSystemDefinedEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@views
Patch Set: Created 5 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
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #import "ui/views/event_monitor_mac.h" 5 #import "ui/views/event_monitor_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 24 matching lines...) Expand all
35 return gfx::Point(mouseLocation.x, mouseLocation.y); 35 return gfx::Point(mouseLocation.x, mouseLocation.y);
36 } 36 }
37 37
38 EventMonitorMac::EventMonitorMac(ui::EventHandler* event_handler, 38 EventMonitorMac::EventMonitorMac(ui::EventHandler* event_handler,
39 gfx::NativeWindow target_window) { 39 gfx::NativeWindow target_window) {
40 DCHECK(event_handler); 40 DCHECK(event_handler);
41 monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSAnyEventMask 41 monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSAnyEventMask
42 handler:^NSEvent*(NSEvent* event) { 42 handler:^NSEvent*(NSEvent* event) {
43 if (!target_window || [event window] == target_window) { 43 if (!target_window || [event window] == target_window) {
44 scoped_ptr<ui::Event> ui_event = ui::EventFromNative(event); 44 scoped_ptr<ui::Event> ui_event = ui::EventFromNative(event);
45 event_handler->OnEvent(ui_event.get()); 45 if (ui_event)
46 event_handler->OnEvent(ui_event.get());
46 } 47 }
47 return event; 48 return event;
48 }]; 49 }];
49 } 50 }
50 51
51 EventMonitorMac::~EventMonitorMac() { 52 EventMonitorMac::~EventMonitorMac() {
52 [NSEvent removeMonitor:monitor_]; 53 [NSEvent removeMonitor:monitor_];
53 } 54 }
54 55
55 } // namespace views 56 } // namespace views
OLDNEW
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698