Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ash / keyboard_overlay / keyboard_overlay_view.h
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 #ifndef ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_
6 #define ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_
7
8 #include <vector>
9
10 #include "ash/content_support/ash_with_content_export.h"
11 #include "ash/wm/overlay_event_filter.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "ui/views/controls/webview/web_dialog_view.h"
15
16 class GURL;
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 namespace ui {
23 class WebDialogDelegate;
24 }
25
26 namespace ash {
27
28 // A customized dialog view for the keyboard overlay.
29 class ASH_WITH_CONTENT_EXPORT KeyboardOverlayView
30     : public views::WebDialogView,
31       public ash::OverlayEventFilter::Delegate {
32  public:
33   struct KeyEventData {
34     ui::KeyboardCode key_code;
35     int flags;
36   };
37
38   KeyboardOverlayView(content::BrowserContext* context,
39                       ui::WebDialogDelegate* delegate,
40                       WebContentsHandler* handler);
41   ~KeyboardOverlayView() override;
42
43   // Overridden from ash::OverlayEventFilter::Delegate:
44   void Cancel() override;
45   bool IsCancelingKeyEvent(ui::KeyEvent* event) override;
46   aura::Window* GetWindow() override;
47
48   // Shows the keyboard overlay.
49   static void ShowDialog(content::BrowserContext* context,
50                          WebContentsHandler* handler,
51                          const GURL& url);
52
53  private:
54   FRIEND_TEST_ALL_PREFIXES(KeyboardOverlayViewTest, OpenAcceleratorsClose);
55   FRIEND_TEST_ALL_PREFIXES(KeyboardOverlayViewTest, NoRedundantCancelingKeys);
56
57   // Overridden from views::WidgetDelegate:
58   void WindowClosing() override;
59
60   static void GetCancelingKeysForTesting(
61       std::vector<KeyEventData>* canceling_keys);
62
63   DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayView);
64 };
65
66 }  // namespace ash
67
68 #endif  // ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_