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 <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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 immersive_mode_controller_->GetRevealedLock( | 1287 immersive_mode_controller_->GetRevealedLock( |
1288 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 1288 ImmersiveModeController::ANIMATE_REVEAL_NO)); |
1289 | 1289 |
1290 toolbar_->app_menu()->Activate(); | 1290 toolbar_->app_menu()->Activate(); |
1291 } | 1291 } |
1292 | 1292 |
1293 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1293 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
1294 bool* is_keyboard_shortcut) { | 1294 bool* is_keyboard_shortcut) { |
1295 *is_keyboard_shortcut = false; | 1295 *is_keyboard_shortcut = false; |
1296 | 1296 |
1297 if ((event.type != WebKit::WebInputEvent::RawKeyDown) && | 1297 if ((event.type != blink::WebInputEvent::RawKeyDown) && |
1298 (event.type != WebKit::WebInputEvent::KeyUp)) { | 1298 (event.type != blink::WebInputEvent::KeyUp)) { |
1299 return false; | 1299 return false; |
1300 } | 1300 } |
1301 | 1301 |
1302 #if defined(OS_WIN) && !defined(USE_AURA) | 1302 #if defined(OS_WIN) && !defined(USE_AURA) |
1303 // As Alt+F4 is the close-app keyboard shortcut, it needs processing | 1303 // As Alt+F4 is the close-app keyboard shortcut, it needs processing |
1304 // immediately. | 1304 // immediately. |
1305 if (event.windowsKeyCode == ui::VKEY_F4 && | 1305 if (event.windowsKeyCode == ui::VKEY_F4 && |
1306 event.type == WebKit::WebInputEvent::RawKeyDown && | 1306 event.type == blink::WebInputEvent::RawKeyDown && |
1307 event.modifiers == NativeWebKeyboardEvent::AltKey) { | 1307 event.modifiers == NativeWebKeyboardEvent::AltKey) { |
1308 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 1308 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
1309 event.os_event.wParam, event.os_event.lParam); | 1309 event.os_event.wParam, event.os_event.lParam); |
1310 return true; | 1310 return true; |
1311 } | 1311 } |
1312 #endif | 1312 #endif |
1313 | 1313 |
1314 views::FocusManager* focus_manager = GetFocusManager(); | 1314 views::FocusManager* focus_manager = GetFocusManager(); |
1315 DCHECK(focus_manager); | 1315 DCHECK(focus_manager); |
1316 | 1316 |
1317 if (focus_manager->shortcut_handling_suspended()) | 1317 if (focus_manager->shortcut_handling_suspended()) |
1318 return false; | 1318 return false; |
1319 | 1319 |
1320 ui::Accelerator accelerator( | 1320 ui::Accelerator accelerator( |
1321 static_cast<ui::KeyboardCode>(event.windowsKeyCode), | 1321 static_cast<ui::KeyboardCode>(event.windowsKeyCode), |
1322 content::GetModifiersFromNativeWebKeyboardEvent(event)); | 1322 content::GetModifiersFromNativeWebKeyboardEvent(event)); |
1323 if (event.type == WebKit::WebInputEvent::KeyUp) | 1323 if (event.type == blink::WebInputEvent::KeyUp) |
1324 accelerator.set_type(ui::ET_KEY_RELEASED); | 1324 accelerator.set_type(ui::ET_KEY_RELEASED); |
1325 | 1325 |
1326 // What we have to do here is as follows: | 1326 // What we have to do here is as follows: |
1327 // - If the |browser_| is for an app, do nothing. | 1327 // - If the |browser_| is for an app, do nothing. |
1328 // - If the |browser_| is not for an app, and the |accelerator| is not | 1328 // - If the |browser_| is not for an app, and the |accelerator| is not |
1329 // associated with the browser (e.g. an Ash shortcut), process it. | 1329 // associated with the browser (e.g. an Ash shortcut), process it. |
1330 // - If the |browser_| is not for an app, and the |accelerator| is associated | 1330 // - If the |browser_| is not for an app, and the |accelerator| is associated |
1331 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it. | 1331 // with the browser, and it is a reserved one (e.g. Ctrl+w), process it. |
1332 // - If the |browser_| is not for an app, and the |accelerator| is associated | 1332 // - If the |browser_| is not for an app, and the |accelerator| is associated |
1333 // with the browser, and it is not a reserved one, do nothing. | 1333 // with the browser, and it is not a reserved one, do nothing. |
(...skipping 24 matching lines...) Expand all Loading... |
1358 controller->SetBlockCommandExecution(original_block_command_state); | 1358 controller->SetBlockCommandExecution(original_block_command_state); |
1359 | 1359 |
1360 // Executing the command may cause |this| object to be destroyed. | 1360 // Executing the command may cause |this| object to be destroyed. |
1361 if (controller->IsReservedCommandOrKey(id, event)) { | 1361 if (controller->IsReservedCommandOrKey(id, event)) { |
1362 UpdateAcceleratorMetrics(accelerator, id); | 1362 UpdateAcceleratorMetrics(accelerator, id); |
1363 return chrome::ExecuteCommand(browser_.get(), id); | 1363 return chrome::ExecuteCommand(browser_.get(), id); |
1364 } | 1364 } |
1365 | 1365 |
1366 if (id != -1) { | 1366 if (id != -1) { |
1367 // |accelerator| is a non-reserved browser shortcut (e.g. Ctrl+f). | 1367 // |accelerator| is a non-reserved browser shortcut (e.g. Ctrl+f). |
1368 if (event.type == WebKit::WebInputEvent::RawKeyDown) | 1368 if (event.type == blink::WebInputEvent::RawKeyDown) |
1369 *is_keyboard_shortcut = true; | 1369 *is_keyboard_shortcut = true; |
1370 } else if (processed) { | 1370 } else if (processed) { |
1371 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report | 1371 // |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report |
1372 // that we handled it. | 1372 // that we handled it. |
1373 return true; | 1373 return true; |
1374 } | 1374 } |
1375 | 1375 |
1376 return false; | 1376 return false; |
1377 } | 1377 } |
1378 | 1378 |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 // The +1 in the next line creates a 1-px gap between icon and arrow tip. | 2722 // The +1 in the next line creates a 1-px gap between icon and arrow tip. |
2723 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - | 2723 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - |
2724 LocationBarView::kIconInternalPadding + 1); | 2724 LocationBarView::kIconInternalPadding + 1); |
2725 ConvertPointToTarget(location_icon_view, this, &icon_bottom); | 2725 ConvertPointToTarget(location_icon_view, this, &icon_bottom); |
2726 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2726 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2727 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2727 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2728 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2728 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2729 } | 2729 } |
2730 return top_arrow_height; | 2730 return top_arrow_height; |
2731 } | 2731 } |
OLD | NEW |