OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 } | 1410 } |
1411 | 1411 |
1412 #if defined(OS_CHROMEOS) | 1412 #if defined(OS_CHROMEOS) |
1413 if (chrome::IsAcceleratorDeprecated(accelerator)) { | 1413 if (chrome::IsAcceleratorDeprecated(accelerator)) { |
1414 if (event.type == blink::WebInputEvent::RawKeyDown) | 1414 if (event.type == blink::WebInputEvent::RawKeyDown) |
1415 *is_keyboard_shortcut = true; | 1415 *is_keyboard_shortcut = true; |
1416 return false; | 1416 return false; |
1417 } | 1417 } |
1418 #endif // defined(OS_CHROMEOS) | 1418 #endif // defined(OS_CHROMEOS) |
1419 | 1419 |
| 1420 if (frame_->PreHandleKeyboardEvent(event)) |
| 1421 return true; |
| 1422 |
1420 chrome::BrowserCommandController* controller = browser_->command_controller(); | 1423 chrome::BrowserCommandController* controller = browser_->command_controller(); |
1421 | 1424 |
1422 // Here we need to retrieve the command id (if any) associated to the | 1425 // Here we need to retrieve the command id (if any) associated to the |
1423 // keyboard event. Instead of looking up the command id in the | 1426 // keyboard event. Instead of looking up the command id in the |
1424 // |accelerator_table_| by ourselves, we block the command execution of | 1427 // |accelerator_table_| by ourselves, we block the command execution of |
1425 // the |browser_| object then send the keyboard event to the | 1428 // the |browser_| object then send the keyboard event to the |
1426 // |focus_manager| as if we are activating an accelerator key. | 1429 // |focus_manager| as if we are activating an accelerator key. |
1427 // Then we can retrieve the command id from the |browser_| object. | 1430 // Then we can retrieve the command id from the |browser_| object. |
1428 bool original_block_command_state = controller->block_command_execution(); | 1431 bool original_block_command_state = controller->block_command_execution(); |
1429 controller->SetBlockCommandExecution(true); | 1432 controller->SetBlockCommandExecution(true); |
(...skipping 17 matching lines...) Expand all Loading... |
1447 } else if (processed) { | 1450 } else if (processed) { |
1448 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report | 1451 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report |
1449 // that we handled it. | 1452 // that we handled it. |
1450 return true; | 1453 return true; |
1451 } | 1454 } |
1452 | 1455 |
1453 return false; | 1456 return false; |
1454 } | 1457 } |
1455 | 1458 |
1456 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1459 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 1460 if (frame_->HandleKeyboardEvent(event)) |
| 1461 return; |
| 1462 |
1457 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 1463 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
1458 GetFocusManager()); | 1464 GetFocusManager()); |
1459 } | 1465 } |
1460 | 1466 |
1461 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1467 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
1462 // enabled in the page menu regardless of whether the command will do | 1468 // enabled in the page menu regardless of whether the command will do |
1463 // anything. When someone selects the menu item, we just act as if they hit | 1469 // anything. When someone selects the menu item, we just act as if they hit |
1464 // the keyboard shortcut for the command by sending the associated key press | 1470 // the keyboard shortcut for the command by sending the associated key press |
1465 // to windows. The real fix to this bug is to disable the commands when they | 1471 // to windows. The real fix to this bug is to disable the commands when they |
1466 // won't do anything. We'll need something like an overall clipboard command | 1472 // won't do anything. We'll need something like an overall clipboard command |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 } | 2661 } |
2656 | 2662 |
2657 extensions::ActiveTabPermissionGranter* | 2663 extensions::ActiveTabPermissionGranter* |
2658 BrowserView::GetActiveTabPermissionGranter() { | 2664 BrowserView::GetActiveTabPermissionGranter() { |
2659 content::WebContents* web_contents = GetActiveWebContents(); | 2665 content::WebContents* web_contents = GetActiveWebContents(); |
2660 if (!web_contents) | 2666 if (!web_contents) |
2661 return nullptr; | 2667 return nullptr; |
2662 return extensions::TabHelper::FromWebContents(web_contents) | 2668 return extensions::TabHelper::FromWebContents(web_contents) |
2663 ->active_tab_permission_granter(); | 2669 ->active_tab_permission_granter(); |
2664 } | 2670 } |
OLD | NEW |