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

Side by Side Diff: content/browser/renderer_host/gtk_key_bindings_handler.h

Issue 11343017: Move remaining files in content\browser\renderer_host to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 1 month 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "content/common/edit_command.h" 12 #include "content/common/edit_command.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "ui/base/gtk/owned_widget_gtk.h" 14 #include "ui/base/gtk/owned_widget_gtk.h"
15 15
16 namespace content { 16 namespace content {
17 struct NativeWebKeyboardEvent; 17 struct NativeWebKeyboardEvent;
18 }
19 18
20 // This class is a convenience class for handling editor key bindings defined 19 // This class is a convenience class for handling editor key bindings defined
21 // in gtk keyboard theme. 20 // in gtk keyboard theme.
22 // In gtk, only GtkEntry and GtkTextView support customizing editor key bindings 21 // In gtk, only GtkEntry and GtkTextView support customizing editor key bindings
23 // through keyboard theme. And in gtk keyboard theme definition file, each key 22 // through keyboard theme. And in gtk keyboard theme definition file, each key
24 // binding must be bound to a specific class or object. So existing keyboard 23 // binding must be bound to a specific class or object. So existing keyboard
25 // themes only define editor key bindings exactly for GtkEntry and GtkTextView. 24 // themes only define editor key bindings exactly for GtkEntry and GtkTextView.
26 // Then, the only way for us to intercept editor key bindings defined in 25 // Then, the only way for us to intercept editor key bindings defined in
27 // keyboard theme, is to create a GtkEntry or GtkTextView object and call 26 // keyboard theme, is to create a GtkEntry or GtkTextView object and call
28 // gtk_bindings_activate_event() against it for the key events. If a key event 27 // gtk_bindings_activate_event() against it for the key events. If a key event
29 // matches a predefined key binding, corresponding signal will be emitted. 28 // matches a predefined key binding, corresponding signal will be emitted.
30 // GtkTextView is used here because it supports more key bindings than GtkEntry, 29 // GtkTextView is used here because it supports more key bindings than GtkEntry,
31 // but in order to minimize the side effect of using a GtkTextView object, a new 30 // but in order to minimize the side effect of using a GtkTextView object, a new
32 // class derived from GtkTextView is used, which overrides all signals related 31 // class derived from GtkTextView is used, which overrides all signals related
33 // to key bindings, to make sure GtkTextView won't receive them. 32 // to key bindings, to make sure GtkTextView won't receive them.
34 // 33 //
35 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed 34 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed
36 // definition of webkit edit commands. 35 // definition of webkit edit commands.
37 // See webkit/glue/editor_client_impl.cc for key bindings predefined in our 36 // See webkit/glue/editor_client_impl.cc for key bindings predefined in our
38 // webkit glue. 37 // webkit glue.
39 class CONTENT_EXPORT GtkKeyBindingsHandler { 38 class CONTENT_EXPORT GtkKeyBindingsHandler {
40 public: 39 public:
41 explicit GtkKeyBindingsHandler(GtkWidget* parent_widget); 40 explicit GtkKeyBindingsHandler(GtkWidget* parent_widget);
42 ~GtkKeyBindingsHandler(); 41 ~GtkKeyBindingsHandler();
43 42
44 // Matches a key event against predefined gtk key bindings, false will be 43 // Matches a key event against predefined gtk key bindings, false will be
45 // returned if the key event doesn't correspond to a predefined key binding. 44 // returned if the key event doesn't correspond to a predefined key binding.
46 // Edit commands matched with |wke| will be stored in |edit_commands|. 45 // Edit commands matched with |wke| will be stored in |edit_commands|.
47 bool Match(const content::NativeWebKeyboardEvent& wke, 46 bool Match(const NativeWebKeyboardEvent& wke,
48 content::EditCommands* edit_commands); 47 EditCommands* edit_commands);
49 48
50 private: 49 private:
51 // Object structure of Handler class, which is derived from GtkTextView. 50 // Object structure of Handler class, which is derived from GtkTextView.
52 struct Handler { 51 struct Handler {
53 GtkTextView parent_object; 52 GtkTextView parent_object;
54 GtkKeyBindingsHandler *owner; 53 GtkKeyBindingsHandler *owner;
55 }; 54 };
56 55
57 // Class structure of Handler class. 56 // Class structure of Handler class.
58 struct HandlerClass { 57 struct HandlerClass {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 117
119 // Handler of "show-help" signal. 118 // Handler of "show-help" signal.
120 static gboolean ShowHelp(GtkWidget* widget, GtkWidgetHelpType arg1); 119 static gboolean ShowHelp(GtkWidget* widget, GtkWidgetHelpType arg1);
121 120
122 // Handler of "move-focus" signal. 121 // Handler of "move-focus" signal.
123 static void MoveFocus(GtkWidget* widget, GtkDirectionType arg1); 122 static void MoveFocus(GtkWidget* widget, GtkDirectionType arg1);
124 123
125 ui::OwnedWidgetGtk handler_; 124 ui::OwnedWidgetGtk handler_;
126 125
127 // Buffer to store the match results. 126 // Buffer to store the match results.
128 content::EditCommands edit_commands_; 127 EditCommands edit_commands_;
129 }; 128 };
130 129
130 } // namespace content
131
131 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_ 132 #endif // CONTENT_BROWSER_RENDERER_HOST_GTK_KEY_BINDINGS_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/gesture_event_filter.h ('k') | content/browser/renderer_host/gtk_key_bindings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698