OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/keyboard_overlay/keyboard_overlay_view.h" |
| 6 |
| 7 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" |
| 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/public/browser/browser_context.h" |
| 10 #include "grit/ash_strings.h" |
| 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/gfx/screen.h" |
| 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 15 |
| 16 using ui::WebDialogDelegate; |
| 17 |
| 18 namespace { |
| 19 // Store the pointer to the view currently shown. |
| 20 KeyboardOverlayView* g_instance = NULL; |
| 21 } |
| 22 |
| 23 KeyboardOverlayView::KeyboardOverlayView( |
| 24 content::BrowserContext* context, |
| 25 WebDialogDelegate* delegate, |
| 26 WebContentsHandler* handler) |
| 27 : views::WebDialogView(context, delegate, handler) { |
| 28 } |
| 29 |
| 30 KeyboardOverlayView::~KeyboardOverlayView() { |
| 31 } |
| 32 |
| 33 void KeyboardOverlayView::ShowDialog( |
| 34 content::BrowserContext* context, |
| 35 WebContentsHandler* handler, |
| 36 const GURL& url) { |
| 37 // Ignore the call if another view is already shown. |
| 38 if (g_instance) |
| 39 return; |
| 40 |
| 41 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( |
| 42 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); |
| 43 KeyboardOverlayView* view = |
| 44 new KeyboardOverlayView(context, delegate, handler); |
| 45 delegate->Show(view); |
| 46 |
| 47 g_instance = view; |
| 48 } |
| 49 |
| 50 void KeyboardOverlayView::WindowClosing() { |
| 51 g_instance = NULL; |
| 52 } |
OLD | NEW |