OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/ui/cocoa/html_dialog_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" |
6 | 6 |
7 #include "app/keyboard_codes.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
10 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
11 #include "chrome/browser/dom_ui/html_dialog_ui.h" | 10 #include "chrome/browser/dom_ui/html_dialog_ui.h" |
12 #include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h" | 11 #include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | 14 #import "chrome/browser/ui/cocoa/browser_command_executor.h" |
16 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 15 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
17 #include "chrome/common/native_web_keyboard_event.h" | 16 #include "chrome/common/native_web_keyboard_event.h" |
18 #include "gfx/size.h" | 17 #include "gfx/size.h" |
19 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 19 #include "ui/base/keycodes/keyboard_codes.h" |
20 | 20 |
21 // Thin bridge that routes notifications to | 21 // Thin bridge that routes notifications to |
22 // HtmlDialogWindowController's member variables. | 22 // HtmlDialogWindowController's member variables. |
23 class HtmlDialogWindowDelegateBridge : public HtmlDialogUIDelegate, | 23 class HtmlDialogWindowDelegateBridge : public HtmlDialogUIDelegate, |
24 public HtmlDialogTabContentsDelegate { | 24 public HtmlDialogTabContentsDelegate { |
25 public: | 25 public: |
26 // All parameters must be non-NULL/non-nil. | 26 // All parameters must be non-NULL/non-nil. |
27 HtmlDialogWindowDelegateBridge(HtmlDialogWindowController* controller, | 27 HtmlDialogWindowDelegateBridge(HtmlDialogWindowController* controller, |
28 Profile* profile, | 28 Profile* profile, |
29 HtmlDialogUIDelegate* delegate); | 29 HtmlDialogUIDelegate* delegate); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // since we handle keyboard events ourselves we can't do that. | 188 // since we handle keyboard events ourselves we can't do that. |
189 // | 189 // |
190 // According to experiments, hitting Esc works regardless of the | 190 // According to experiments, hitting Esc works regardless of the |
191 // presence of other modifiers (as long as it's not an app-level | 191 // presence of other modifiers (as long as it's not an app-level |
192 // shortcut, e.g. Commmand-Esc for Front Row) but no other modifiers | 192 // shortcut, e.g. Commmand-Esc for Front Row) but no other modifiers |
193 // can be present for Command-. to work. | 193 // can be present for Command-. to work. |
194 // | 194 // |
195 // TODO(thakis): It would be nice to get cancel: to work somehow. | 195 // TODO(thakis): It would be nice to get cancel: to work somehow. |
196 // Bug: http://code.google.com/p/chromium/issues/detail?id=32828 . | 196 // Bug: http://code.google.com/p/chromium/issues/detail?id=32828 . |
197 if (event.type == NativeWebKeyboardEvent::RawKeyDown && | 197 if (event.type == NativeWebKeyboardEvent::RawKeyDown && |
198 ((event.windowsKeyCode == app::VKEY_ESCAPE) || | 198 ((event.windowsKeyCode == ui::VKEY_ESCAPE) || |
199 (event.windowsKeyCode == app::VKEY_OEM_PERIOD && | 199 (event.windowsKeyCode == ui::VKEY_OEM_PERIOD && |
200 event.modifiers == NativeWebKeyboardEvent::MetaKey))) { | 200 event.modifiers == NativeWebKeyboardEvent::MetaKey))) { |
201 [controller_ close]; | 201 [controller_ close]; |
202 return; | 202 return; |
203 } | 203 } |
204 | 204 |
205 ChromeEventProcessingWindow* event_window = | 205 ChromeEventProcessingWindow* event_window = |
206 static_cast<ChromeEventProcessingWindow*>([controller_ window]); | 206 static_cast<ChromeEventProcessingWindow*>([controller_ window]); |
207 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); | 207 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); |
208 [event_window redispatchKeyEvent:event.os_event]; | 208 [event_window redispatchKeyEvent:event.os_event]; |
209 } | 209 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 284 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
285 // to do the above doesn't work. | 285 // to do the above doesn't work. |
286 } | 286 } |
287 | 287 |
288 - (void)windowWillClose:(NSNotification*)notification { | 288 - (void)windowWillClose:(NSNotification*)notification { |
289 delegate_->WindowControllerClosed(); | 289 delegate_->WindowControllerClosed(); |
290 [self autorelease]; | 290 [self autorelease]; |
291 } | 291 } |
292 | 292 |
293 @end | 293 @end |
OLD | NEW |