OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/keyboard_overlay_dialog_view.h" | 5 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
9 #include "chrome/browser/ui/browser_dialogs.h" | 9 #include "chrome/browser/ui/browser_dialogs.h" |
10 #include "chrome/browser/ui/views/accelerator_table.h" | 10 #include "chrome/browser/ui/views/accelerator_table.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 bool alt_pressed; | 28 bool alt_pressed; |
29 } kCloseAccelerators[] = { | 29 } kCloseAccelerators[] = { |
30 {ui::VKEY_OEM_2, false, true, true}, | 30 {ui::VKEY_OEM_2, false, true, true}, |
31 {ui::VKEY_OEM_2, true, true, true}, | 31 {ui::VKEY_OEM_2, true, true, true}, |
32 {ui::VKEY_ESCAPE, true, false, false}, | 32 {ui::VKEY_ESCAPE, true, false, false}, |
33 }; | 33 }; |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 KeyboardOverlayDialogView::KeyboardOverlayDialogView( | 36 KeyboardOverlayDialogView::KeyboardOverlayDialogView( |
37 Profile* profile, | 37 Profile* profile, |
38 HtmlDialogUIDelegate* delegate, | 38 WebDialogDelegate* delegate, |
39 BrowserView* parent_view) | 39 BrowserView* parent_view) |
40 : HtmlDialogView(profile, parent_view->browser(), delegate), | 40 : WebDialogView(profile, parent_view->browser(), delegate), |
41 parent_view_(parent_view) { | 41 parent_view_(parent_view) { |
42 RegisterDialogAccelerators(); | 42 RegisterDialogAccelerators(); |
43 } | 43 } |
44 | 44 |
45 KeyboardOverlayDialogView::~KeyboardOverlayDialogView() { | 45 KeyboardOverlayDialogView::~KeyboardOverlayDialogView() { |
46 } | 46 } |
47 | 47 |
48 void KeyboardOverlayDialogView::RegisterDialogAccelerators() { | 48 void KeyboardOverlayDialogView::RegisterDialogAccelerators() { |
49 for (size_t i = 0; i < arraysize(kCloseAccelerators); ++i) { | 49 for (size_t i = 0; i < arraysize(kCloseAccelerators); ++i) { |
50 ui::Accelerator accelerator(kCloseAccelerators[i].keycode, | 50 ui::Accelerator accelerator(kCloseAccelerators[i].keycode, |
(...skipping 30 matching lines...) Expand all Loading... |
81 return true; | 81 return true; |
82 } | 82 } |
83 | 83 |
84 void KeyboardOverlayDialogView::ShowDialog( | 84 void KeyboardOverlayDialogView::ShowDialog( |
85 gfx::NativeWindow owning_window, BrowserView* parent_view) { | 85 gfx::NativeWindow owning_window, BrowserView* parent_view) { |
86 // Temporarily disable Shift+Alt. crosbug.com/17208. | 86 // Temporarily disable Shift+Alt. crosbug.com/17208. |
87 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); | 87 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); |
88 | 88 |
89 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( | 89 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( |
90 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); | 90 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); |
91 KeyboardOverlayDialogView* html_view = | 91 KeyboardOverlayDialogView* view = |
92 new KeyboardOverlayDialogView(parent_view->browser()->profile(), | 92 new KeyboardOverlayDialogView(parent_view->browser()->profile(), |
93 delegate, | 93 delegate, |
94 parent_view); | 94 parent_view); |
95 delegate->set_view(html_view); | 95 delegate->set_view(view); |
96 browser::CreateFramelessViewsWindow(owning_window, html_view); | 96 browser::CreateFramelessViewsWindow(owning_window, view); |
97 // Show the widget at the bottom of the work area. | 97 // Show the widget at the bottom of the work area. |
98 gfx::Size size; | 98 gfx::Size size; |
99 delegate->GetDialogSize(&size); | 99 delegate->GetDialogSize(&size); |
100 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( | 100 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( |
101 html_view->GetWidget()->GetNativeView()).work_area(); | 101 view->GetWidget()->GetNativeView()).work_area(); |
102 gfx::Rect bounds((rect.width() - size.width()) / 2, | 102 gfx::Rect bounds((rect.width() - size.width()) / 2, |
103 rect.height() - size.height(), | 103 rect.height() - size.height(), |
104 size.width(), | 104 size.width(), |
105 size.height()); | 105 size.height()); |
106 html_view->GetWidget()->SetBounds(bounds); | 106 view->GetWidget()->SetBounds(bounds); |
107 html_view->GetWidget()->Show(); | 107 view->GetWidget()->Show(); |
108 } | 108 } |
109 | 109 |
110 bool KeyboardOverlayDialogView::IsCloseAccelerator( | 110 bool KeyboardOverlayDialogView::IsCloseAccelerator( |
111 const ui::Accelerator& accelerator) { | 111 const ui::Accelerator& accelerator) { |
112 return close_accelerators_.find(accelerator) != close_accelerators_.end(); | 112 return close_accelerators_.find(accelerator) != close_accelerators_.end(); |
113 } | 113 } |
OLD | NEW |