OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 return true; | 681 return true; |
682 } | 682 } |
683 return false; | 683 return false; |
684 } | 684 } |
685 | 685 |
686 bool BrowserView::GetAccelerator(int cmd_id, menus::Accelerator* accelerator) { | 686 bool BrowserView::GetAccelerator(int cmd_id, menus::Accelerator* accelerator) { |
687 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 687 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
688 // anywhere so we need to check for them explicitly here. | 688 // anywhere so we need to check for them explicitly here. |
689 switch (cmd_id) { | 689 switch (cmd_id) { |
690 case IDC_CUT: | 690 case IDC_CUT: |
691 *accelerator = views::Accelerator(app::VKEY_X, false, true, false); | 691 *accelerator = views::Accelerator(base::VKEY_X, false, true, false); |
692 return true; | 692 return true; |
693 case IDC_COPY: | 693 case IDC_COPY: |
694 *accelerator = views::Accelerator(app::VKEY_C, false, true, false); | 694 *accelerator = views::Accelerator(base::VKEY_C, false, true, false); |
695 return true; | 695 return true; |
696 case IDC_PASTE: | 696 case IDC_PASTE: |
697 *accelerator = views::Accelerator(app::VKEY_V, false, true, false); | 697 *accelerator = views::Accelerator(base::VKEY_V, false, true, false); |
698 return true; | 698 return true; |
699 } | 699 } |
700 // Else, we retrieve the accelerator information from the accelerator table. | 700 // Else, we retrieve the accelerator information from the accelerator table. |
701 std::map<views::Accelerator, int>::iterator it = | 701 std::map<views::Accelerator, int>::iterator it = |
702 accelerator_table_.begin(); | 702 accelerator_table_.begin(); |
703 for (; it != accelerator_table_.end(); ++it) { | 703 for (; it != accelerator_table_.end(); ++it) { |
704 if (it->second == cmd_id) { | 704 if (it->second == cmd_id) { |
705 *accelerator = it->first; | 705 *accelerator = it->first; |
706 return true; | 706 return true; |
707 } | 707 } |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 } | 1286 } |
1287 | 1287 |
1288 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1288 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
1289 bool* is_keyboard_shortcut) { | 1289 bool* is_keyboard_shortcut) { |
1290 if (event.type != WebKit::WebInputEvent::RawKeyDown) | 1290 if (event.type != WebKit::WebInputEvent::RawKeyDown) |
1291 return false; | 1291 return false; |
1292 | 1292 |
1293 #if defined(OS_WIN) | 1293 #if defined(OS_WIN) |
1294 // As Alt+F4 is the close-app keyboard shortcut, it needs processing | 1294 // As Alt+F4 is the close-app keyboard shortcut, it needs processing |
1295 // immediately. | 1295 // immediately. |
1296 if (event.windowsKeyCode == app::VKEY_F4 && | 1296 if (event.windowsKeyCode == base::VKEY_F4 && |
1297 event.modifiers == NativeWebKeyboardEvent::AltKey) { | 1297 event.modifiers == NativeWebKeyboardEvent::AltKey) { |
1298 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 1298 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
1299 event.os_event.wParam, event.os_event.lParam); | 1299 event.os_event.wParam, event.os_event.lParam); |
1300 return true; | 1300 return true; |
1301 } | 1301 } |
1302 #endif | 1302 #endif |
1303 | 1303 |
1304 views::FocusManager* focus_manager = GetFocusManager(); | 1304 views::FocusManager* focus_manager = GetFocusManager(); |
1305 DCHECK(focus_manager); | 1305 DCHECK(focus_manager); |
1306 | 1306 |
1307 views::Accelerator accelerator( | 1307 views::Accelerator accelerator( |
1308 static_cast<app::KeyboardCode>(event.windowsKeyCode), | 1308 static_cast<base::KeyboardCode>(event.windowsKeyCode), |
1309 (event.modifiers & NativeWebKeyboardEvent::ShiftKey) == | 1309 (event.modifiers & NativeWebKeyboardEvent::ShiftKey) == |
1310 NativeWebKeyboardEvent::ShiftKey, | 1310 NativeWebKeyboardEvent::ShiftKey, |
1311 (event.modifiers & NativeWebKeyboardEvent::ControlKey) == | 1311 (event.modifiers & NativeWebKeyboardEvent::ControlKey) == |
1312 NativeWebKeyboardEvent::ControlKey, | 1312 NativeWebKeyboardEvent::ControlKey, |
1313 (event.modifiers & NativeWebKeyboardEvent::AltKey) == | 1313 (event.modifiers & NativeWebKeyboardEvent::AltKey) == |
1314 NativeWebKeyboardEvent::AltKey); | 1314 NativeWebKeyboardEvent::AltKey); |
1315 | 1315 |
1316 // We first find out the browser command associated to the |event|. | 1316 // We first find out the browser command associated to the |event|. |
1317 // Then if the command is a reserved one, and should be processed | 1317 // Then if the command is a reserved one, and should be processed |
1318 // immediately according to the |event|, the command will be executed | 1318 // immediately according to the |event|, the command will be executed |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 | 1364 |
1365 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1365 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
1366 // enabled in the page menu regardless of whether the command will do | 1366 // enabled in the page menu regardless of whether the command will do |
1367 // anything. When someone selects the menu item, we just act as if they hit | 1367 // anything. When someone selects the menu item, we just act as if they hit |
1368 // the keyboard shortcut for the command by sending the associated key press | 1368 // the keyboard shortcut for the command by sending the associated key press |
1369 // to windows. The real fix to this bug is to disable the commands when they | 1369 // to windows. The real fix to this bug is to disable the commands when they |
1370 // won't do anything. We'll need something like an overall clipboard command | 1370 // won't do anything. We'll need something like an overall clipboard command |
1371 // manager to do that. | 1371 // manager to do that. |
1372 #if !defined(OS_MACOSX) | 1372 #if !defined(OS_MACOSX) |
1373 void BrowserView::Cut() { | 1373 void BrowserView::Cut() { |
1374 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_X, | 1374 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_X, |
1375 true, false, false, false); | 1375 true, false, false, false); |
1376 } | 1376 } |
1377 | 1377 |
1378 void BrowserView::Copy() { | 1378 void BrowserView::Copy() { |
1379 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_C, | 1379 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, |
1380 true, false, false, false); | 1380 true, false, false, false); |
1381 } | 1381 } |
1382 | 1382 |
1383 void BrowserView::Paste() { | 1383 void BrowserView::Paste() { |
1384 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_V, | 1384 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, |
1385 true, false, false, false); | 1385 true, false, false, false); |
1386 } | 1386 } |
1387 #else | 1387 #else |
1388 // Mac versions. Not tested by antyhing yet; | 1388 // Mac versions. Not tested by antyhing yet; |
1389 // don't assume written == works. | 1389 // don't assume written == works. |
1390 void BrowserView::Cut() { | 1390 void BrowserView::Cut() { |
1391 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_X, | 1391 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_X, |
1392 false, false, false, true); | 1392 false, false, false, true); |
1393 } | 1393 } |
1394 | 1394 |
1395 void BrowserView::Copy() { | 1395 void BrowserView::Copy() { |
1396 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_C, | 1396 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, |
1397 false, false, false, true); | 1397 false, false, false, true); |
1398 } | 1398 } |
1399 | 1399 |
1400 void BrowserView::Paste() { | 1400 void BrowserView::Paste() { |
1401 ui_controls::SendKeyPress(GetNativeHandle(), app::VKEY_V, | 1401 ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, |
1402 false, false, false, true); | 1402 false, false, false, true); |
1403 } | 1403 } |
1404 #endif | 1404 #endif |
1405 | 1405 |
1406 void BrowserView::ToggleTabStripMode() { | 1406 void BrowserView::ToggleTabStripMode() { |
1407 InitTabStrip(browser_->tabstrip_model()); | 1407 InitTabStrip(browser_->tabstrip_model()); |
1408 frame_->TabStripDisplayModeChanged(); | 1408 frame_->TabStripDisplayModeChanged(); |
1409 } | 1409 } |
1410 | 1410 |
1411 /////////////////////////////////////////////////////////////////////////////// | 1411 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 | 2297 |
2298 views::FocusManager* focus_manager = GetFocusManager(); | 2298 views::FocusManager* focus_manager = GetFocusManager(); |
2299 DCHECK(focus_manager); | 2299 DCHECK(focus_manager); |
2300 | 2300 |
2301 // Let's fill our own accelerator table. | 2301 // Let's fill our own accelerator table. |
2302 for (int i = 0; i < count; ++i) { | 2302 for (int i = 0; i < count; ++i) { |
2303 bool alt_down = (accelerators[i].fVirt & FALT) == FALT; | 2303 bool alt_down = (accelerators[i].fVirt & FALT) == FALT; |
2304 bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL; | 2304 bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL; |
2305 bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT; | 2305 bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT; |
2306 views::Accelerator accelerator( | 2306 views::Accelerator accelerator( |
2307 static_cast<app::KeyboardCode>(accelerators[i].key), | 2307 static_cast<base::KeyboardCode>(accelerators[i].key), |
2308 shift_down, ctrl_down, alt_down); | 2308 shift_down, ctrl_down, alt_down); |
2309 accelerator_table_[accelerator] = accelerators[i].cmd; | 2309 accelerator_table_[accelerator] = accelerators[i].cmd; |
2310 | 2310 |
2311 // Also register with the focus manager. | 2311 // Also register with the focus manager. |
2312 focus_manager->RegisterAccelerator(accelerator, this); | 2312 focus_manager->RegisterAccelerator(accelerator, this); |
2313 } | 2313 } |
2314 | 2314 |
2315 // We don't need the Windows accelerator table anymore. | 2315 // We don't need the Windows accelerator table anymore. |
2316 free(accelerators); | 2316 free(accelerators); |
2317 #else | 2317 #else |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2524 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
2525 | 2525 |
2526 return view; | 2526 return view; |
2527 } | 2527 } |
2528 #endif | 2528 #endif |
2529 | 2529 |
2530 // static | 2530 // static |
2531 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2531 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2532 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2532 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2533 } | 2533 } |
OLD | NEW |