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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 65 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
66 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 66 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
68 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 68 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
70 #include "chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h" | 70 #include "chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h" |
71 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 71 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
72 #include "chrome/browser/ui/views/find_bar_host.h" | 72 #include "chrome/browser/ui/views/find_bar_host.h" |
73 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 73 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
74 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | 74 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" |
75 #include "chrome/browser/ui/views/frame/browser_view_platform.h" | |
75 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" | 76 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" |
76 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 77 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
77 #include "chrome/browser/ui/views/frame/top_container_view.h" | 78 #include "chrome/browser/ui/views/frame/top_container_view.h" |
78 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" | 79 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" |
79 #include "chrome/browser/ui/views/ime/ime_warning_bubble_view.h" | 80 #include "chrome/browser/ui/views/ime/ime_warning_bubble_view.h" |
80 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 81 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
81 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 82 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
82 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 83 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
83 #include "chrome/browser/ui/views/location_bar/star_view.h" | 84 #include "chrome/browser/ui/views/location_bar/star_view.h" |
84 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 85 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1410 } | 1411 } |
1411 | 1412 |
1412 #if defined(OS_CHROMEOS) | 1413 #if defined(OS_CHROMEOS) |
1413 if (chrome::IsAcceleratorDeprecated(accelerator)) { | 1414 if (chrome::IsAcceleratorDeprecated(accelerator)) { |
1414 if (event.type == blink::WebInputEvent::RawKeyDown) | 1415 if (event.type == blink::WebInputEvent::RawKeyDown) |
1415 *is_keyboard_shortcut = true; | 1416 *is_keyboard_shortcut = true; |
1416 return false; | 1417 return false; |
1417 } | 1418 } |
1418 #endif // defined(OS_CHROMEOS) | 1419 #endif // defined(OS_CHROMEOS) |
1419 | 1420 |
1421 if (BrowserViewPlatform::PreHandleKeyboardEvent(event, browser())) | |
tapted
2016/10/17 07:02:47
I'm not an owner here, but based on the surroundin
themblsha
2016/10/20 16:41:05
Thanks! Moved the code there.
| |
1422 return true; | |
1423 | |
1420 chrome::BrowserCommandController* controller = browser_->command_controller(); | 1424 chrome::BrowserCommandController* controller = browser_->command_controller(); |
1421 | 1425 |
1422 // Here we need to retrieve the command id (if any) associated to the | 1426 // 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 | 1427 // keyboard event. Instead of looking up the command id in the |
1424 // |accelerator_table_| by ourselves, we block the command execution of | 1428 // |accelerator_table_| by ourselves, we block the command execution of |
1425 // the |browser_| object then send the keyboard event to the | 1429 // the |browser_| object then send the keyboard event to the |
1426 // |focus_manager| as if we are activating an accelerator key. | 1430 // |focus_manager| as if we are activating an accelerator key. |
1427 // Then we can retrieve the command id from the |browser_| object. | 1431 // Then we can retrieve the command id from the |browser_| object. |
1428 bool original_block_command_state = controller->block_command_execution(); | 1432 bool original_block_command_state = controller->block_command_execution(); |
1429 controller->SetBlockCommandExecution(true); | 1433 controller->SetBlockCommandExecution(true); |
(...skipping 17 matching lines...) Expand all Loading... | |
1447 } else if (processed) { | 1451 } else if (processed) { |
1448 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report | 1452 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report |
1449 // that we handled it. | 1453 // that we handled it. |
1450 return true; | 1454 return true; |
1451 } | 1455 } |
1452 | 1456 |
1453 return false; | 1457 return false; |
1454 } | 1458 } |
1455 | 1459 |
1456 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1460 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
1461 if (BrowserViewPlatform::HandleKeyboardEvent(event, browser())) | |
1462 return; | |
1463 | |
1457 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 1464 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
tapted
2016/10/17 07:02:47
There is already a mac-specific UnhandledKeyboardE
themblsha
2016/10/20 16:41:05
Tried to do that: https://gist.github.com/mblsha/d
| |
1458 GetFocusManager()); | 1465 GetFocusManager()); |
1459 } | 1466 } |
1460 | 1467 |
1461 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1468 // 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 | 1469 // 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 | 1470 // 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 | 1471 // 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 | 1472 // 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 | 1473 // won't do anything. We'll need something like an overall clipboard command |
1467 // manager to do that. | 1474 // manager to do that. |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2655 } | 2662 } |
2656 | 2663 |
2657 extensions::ActiveTabPermissionGranter* | 2664 extensions::ActiveTabPermissionGranter* |
2658 BrowserView::GetActiveTabPermissionGranter() { | 2665 BrowserView::GetActiveTabPermissionGranter() { |
2659 content::WebContents* web_contents = GetActiveWebContents(); | 2666 content::WebContents* web_contents = GetActiveWebContents(); |
2660 if (!web_contents) | 2667 if (!web_contents) |
2661 return nullptr; | 2668 return nullptr; |
2662 return extensions::TabHelper::FromWebContents(web_contents) | 2669 return extensions::TabHelper::FromWebContents(web_contents) |
2663 ->active_tab_permission_granter(); | 2670 ->active_tab_permission_granter(); |
2664 } | 2671 } |
OLD | NEW |