| 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" |
| 11 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h" | 11 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h" |
| 12 #include "chrome/browser/ui/webui/web_dialog_delegate.h" | 12 #include "chrome/browser/ui/webui/web_dialog_delegate.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 | 17 |
| 18 KeyboardOverlayDialogView::KeyboardOverlayDialogView( | 18 KeyboardOverlayDialogView::KeyboardOverlayDialogView( |
| 19 Profile* profile, | 19 Profile* profile, |
| 20 WebDialogDelegate* delegate) | 20 WebDialogDelegate* delegate) |
| 21 : WebDialogView(profile, NULL, delegate) { | 21 : WebDialogView(profile, NULL, delegate) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 KeyboardOverlayDialogView::~KeyboardOverlayDialogView() { | 24 KeyboardOverlayDialogView::~KeyboardOverlayDialogView() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 void KeyboardOverlayDialogView::ShowDialog() { | 27 void KeyboardOverlayDialogView::ShowDialog() { |
| 28 | |
| 29 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( | 28 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( |
| 30 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); | 29 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); |
| 31 KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView( | 30 KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView( |
| 32 ProfileManager::GetDefaultProfileOrOffTheRecord(), delegate); | 31 ProfileManager::GetDefaultProfileOrOffTheRecord(), delegate); |
| 33 delegate->set_view(view); | 32 delegate->Show(view); |
| 34 | |
| 35 views::Widget* widget = new views::Widget; | |
| 36 views::Widget::InitParams params( | |
| 37 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
| 38 params.delegate = view; | |
| 39 widget->Init(params); | |
| 40 | |
| 41 // Show the widget at the bottom of the work area. | |
| 42 gfx::Size size; | |
| 43 delegate->GetDialogSize(&size); | |
| 44 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( | |
| 45 view->GetWidget()->GetNativeView()).work_area(); | |
| 46 gfx::Rect bounds((rect.width() - size.width()) / 2, | |
| 47 rect.height() - size.height(), | |
| 48 size.width(), | |
| 49 size.height()); | |
| 50 view->GetWidget()->SetBounds(bounds); | |
| 51 view->GetWidget()->Show(); | |
| 52 } | 33 } |
| OLD | NEW |