| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/views/frame/browser_frame_mac.h" | 5 #import "chrome/browser/ui/views/frame/browser_frame_mac.h" |
| 6 | 6 |
| 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 8 #include "chrome/browser/ui/browser_command_controller.h" | 8 #include "chrome/browser/ui/browser_command_controller.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 10 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" |
| 11 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" | 11 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_frame.h" | 12 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 14 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" | 14 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_host.h" | 15 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 16 #include "content/public/browser/native_web_keyboard_event.h" | 16 #include "content/public/browser/native_web_keyboard_event.h" |
| 17 #import "ui/base/cocoa/window_size_constants.h" | 17 #import "ui/base/cocoa/window_size_constants.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 bool ShouldHandleKeyboardEvent(const content::NativeWebKeyboardEvent& event) { | 21 bool ShouldHandleKeyboardEvent(const content::NativeWebKeyboardEvent& event) { |
| 22 // |event.skip_in_browser| is true when it shouldn't be handled by the browser | 22 // |event.skip_in_browser| is true when it shouldn't be handled by the browser |
| 23 // if it was ignored by the renderer. See http://crbug.com/25000. | 23 // if it was ignored by the renderer. See http://crbug.com/25000. |
| 24 if (event.skip_in_browser) | 24 if (event.skip_in_browser) |
| 25 return false; | 25 return false; |
| 26 | 26 |
| 27 // Ignore synthesized keyboard events. See http://crbug.com/23221. | 27 // Ignore synthesized keyboard events. See http://crbug.com/23221. |
| 28 if (event.type() == content::NativeWebKeyboardEvent::Char) | 28 if (event.GetType() == content::NativeWebKeyboardEvent::kChar) |
| 29 return false; | 29 return false; |
| 30 | 30 |
| 31 // If the event was not synthesized it should have an os_event. | 31 // If the event was not synthesized it should have an os_event. |
| 32 DCHECK(event.os_event); | 32 DCHECK(event.os_event); |
| 33 | 33 |
| 34 // Do not fire shortcuts on key up. | 34 // Do not fire shortcuts on key up. |
| 35 return [event.os_event type] == NSKeyDown; | 35 return [event.os_event type] == NSKeyDown; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Returns true if |event| was handled. | 38 // Returns true if |event| was handled. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool BrowserFrameMac::HandleKeyboardEvent( | 172 bool BrowserFrameMac::HandleKeyboardEvent( |
| 173 const content::NativeWebKeyboardEvent& event) { | 173 const content::NativeWebKeyboardEvent& event) { |
| 174 if (!ShouldHandleKeyboardEvent(event)) | 174 if (!ShouldHandleKeyboardEvent(event)) |
| 175 return false; | 175 return false; |
| 176 | 176 |
| 177 return HandleExtraKeyboardShortcut(event.os_event, browser_view_->browser(), | 177 return HandleExtraKeyboardShortcut(event.os_event, browser_view_->browser(), |
| 178 command_dispatcher_delegate_); | 178 command_dispatcher_delegate_); |
| 179 } | 179 } |
| OLD | NEW |