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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
44 // Temporarily disable all accelerators for IME switching including Shift+Alt | 44 // Temporarily disable all accelerators for IME switching including Shift+Alt |
45 // since the user might press Shift+Alt to remember an accelerator that starts | 45 // since the user might press Shift+Alt to remember an accelerator that starts |
46 // with Shift+Alt (e.g. Shift+Alt+Tab for moving focus backwards). | 46 // with Shift+Alt (e.g. Shift+Alt+Tab for moving focus backwards). |
47 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); | 47 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); |
48 #endif | 48 #endif |
49 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( | 49 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( |
50 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); | 50 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); |
51 KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView( | 51 KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView( |
52 ProfileManager::GetDefaultProfileOrOffTheRecord(), delegate); | 52 ProfileManager::GetDefaultProfileOrOffTheRecord(), delegate); |
53 delegate->set_view(view); | 53 delegate->Show(view); |
54 | |
55 views::Widget* widget = new views::Widget; | |
56 views::Widget::InitParams params( | |
57 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
58 params.delegate = view; | |
59 widget->Init(params); | |
60 | |
61 // Show the widget at the bottom of the work area. | |
62 gfx::Size size; | |
63 delegate->GetDialogSize(&size); | |
64 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( | |
65 view->GetWidget()->GetNativeView()).work_area(); | |
66 gfx::Rect bounds((rect.width() - size.width()) / 2, | |
67 rect.height() - size.height(), | |
68 size.width(), | |
69 size.height()); | |
70 view->GetWidget()->SetBounds(bounds); | |
71 view->GetWidget()->Show(); | |
72 | 54 |
73 g_instance = view; | 55 g_instance = view; |
74 } | 56 } |
75 | 57 |
76 void KeyboardOverlayDialogView::WindowClosing() { | 58 void KeyboardOverlayDialogView::WindowClosing() { |
77 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
78 // Re-enable the IME accelerators. See the comment in ShowDialog() above. | 60 // Re-enable the IME accelerators. See the comment in ShowDialog() above. |
79 chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys(); | 61 chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys(); |
80 #endif | 62 #endif |
81 g_instance = NULL; | 63 g_instance = NULL; |
82 } | 64 } |
OLD | NEW |