1// Copyright 2014 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_TEST_CHILD_MODAL_WINDOW_H_
6#define ASH_TEST_CHILD_MODAL_WINDOW_H_
7
8#include "ui/views/controls/button/button.h"
9#include "ui/views/widget/widget_delegate.h"
10#include "ui/views/widget/widget_observer.h"
11
12namespace views {
13class LabelButton;
14class NativeViewHost;
15class Textfield;
16class View;
17class Widget;
18}
19
20namespace ash {
21namespace test {
22
23void CreateChildModalParent(gfx::NativeView context);
24
25class ChildModalParent : public views::WidgetDelegateView,
26                         public views::ButtonListener,
27                         public views::WidgetObserver {
28 public:
29  ChildModalParent(gfx::NativeView context);
30  virtual ~ChildModalParent();
31
32  void ShowChild();
33  gfx::NativeWindow GetModalParent() const;
34  gfx::NativeWindow GetChild() const;
35
36 private:
37  views::Widget* CreateChild();
38
39  // Overridden from views::WidgetDelegate:
40  virtual View* GetContentsView() OVERRIDE;
41  virtual base::string16 GetWindowTitle() const OVERRIDE;
42  virtual bool CanResize() const OVERRIDE;
43  virtual void DeleteDelegate() OVERRIDE;
44
45  // Overridden from views::View:
46  virtual void Layout() OVERRIDE;
47  virtual void ViewHierarchyChanged(
48      const ViewHierarchyChangedDetails& details) OVERRIDE;
49
50  // Overridden from ButtonListener:
51  virtual void ButtonPressed(views::Button* sender,
52                             const ui::Event& event) OVERRIDE;
53
54  // Overridden from WidgetObserver:
55  virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
56
57  // The button to toggle showing and hiding the child window. The child window
58  // does not block input to this button.
59  views::LabelButton* button_;
60
61  // The text field to indicate the keyboard focus.
62  views::Textfield* textfield_;
63
64  // The host for the modal parent.
65  views::NativeViewHost* host_;
66
67  // The modal parent of the child window. The child window blocks input to this
68  // view.
69  gfx::NativeWindow modal_parent_;
70
71  // The child window.
72  views::Widget* child_;
73
74  DISALLOW_COPY_AND_ASSIGN(ChildModalParent);
75};
76
77}  // namespace test
78}  // namespace ash
79
80#endif  // ASH_TEST_CHILD_MODAL_WINDOW_H_
81