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

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

Issue 838253004: MacViews: Fix duplicate definition of ExtensionKeyBindingRegistry::SetShortcutHandlingSuspended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DragBookmarks2
Patch Set: Observe widget to cleanup event monitor Created 5 years, 11 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1368
1369 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 1369 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
1370 bool* is_keyboard_shortcut) { 1370 bool* is_keyboard_shortcut) {
1371 *is_keyboard_shortcut = false; 1371 *is_keyboard_shortcut = false;
1372 1372
1373 if ((event.type != blink::WebInputEvent::RawKeyDown) && 1373 if ((event.type != blink::WebInputEvent::RawKeyDown) &&
1374 (event.type != blink::WebInputEvent::KeyUp)) { 1374 (event.type != blink::WebInputEvent::KeyUp)) {
1375 return false; 1375 return false;
1376 } 1376 }
1377 1377
1378 views::FocusManager* focus_manager = GetFocusManager();
1379 DCHECK(focus_manager);
1380
1381 if (focus_manager->shortcut_handling_suspended())
1382 return false;
1383
1384 ui::Accelerator accelerator = 1378 ui::Accelerator accelerator =
1385 ui::GetAcceleratorFromNativeWebKeyboardEvent(event); 1379 ui::GetAcceleratorFromNativeWebKeyboardEvent(event);
1386 1380
1387 // What we have to do here is as follows: 1381 // What we have to do here is as follows:
1388 // - If the |browser_| is for an app, do nothing. 1382 // - If the |browser_| is for an app, do nothing.
1389 // - If the |browser_| is not for an app, and the |accelerator| is not 1383 // - If the |browser_| is not for an app, and the |accelerator| is not
1390 // associated with the browser (e.g. an Ash shortcut), process it. 1384 // associated with the browser (e.g. an Ash shortcut), process it.
1391 // - If the |browser_| is not for an app, and the |accelerator| is associated 1385 // - If the |browser_| is not for an app, and the |accelerator| is associated
1392 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it. 1386 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it.
1393 // - If the |browser_| is not for an app, and the |accelerator| is associated 1387 // - If the |browser_| is not for an app, and the |accelerator| is associated
(...skipping 13 matching lines...) Expand all
1407 // keyboard event. Instead of looking up the command id in the 1401 // keyboard event. Instead of looking up the command id in the
1408 // |accelerator_table_| by ourselves, we block the command execution of 1402 // |accelerator_table_| by ourselves, we block the command execution of
1409 // the |browser_| object then send the keyboard event to the 1403 // the |browser_| object then send the keyboard event to the
1410 // |focus_manager| as if we are activating an accelerator key. 1404 // |focus_manager| as if we are activating an accelerator key.
1411 // Then we can retrieve the command id from the |browser_| object. 1405 // Then we can retrieve the command id from the |browser_| object.
1412 bool original_block_command_state = controller->block_command_execution(); 1406 bool original_block_command_state = controller->block_command_execution();
1413 controller->SetBlockCommandExecution(true); 1407 controller->SetBlockCommandExecution(true);
1414 // If the |accelerator| is a non-browser shortcut (e.g. Ash shortcut), the 1408 // If the |accelerator| is a non-browser shortcut (e.g. Ash shortcut), the
1415 // command execution cannot be blocked and true is returned. However, it is 1409 // command execution cannot be blocked and true is returned. However, it is
1416 // okay as long as is_app() is false. See comments in this function. 1410 // okay as long as is_app() is false. See comments in this function.
1411 views::FocusManager* focus_manager = GetFocusManager();
1412 DCHECK(focus_manager);
1417 const bool processed = focus_manager->ProcessAccelerator(accelerator); 1413 const bool processed = focus_manager->ProcessAccelerator(accelerator);
1418 const int id = controller->GetLastBlockedCommand(nullptr); 1414 const int id = controller->GetLastBlockedCommand(nullptr);
1419 controller->SetBlockCommandExecution(original_block_command_state); 1415 controller->SetBlockCommandExecution(original_block_command_state);
1420 1416
1421 // Executing the command may cause |this| object to be destroyed. 1417 // Executing the command may cause |this| object to be destroyed.
1422 if (controller->IsReservedCommandOrKey(id, event)) { 1418 if (controller->IsReservedCommandOrKey(id, event)) {
1423 UpdateAcceleratorMetrics(accelerator, id); 1419 UpdateAcceleratorMetrics(accelerator, id);
1424 return chrome::ExecuteCommand(browser_.get(), id); 1420 return chrome::ExecuteCommand(browser_.get(), id);
1425 } 1421 }
1426 1422
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2564 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2569 gfx::Point icon_bottom( 2565 gfx::Point icon_bottom(
2570 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2566 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2571 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2567 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2572 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr)); 2568 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr));
2573 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2569 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2574 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2570 top_arrow_height = infobar_top.y() - icon_bottom.y();
2575 } 2571 }
2576 return top_arrow_height; 2572 return top_arrow_height;
2577 } 2573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698