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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_NATIVE_WEB_KEYBOARD_EVENT_H_
6 #define CONTENT_PUBLIC_BROWSER_NATIVE_WEB_KEYBOARD_EVENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "build/build_config.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
13 #include "ui/base/events/event_constants.h"
14 #include "ui/gfx/native_widget_types.h"
18 // Owns a platform specific event; used to pass own and pass event through
19 // platform independent code.
20 struct CONTENT_EXPORT NativeWebKeyboardEvent
:
21 NON_EXPORTED_BASE(public WebKit::WebKeyboardEvent
) {
22 NativeWebKeyboardEvent();
24 explicit NativeWebKeyboardEvent(gfx::NativeEvent native_event
);
26 NativeWebKeyboardEvent(ui::EventType type
,
30 double time_stamp_seconds
);
31 #elif defined(OS_MACOSX) || defined(TOOLKIT_GTK)
32 // TODO(suzhe): Limit these constructors to Linux native Gtk port.
33 // For Linux Views port, after using RenderWidgetHostViewViews to replace
34 // RenderWidgetHostViewGtk, we can use constructors for TOOLKIT_VIEWS defined
36 NativeWebKeyboardEvent(wchar_t character
,
38 double time_stamp_seconds
);
39 #elif defined(OS_ANDROID)
40 NativeWebKeyboardEvent(WebKit::WebInputEvent::Type type
,
44 int unicode_character
,
46 // Takes ownership of android_key_event.
47 NativeWebKeyboardEvent(jobject android_key_event
,
48 WebKit::WebInputEvent::Type type
,
52 int unicode_character
,
56 NativeWebKeyboardEvent(const NativeWebKeyboardEvent
& event
);
57 ~NativeWebKeyboardEvent();
59 NativeWebKeyboardEvent
& operator=(const NativeWebKeyboardEvent
& event
);
61 gfx::NativeEvent os_event
;
63 // True if the browser should ignore this event if it's not handled by the
64 // renderer. This happens for RawKeyDown events that are created while IME is
65 // active and is necessary to prevent backspace from doing "history back" if
66 // it is hit in ime mode.
67 // Currently, it's only used by Linux and Mac ports.
70 #if defined(TOOLKIT_GTK)
71 // True if the key event matches an edit command. In order to ensure the edit
72 // command always work in web page, the browser should not pre-handle this key
73 // event as a reserved accelerator. See http://crbug.com/54573
74 bool match_edit_command
;
78 // Returns a bitmak of values from ui/base/events/event_constants.h.
79 CONTENT_EXPORT
int GetModifiersFromNativeWebKeyboardEvent(
80 const NativeWebKeyboardEvent
& event
);
82 } // namespace content
84 #endif // CONTENT_PUBLIC_BROWSER_NATIVE_WEB_KEYBOARD_EVENT_H_