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

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: correctly open browser if no one is present Created 5 years, 3 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 23 matching lines...) Expand all
34 #include "chrome/browser/profiles/profile_manager.h" 34 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/browser/profiles/profile_window.h" 35 #include "chrome/browser/profiles/profile_window.h"
36 #include "chrome/browser/profiles/profiles_state.h" 36 #include "chrome/browser/profiles/profiles_state.h"
37 #include "chrome/browser/search/search.h" 37 #include "chrome/browser/search/search.h"
38 #include "chrome/browser/sessions/tab_restore_service.h" 38 #include "chrome/browser/sessions/tab_restore_service.h"
39 #include "chrome/browser/sessions/tab_restore_service_factory.h" 39 #include "chrome/browser/sessions/tab_restore_service_factory.h"
40 #include "chrome/browser/signin/chrome_signin_helper.h" 40 #include "chrome/browser/signin/chrome_signin_helper.h"
41 #include "chrome/browser/themes/theme_properties.h" 41 #include "chrome/browser/themes/theme_properties.h"
42 #include "chrome/browser/themes/theme_service_factory.h" 42 #include "chrome/browser/themes/theme_service_factory.h"
43 #include "chrome/browser/translate/chrome_translate_client.h" 43 #include "chrome/browser/translate/chrome_translate_client.h"
44 #include "chrome/browser/ui/ash/ash_util.h"
44 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 45 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
45 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" 46 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
46 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" 47 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
47 #include "chrome/browser/ui/browser.h" 48 #include "chrome/browser/ui/browser.h"
48 #include "chrome/browser/ui/browser_command_controller.h" 49 #include "chrome/browser/ui/browser_command_controller.h"
49 #include "chrome/browser/ui/browser_commands.h" 50 #include "chrome/browser/ui/browser_commands.h"
50 #include "chrome/browser/ui/browser_dialogs.h" 51 #include "chrome/browser/ui/browser_dialogs.h"
51 #include "chrome/browser/ui/browser_finder.h" 52 #include "chrome/browser/ui/browser_finder.h"
52 #include "chrome/browser/ui/browser_list.h" 53 #include "chrome/browser/ui/browser_list.h"
53 #include "chrome/browser/ui/browser_window_state.h" 54 #include "chrome/browser/ui/browser_window_state.h"
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 DCHECK(focus_manager); 1401 DCHECK(focus_manager);
1401 1402
1402 if (focus_manager->shortcut_handling_suspended()) 1403 if (focus_manager->shortcut_handling_suspended())
1403 return false; 1404 return false;
1404 1405
1405 ui::Accelerator accelerator = 1406 ui::Accelerator accelerator =
1406 ui::GetAcceleratorFromNativeWebKeyboardEvent(event); 1407 ui::GetAcceleratorFromNativeWebKeyboardEvent(event);
1407 1408
1408 // What we have to do here is as follows: 1409 // What we have to do here is as follows:
1409 // - If the |browser_| is for an app, do nothing. 1410 // - If the |browser_| is for an app, do nothing.
1411 // - On CrOS if |accelerator| is deprecated, we allow web contents to consume
1412 // it if needed.
1410 // - If the |browser_| is not for an app, and the |accelerator| is not 1413 // - If the |browser_| is not for an app, and the |accelerator| is not
1411 // associated with the browser (e.g. an Ash shortcut), process it. 1414 // associated with the browser (e.g. an Ash shortcut), process it.
1412 // - If the |browser_| is not for an app, and the |accelerator| is associated 1415 // - If the |browser_| is not for an app, and the |accelerator| is associated
1413 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it. 1416 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it.
1414 // - If the |browser_| is not for an app, and the |accelerator| is associated 1417 // - If the |browser_| is not for an app, and the |accelerator| is associated
1415 // with the browser, and it is not a reserved one, do nothing. 1418 // with the browser, and it is not a reserved one, do nothing.
1416 1419
1417 if (browser_->is_app()) { 1420 if (browser_->is_app()) {
1418 // Let all keys fall through to a v1 app's web content, even accelerators. 1421 // Let all keys fall through to a v1 app's web content, even accelerators.
1419 // We don't have to flip |is_keyboard_shortcut| here. If we do that, the app 1422 // We don't have to flip |is_keyboard_shortcut| here. If we do that, the app
1420 // might not be able to see a subsequent Char event. See OnHandleInputEvent 1423 // might not be able to see a subsequent Char event. See OnHandleInputEvent
1421 // in content/renderer/render_widget.cc for details. 1424 // in content/renderer/render_widget.cc for details.
1422 return false; 1425 return false;
1423 } 1426 }
1424 1427
1428 #if defined(OS_CHROMEOS)
1429 if (chrome::IsAcceleratorDeprecated(accelerator)) {
1430 if (event.type == blink::WebInputEvent::RawKeyDown)
1431 *is_keyboard_shortcut = true;
1432 return false;
1433 }
1434 #endif // defined(OS_CHROMEOS)
1435
1425 chrome::BrowserCommandController* controller = browser_->command_controller(); 1436 chrome::BrowserCommandController* controller = browser_->command_controller();
1426 1437
1427 // Here we need to retrieve the command id (if any) associated to the 1438 // Here we need to retrieve the command id (if any) associated to the
1428 // keyboard event. Instead of looking up the command id in the 1439 // keyboard event. Instead of looking up the command id in the
1429 // |accelerator_table_| by ourselves, we block the command execution of 1440 // |accelerator_table_| by ourselves, we block the command execution of
1430 // the |browser_| object then send the keyboard event to the 1441 // the |browser_| object then send the keyboard event to the
1431 // |focus_manager| as if we are activating an accelerator key. 1442 // |focus_manager| as if we are activating an accelerator key.
1432 // Then we can retrieve the command id from the |browser_| object. 1443 // Then we can retrieve the command id from the |browser_| object.
1433 bool original_block_command_state = controller->block_command_execution(); 1444 bool original_block_command_state = controller->block_command_execution();
1434 controller->SetBlockCommandExecution(true); 1445 controller->SetBlockCommandExecution(true);
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 return immersive_mode_controller()->IsEnabled(); 2613 return immersive_mode_controller()->IsEnabled();
2603 } 2614 }
2604 2615
2605 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2616 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2606 return GetWidget(); 2617 return GetWidget();
2607 } 2618 }
2608 2619
2609 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2620 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2610 return top_container_->GetBoundsInScreen(); 2621 return top_container_->GetBoundsInScreen();
2611 } 2622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698