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 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 } | 1345 } |
1346 | 1346 |
1347 #if defined(OS_CHROMEOS) | 1347 #if defined(OS_CHROMEOS) |
1348 if (chrome::IsAcceleratorDeprecated(accelerator)) { | 1348 if (chrome::IsAcceleratorDeprecated(accelerator)) { |
1349 if (event.type == blink::WebInputEvent::RawKeyDown) | 1349 if (event.type == blink::WebInputEvent::RawKeyDown) |
1350 *is_keyboard_shortcut = true; | 1350 *is_keyboard_shortcut = true; |
1351 return false; | 1351 return false; |
1352 } | 1352 } |
1353 #endif // defined(OS_CHROMEOS) | 1353 #endif // defined(OS_CHROMEOS) |
1354 | 1354 |
| 1355 if (frame_->PreHandleKeyboardEvent(event)) |
| 1356 return true; |
| 1357 |
1355 chrome::BrowserCommandController* controller = browser_->command_controller(); | 1358 chrome::BrowserCommandController* controller = browser_->command_controller(); |
1356 | 1359 |
1357 // Here we need to retrieve the command id (if any) associated to the | 1360 // Here we need to retrieve the command id (if any) associated to the |
1358 // keyboard event. Instead of looking up the command id in the | 1361 // keyboard event. Instead of looking up the command id in the |
1359 // |accelerator_table_| by ourselves, we block the command execution of | 1362 // |accelerator_table_| by ourselves, we block the command execution of |
1360 // the |browser_| object then send the keyboard event to the | 1363 // the |browser_| object then send the keyboard event to the |
1361 // |focus_manager| as if we are activating an accelerator key. | 1364 // |focus_manager| as if we are activating an accelerator key. |
1362 // Then we can retrieve the command id from the |browser_| object. | 1365 // Then we can retrieve the command id from the |browser_| object. |
1363 bool original_block_command_state = controller->block_command_execution(); | 1366 bool original_block_command_state = controller->block_command_execution(); |
1364 controller->SetBlockCommandExecution(true); | 1367 controller->SetBlockCommandExecution(true); |
(...skipping 17 matching lines...) Expand all Loading... |
1382 } else if (processed) { | 1385 } else if (processed) { |
1383 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report | 1386 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report |
1384 // that we handled it. | 1387 // that we handled it. |
1385 return true; | 1388 return true; |
1386 } | 1389 } |
1387 | 1390 |
1388 return false; | 1391 return false; |
1389 } | 1392 } |
1390 | 1393 |
1391 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1394 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 1395 if (frame_->HandleKeyboardEvent(event)) |
| 1396 return; |
| 1397 |
1392 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 1398 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
1393 GetFocusManager()); | 1399 GetFocusManager()); |
1394 } | 1400 } |
1395 | 1401 |
1396 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1402 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
1397 // enabled in the page menu regardless of whether the command will do | 1403 // enabled in the page menu regardless of whether the command will do |
1398 // anything. When someone selects the menu item, we just act as if they hit | 1404 // anything. When someone selects the menu item, we just act as if they hit |
1399 // the keyboard shortcut for the command by sending the associated key press | 1405 // the keyboard shortcut for the command by sending the associated key press |
1400 // to windows. The real fix to this bug is to disable the commands when they | 1406 // to windows. The real fix to this bug is to disable the commands when they |
1401 // won't do anything. We'll need something like an overall clipboard command | 1407 // won't do anything. We'll need something like an overall clipboard command |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2589 } | 2595 } |
2590 | 2596 |
2591 extensions::ActiveTabPermissionGranter* | 2597 extensions::ActiveTabPermissionGranter* |
2592 BrowserView::GetActiveTabPermissionGranter() { | 2598 BrowserView::GetActiveTabPermissionGranter() { |
2593 content::WebContents* web_contents = GetActiveWebContents(); | 2599 content::WebContents* web_contents = GetActiveWebContents(); |
2594 if (!web_contents) | 2600 if (!web_contents) |
2595 return nullptr; | 2601 return nullptr; |
2596 return extensions::TabHelper::FromWebContents(web_contents) | 2602 return extensions::TabHelper::FromWebContents(web_contents) |
2597 ->active_tab_permission_granter(); | 2603 ->active_tab_permission_granter(); |
2598 } | 2604 } |
OLD | NEW |