diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 21:18:58 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 21:18:58 +0000 |
commit | d766882c913b272cc2db478d7640a317d838ebad (patch) | |
tree | 99424c7a994d0d771bd4c3bdf2b196042b937b62 /chrome/browser/views | |
parent | eb75208190b35bedd144e102ea5cc826358bbbfd (diff) | |
download | chromium_src-d766882c913b272cc2db478d7640a317d838ebad.zip chromium_src-d766882c913b272cc2db478d7640a317d838ebad.tar.gz chromium_src-d766882c913b272cc2db478d7640a317d838ebad.tar.bz2 |
Changing the KeyboardEvent to use a KeyboardCode instead of a w_char. Led to several places where I had to switch from VK_ to VKEY_.
Also cleaned-up the table view OnKeyDown method. Since TableView is a NativeControl it can use the NativeControl::OnKeyDown directly.
BUG=None
TEST=Make sure short-cuts works as expected, especially in the omnibox.
Review URL: http://codereview.chromium.org/248010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_host_browsertest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_host_interactive_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 12 | ||||
-rw-r--r-- | chrome/browser/views/fullscreen_exit_bubble.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/jsmessage_box_dialog.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/star_toggle.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/render_view_context_menu_win.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_win.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/task_manager_view.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 8 | ||||
-rw-r--r-- | chrome/browser/views/url_picker.cc | 3 |
13 files changed, 43 insertions, 26 deletions
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc index 313bc09..60ec1b9 100644 --- a/chrome/browser/views/bookmark_manager_view.cc +++ b/chrome/browser/views/bookmark_manager_view.cc @@ -9,6 +9,7 @@ #include "app/gfx/canvas.h" #include "app/gfx/color_utils.h" #include "app/l10n_util.h" +#include "base/keyboard_codes.h" #include "base/thread.h" #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" #include "chrome/browser/bookmarks/bookmark_html_writer.h" @@ -225,7 +226,7 @@ BookmarkManagerView::BookmarkManagerView(Profile* profile) layout->AddView(split_view_); // Press Ctrl-W to close bookmark manager window. - AddAccelerator(views::Accelerator('W', false, true, false)); + AddAccelerator(views::Accelerator(base::VKEY_W, false, true, false)); BookmarkModel* bookmark_model = profile_->GetBookmarkModel(); if (!bookmark_model->IsLoaded()) diff --git a/chrome/browser/views/find_bar_host_browsertest.cc b/chrome/browser/views/find_bar_host_browsertest.cc index 703a401..caed556 100644 --- a/chrome/browser/views/find_bar_host_browsertest.cc +++ b/chrome/browser/views/find_bar_host_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/keyboard_codes.h" #include "base/message_loop.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" @@ -590,7 +591,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { views::FocusManager::GetFocusManagerForNativeView(browser_view); // See where Escape is registered. - views::Accelerator escape(VK_ESCAPE, false, false, false); + views::Accelerator escape(base::VKEY_ESCAPE, false, false, false); views::AcceleratorTarget* old_target = focus_manager->GetCurrentTargetForAccelerator(escape); EXPECT_TRUE(old_target != NULL); diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc index 75f10d5..fe2cecd 100644 --- a/chrome/browser/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. +#include "base/keyboard_codes.h" #include "chrome/browser/view_ids.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/window_proxy.h" @@ -90,6 +91,6 @@ TEST_F(FindInPageTest, CrashEscHandlers) { EXPECT_EQ(VIEW_ID_LOCATION_BAR, focused_view_id); // This used to crash until bug 1303709 was fixed. - EXPECT_TRUE(window->SimulateOSKeyPress(VK_ESCAPE, 0)); + EXPECT_TRUE(window->SimulateOSKeyPress(base::VKEY_ESCAPE, 0)); ::Sleep(kActionDelayMs); } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index d4a0e8f..50fd3bd 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -10,6 +10,7 @@ #include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/command_line.h" +#include "base/keyboard_codes.h" #include "base/time.h" #include "build/build_config.h" #include "chrome/app/chrome_dll_resource.h" @@ -585,13 +586,13 @@ bool BrowserView::GetAccelerator(int cmd_id, views::Accelerator* accelerator) { // anywhere so we need to check for them explicitly here. switch (cmd_id) { case IDC_CUT: - *accelerator = views::Accelerator(L'X', false, true, false); + *accelerator = views::Accelerator(base::VKEY_X, false, true, false); return true; case IDC_COPY: - *accelerator = views::Accelerator(L'C', false, true, false); + *accelerator = views::Accelerator(base::VKEY_C, false, true, false); return true; case IDC_PASTE: - *accelerator = views::Accelerator(L'V', false, true, false); + *accelerator = views::Accelerator(base::VKEY_V, false, true, false); return true; } // Else, we retrieve the accelerator information from the accelerator table. @@ -1993,8 +1994,9 @@ void BrowserView::LoadAccelerators() { bool alt_down = (accelerators[i].fVirt & FALT) == FALT; bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL; bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT; - views::Accelerator accelerator(accelerators[i].key, shift_down, ctrl_down, - alt_down); + views::Accelerator accelerator( + static_cast<base::KeyboardCode>(accelerators[i].key), + shift_down, ctrl_down, alt_down); accelerator_table_[accelerator] = accelerators[i].cmd; // Also register with the focus manager. diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc index 907a791..b7e5705 100644 --- a/chrome/browser/views/fullscreen_exit_bubble.cc +++ b/chrome/browser/views/fullscreen_exit_bubble.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" +#include "base/keyboard_codes.h" #include "chrome/app/chrome_dll_resource.h" #include "grit/generated_resources.h" #include "views/widget/root_view.h" @@ -133,7 +134,7 @@ FullscreenExitBubble::FullscreenExitBubble( size_animation_->Reset(1); // Create the contents view. - views::Accelerator accelerator(0, false, false, false); + views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false); bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); DCHECK(got_accelerator); view_ = new FullscreenExitView(this, popup_, accelerator.GetShortcutText()); diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 40244ef..91a41a4 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -7,6 +7,7 @@ #include "app/gfx/canvas.h" #include "app/gfx/color_utils.h" #include "app/gfx/path.h" +#include "base/keyboard_codes.h" #include "chrome/browser/window_sizer.h" #include "chrome/common/notification_service.h" #include "third_party/skia/include/core/SkPaint.h" @@ -278,7 +279,7 @@ void InfoBubble::Init(views::Window* parent, #if defined(OS_WIN) // Register the Escape accelerator for closing. GetFocusManager()->RegisterAccelerator( - views::Accelerator(VK_ESCAPE, false, false, false), this); + views::Accelerator(base::VKEY_ESCAPE, false, false, false), this); #endif // Done creating the bubble. diff --git a/chrome/browser/views/jsmessage_box_dialog.cc b/chrome/browser/views/jsmessage_box_dialog.cc index df60f0f9..3fb70e0 100644 --- a/chrome/browser/views/jsmessage_box_dialog.cc +++ b/chrome/browser/views/jsmessage_box_dialog.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "app/message_box_flags.h" +#include "base/keyboard_codes.h" #include "chrome/browser/app_modal_dialog.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" @@ -25,7 +26,7 @@ JavascriptMessageBoxDialog::JavascriptMessageBoxDialog( DCHECK(message_box_view_); message_box_view_->AddAccelerator( - views::Accelerator('C', false, true, false)); + views::Accelerator(base::VKEY_C, false, true, false)); if (display_suppress_checkbox) { message_box_view_->SetCheckBoxLabel( l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); diff --git a/chrome/browser/views/star_toggle.cc b/chrome/browser/views/star_toggle.cc index 0e03f91..ebb67ac 100644 --- a/chrome/browser/views/star_toggle.cc +++ b/chrome/browser/views/star_toggle.cc @@ -6,6 +6,7 @@ #include "app/gfx/canvas.h" #include "app/resource_bundle.h" +#include "base/keyboard_codes.h" #include "chrome/app/chrome_dll_resource.h" #include "grit/theme_resources.h" @@ -63,7 +64,8 @@ void StarToggle::OnMouseReleased(const views::MouseEvent& e, } bool StarToggle::OnKeyPressed(const views::KeyEvent& e) { - if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) { + if ((e.GetKeyCode() == base::VKEY_SPACE) || + (e.GetKeyCode() == base::VKEY_RETURN)) { SwitchState(); return true; } diff --git a/chrome/browser/views/tab_contents/render_view_context_menu_win.cc b/chrome/browser/views/tab_contents/render_view_context_menu_win.cc index 63bbca6..a46174a 100644 --- a/chrome/browser/views/tab_contents/render_view_context_menu_win.cc +++ b/chrome/browser/views/tab_contents/render_view_context_menu_win.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/compiler_specific.h" +#include "base/keyboard_codes.h" #include "chrome/browser/profile.h" #include "grit/generated_resources.h" @@ -46,27 +47,28 @@ bool RenderViewContextMenuWin::GetAcceleratorForCommandId( // that Ctrl+C, Ctrl+V, Ctrl+X, Ctrl-A, etc do what they normally do. switch (command_id) { case IDS_CONTENT_CONTEXT_UNDO: - *accel = views::Accelerator(L'Z', false, true, false); + *accel = views::Accelerator(base::VKEY_Z, false, true, false); return true; case IDS_CONTENT_CONTEXT_REDO: - *accel = views::Accelerator(L'Z', true, true, false); + // TODO(jcampan): should it be Ctrl-Y? + *accel = views::Accelerator(base::VKEY_Z, true, true, false); return true; case IDS_CONTENT_CONTEXT_CUT: - *accel = views::Accelerator(L'X', false, true, false); + *accel = views::Accelerator(base::VKEY_X, false, true, false); return true; case IDS_CONTENT_CONTEXT_COPY: - *accel = views::Accelerator(L'C', false, true, false); + *accel = views::Accelerator(base::VKEY_C, false, true, false); return true; case IDS_CONTENT_CONTEXT_PASTE: - *accel = views::Accelerator(L'V', false, true, false); + *accel = views::Accelerator(base::VKEY_V, false, true, false); return true; case IDS_CONTENT_CONTEXT_SELECTALL: - *accel = views::Accelerator(L'A', false, true, false); + *accel = views::Accelerator(base::VKEY_A, false, true, false); return true; default: diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 22a1552..7352951 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -9,7 +9,9 @@ #include "app/gfx/canvas_paint.h" #include "app/os_exchange_data.h" #include "app/os_exchange_data_provider_win.h" +#include "base/keyboard_codes.h" #include "base/time.h" +#include "base/win_util.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. #include "chrome/browser/browser_process.h" @@ -403,7 +405,8 @@ void TabContentsViewWin::HandleKeyboardEvent( // We may not have a focus_manager at this point (if the tab has been // switched by the time this message returned). if (focus_manager) { - views::Accelerator accelerator(event.windowsKeyCode, + views::Accelerator accelerator( + win_util::WinToKeyboardCode(event.windowsKeyCode), (event.modifiers & WebInputEvent::ShiftKey) == WebInputEvent::ShiftKey, (event.modifiers & WebInputEvent::ControlKey) == diff --git a/chrome/browser/views/task_manager_view.cc b/chrome/browser/views/task_manager_view.cc index 5256b03..b41fbe1 100644 --- a/chrome/browser/views/task_manager_view.cc +++ b/chrome/browser/views/task_manager_view.cc @@ -334,7 +334,8 @@ void TaskManagerView::Init() { SetContextMenuController(this); kill_button_ = new views::NativeButton( this, l10n_util::GetString(IDS_TASK_MANAGER_KILL)); - kill_button_->AddAccelerator(views::Accelerator('E', false, false, false)); + kill_button_->AddAccelerator(views::Accelerator(base::VKEY_E, + false, false, false)); kill_button_->SetAccessibleKeyboardShortcut(L"E"); about_memory_link_ = new views::Link( l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK)); @@ -535,7 +536,7 @@ void TaskManagerView::OnDoubleClick() { } void TaskManagerView::OnKeyDown(unsigned short virtual_keycode) { - if (virtual_keycode == VK_RETURN) + if (virtual_keycode == base::VKEY_RETURN) ActivateFocusedTab(); } diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index d917804..81d006f 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -416,13 +416,13 @@ bool ToolbarView::GetAcceleratorForCommandId(int command_id, // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. switch (command_id) { case IDC_CUT: - *accelerator = views::Accelerator(L'X', false, true, false); + *accelerator = views::Accelerator(base::VKEY_X, false, true, false); return true; case IDC_COPY: - *accelerator = views::Accelerator(L'C', false, true, false); + *accelerator = views::Accelerator(base::VKEY_C, false, true, false); return true; case IDC_PASTE: - *accelerator = views::Accelerator(L'V', false, true, false); + *accelerator = views::Accelerator(base::VKEY_V, false, true, false); return true; } // Else, we retrieve the accelerator information from the frame. @@ -639,7 +639,7 @@ bool ToolbarView::OnKeyPressed(const views::KeyEvent& e) { int focused_view = GetChildIndex(acc_focused_view_); int next_view = focused_view; - switch (e.GetCharacter()) { + switch (e.GetKeyCode()) { case base::VKEY_LEFT: next_view = GetNextAccessibleViewIndex(focused_view, true); break; diff --git a/chrome/browser/views/url_picker.cc b/chrome/browser/views/url_picker.cc index e9837ff..5232676 100644 --- a/chrome/browser/views/url_picker.cc +++ b/chrome/browser/views/url_picker.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "app/table_model.h" #include "app/table_model_observer.h" +#include "base/keyboard_codes.h" #include "base/stl_util-inl.h" #include "base/string_util.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -130,7 +131,7 @@ UrlPicker::UrlPicker(UrlPickerDelegate* delegate, layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - AddAccelerator(views::Accelerator(VK_RETURN, false, false, false)); + AddAccelerator(views::Accelerator(base::VKEY_RETURN, false, false, false)); } UrlPicker::~UrlPicker() { |