summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcem.kocagil@gmail.com <cem.kocagil@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-14 10:51:49 +0000
committercem.kocagil@gmail.com <cem.kocagil@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-14 10:51:49 +0000
commitb93a3636364ac026697cf08a8b213fd76882363b (patch)
tree87b105e98d0cdf3635582efd4578655c897895e5 /content
parentde1528d1a20fe662a0193977793b23bada0b9ffd (diff)
downloadchromium_src-b93a3636364ac026697cf08a8b213fd76882363b.zip
chromium_src-b93a3636364ac026697cf08a8b213fd76882363b.tar.gz
chromium_src-b93a3636364ac026697cf08a8b213fd76882363b.tar.bz2
Add keyboard shortcut to create windows (content_shell)
BUG=120153 TEST=Hitting Control-N while focused on webpage should create new window Review URL: https://chromiumcodereview.appspot.com/9969040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/shell/shell.h6
-rwxr-xr-x[-rw-r--r--]content/shell/shell_win.cc25
2 files changed, 30 insertions, 1 deletions
diff --git a/content/shell/shell.h b/content/shell/shell.h
index a15430d..1ea5755 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -125,7 +125,11 @@ class Shell : public WebContentsDelegate,
virtual void DidNavigateMainFramePostCommit(
WebContents* web_contents) OVERRIDE;
virtual JavaScriptDialogCreator* GetJavaScriptDialogCreator() OVERRIDE;
-#if defined(OS_MACOSX)
+
+#if defined(OS_WIN)
+ virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) OVERRIDE;
+#elif defined(OS_MACOSX)
virtual void HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) OVERRIDE;
#endif
diff --git a/content/shell/shell_win.cc b/content/shell/shell_win.cc
index 3aeef3c..ff3519a 100644..100755
--- a/content/shell/shell_win.cc
+++ b/content/shell/shell_win.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "base/win/resource_util.h"
#include "base/win/wrapped_window_proc.h"
+#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/shell/resource.h"
@@ -188,6 +189,30 @@ void Shell::Close() {
DestroyWindow(window_);
}
+bool Shell::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) {
+ if (event.type != WebKit::WebInputEvent::RawKeyDown)
+ return false;
+
+ bool control = (event.modifiers & NativeWebKeyboardEvent::ControlKey) ==
+ NativeWebKeyboardEvent::ControlKey;
+ bool shift = (event.modifiers & NativeWebKeyboardEvent::ShiftKey) ==
+ NativeWebKeyboardEvent::ShiftKey;
+ bool alt = (event.modifiers & NativeWebKeyboardEvent::AltKey) ==
+ NativeWebKeyboardEvent::AltKey;
+
+ // Control-N creates a new window
+ if (control && !shift && !alt &&
+ event.text[0] == 'N') {
+ CreateNewWindow(web_contents()->GetBrowserContext(), GURL(), NULL,
+ MSG_ROUTING_NONE, NULL);
+ return true;
+ }
+
+ *is_keyboard_shortcut = true;
+ return false;
+}
+
ATOM Shell::RegisterWindowClass() {
WNDCLASSEX window_class;
base::win::InitializeWindowClass(