Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1177773002: Deprecating high-conflict accelerators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified the design, modified tests accordingly, made accelerators consumable by webcontents if n… Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 DCHECK(focus_manager); 1396 DCHECK(focus_manager);
1397 1397
1398 if (focus_manager->shortcut_handling_suspended()) 1398 if (focus_manager->shortcut_handling_suspended())
1399 return false; 1399 return false;
1400 1400
1401 ui::Accelerator accelerator = 1401 ui::Accelerator accelerator =
1402 ui::GetAcceleratorFromNativeWebKeyboardEvent(event); 1402 ui::GetAcceleratorFromNativeWebKeyboardEvent(event);
1403 1403
1404 // What we have to do here is as follows: 1404 // What we have to do here is as follows:
1405 // - If the |browser_| is for an app, do nothing. 1405 // - If the |browser_| is for an app, do nothing.
1406 // - On CrOS if |accelerator| is deprecated, we allow web contents to consume
1407 // it if needed.
1406 // - If the |browser_| is not for an app, and the |accelerator| is not 1408 // - If the |browser_| is not for an app, and the |accelerator| is not
1407 // associated with the browser (e.g. an Ash shortcut), process it. 1409 // associated with the browser (e.g. an Ash shortcut), process it.
1408 // - If the |browser_| is not for an app, and the |accelerator| is associated 1410 // - If the |browser_| is not for an app, and the |accelerator| is associated
1409 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it. 1411 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it.
1410 // - If the |browser_| is not for an app, and the |accelerator| is associated 1412 // - If the |browser_| is not for an app, and the |accelerator| is associated
1411 // with the browser, and it is not a reserved one, do nothing. 1413 // with the browser, and it is not a reserved one, do nothing.
1412 1414
1413 if (browser_->is_app()) { 1415 if (browser_->is_app()) {
1414 // Let all keys fall through to a v1 app's web content, even accelerators. 1416 // Let all keys fall through to a v1 app's web content, even accelerators.
1415 // We don't have to flip |is_keyboard_shortcut| here. If we do that, the app 1417 // We don't have to flip |is_keyboard_shortcut| here. If we do that, the app
1416 // might not be able to see a subsequent Char event. See OnHandleInputEvent 1418 // might not be able to see a subsequent Char event. See OnHandleInputEvent
1417 // in content/renderer/render_widget.cc for details. 1419 // in content/renderer/render_widget.cc for details.
1418 return false; 1420 return false;
1419 } 1421 }
1420 1422
1423 #if defined(OS_CHROMEOS)
1424 if (focus_manager->IsAcceleratorDeprecated(accelerator)) {
1425 if (event.type == blink::WebInputEvent::RawKeyDown)
1426 *is_keyboard_shortcut = true;
1427 return false;
1428 }
1429 #endif // defined(OS_CHROMEOS)
1430
1421 chrome::BrowserCommandController* controller = browser_->command_controller(); 1431 chrome::BrowserCommandController* controller = browser_->command_controller();
1422 1432
1423 // Here we need to retrieve the command id (if any) associated to the 1433 // Here we need to retrieve the command id (if any) associated to the
1424 // keyboard event. Instead of looking up the command id in the 1434 // keyboard event. Instead of looking up the command id in the
1425 // |accelerator_table_| by ourselves, we block the command execution of 1435 // |accelerator_table_| by ourselves, we block the command execution of
1426 // the |browser_| object then send the keyboard event to the 1436 // the |browser_| object then send the keyboard event to the
1427 // |focus_manager| as if we are activating an accelerator key. 1437 // |focus_manager| as if we are activating an accelerator key.
1428 // Then we can retrieve the command id from the |browser_| object. 1438 // Then we can retrieve the command id from the |browser_| object.
1429 bool original_block_command_state = controller->block_command_execution(); 1439 bool original_block_command_state = controller->block_command_execution();
1430 controller->SetBlockCommandExecution(true); 1440 controller->SetBlockCommandExecution(true);
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 return immersive_mode_controller()->IsEnabled(); 2627 return immersive_mode_controller()->IsEnabled();
2618 } 2628 }
2619 2629
2620 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2630 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2621 return GetWidget(); 2631 return GetWidget();
2622 } 2632 }
2623 2633
2624 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2634 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2625 return top_container_->GetBoundsInScreen(); 2635 return top_container_->GetBoundsInScreen();
2626 } 2636 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698