Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / renderer_host / native_web_keyboard_event_mac.mm
blob76c5c1006bfcda2dad993fb71de54de13a7f08ec
1 // Copyright (c) 2011 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.
5 #include "content/public/browser/native_web_keyboard_event.h"
7 #import <AppKit/AppKit.h>
9 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h"
10 #include "ui/events/event.h"
12 using blink::WebInputEventFactory;
14 namespace content {
16 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
17     : os_event(NULL),
18       skip_in_browser(false) {
21 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
22     : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(native_event)),
23       os_event([native_event retain]),
24       skip_in_browser(false) {
27 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event)
28     : NativeWebKeyboardEvent(key_event.native_event()) {
31 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
32     const NativeWebKeyboardEvent& other)
33     : WebKeyboardEvent(other),
34       os_event([other.os_event retain]),
35       skip_in_browser(other.skip_in_browser) {
38 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
39     const NativeWebKeyboardEvent& other) {
40   WebKeyboardEvent::operator=(other);
42   NSObject* previous = os_event;
43   os_event = [other.os_event retain];
44   [previous release];
46   skip_in_browser = other.skip_in_browser;
48   return *this;
51 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
52   [os_event release];
55 }  // namespace content