Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: ash/test/child_modal_window.h

Issue 2733883003: Makes ChildModalWindow not leak (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/test/child_modal_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef ASH_TEST_CHILD_MODAL_WINDOW_H_ 5 #ifndef ASH_TEST_CHILD_MODAL_WINDOW_H_
6 #define ASH_TEST_CHILD_MODAL_WINDOW_H_ 6 #define ASH_TEST_CHILD_MODAL_WINDOW_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "ui/views/controls/button/button.h" 11 #include "ui/views/controls/button/button.h"
10 #include "ui/views/widget/widget_delegate.h" 12 #include "ui/views/widget/widget_delegate.h"
11 #include "ui/views/widget/widget_observer.h" 13 #include "ui/views/widget/widget_observer.h"
12 14
13 namespace views { 15 namespace views {
14 class LabelButton; 16 class LabelButton;
15 class NativeViewHost; 17 class NativeViewHost;
16 class Textfield; 18 class Textfield;
17 class View; 19 class View;
18 class Widget; 20 class Widget;
19 } 21 }
20 22
21 namespace ash { 23 namespace ash {
22 namespace test { 24 namespace test {
23 25
24 void CreateChildModalParent(gfx::NativeView context); 26 void CreateChildModalParent(aura::Window* context);
25 27
26 class ChildModalParent : public views::WidgetDelegateView, 28 class ChildModalParent : public views::WidgetDelegateView,
27 public views::ButtonListener, 29 public views::ButtonListener,
28 public views::WidgetObserver { 30 public views::WidgetObserver {
29 public: 31 public:
30 ChildModalParent(gfx::NativeView context); 32 ChildModalParent(aura::Window* context);
31 ~ChildModalParent() override; 33 ~ChildModalParent() override;
32 34
33 void ShowChild(); 35 void ShowChild();
34 gfx::NativeWindow GetModalParent() const; 36 aura::Window* GetModalParent() const;
35 gfx::NativeWindow GetChild() const; 37 aura::Window* GetChild() const;
36 38
37 private: 39 private:
38 views::Widget* CreateChild(); 40 views::Widget* CreateChild();
39 41
40 // Overridden from views::WidgetDelegate: 42 // Overridden from views::WidgetDelegate:
41 base::string16 GetWindowTitle() const override; 43 base::string16 GetWindowTitle() const override;
42 bool CanResize() const override; 44 bool CanResize() const override;
43 void DeleteDelegate() override; 45 void DeleteDelegate() override;
44 46
45 // Overridden from views::View: 47 // Overridden from views::View:
46 void Layout() override; 48 void Layout() override;
47 void ViewHierarchyChanged( 49 void ViewHierarchyChanged(
48 const ViewHierarchyChangedDetails& details) override; 50 const ViewHierarchyChangedDetails& details) override;
49 51
50 // Overridden from ButtonListener: 52 // Overridden from ButtonListener:
51 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 53 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
52 54
53 // Overridden from WidgetObserver: 55 // Overridden from WidgetObserver:
54 void OnWidgetDestroying(views::Widget* widget) override; 56 void OnWidgetDestroying(views::Widget* widget) override;
55 57
58 // This is the Widget this class creates to contain the child Views. This
59 // class is *not* the WidgetDelegateView for this Widget.
60 std::unique_ptr<views::Widget> widget_;
61
56 // The button to toggle showing and hiding the child window. The child window 62 // The button to toggle showing and hiding the child window. The child window
57 // does not block input to this button. 63 // does not block input to this button.
58 views::LabelButton* button_; 64 views::LabelButton* button_;
59 65
60 // The text field to indicate the keyboard focus. 66 // The text field to indicate the keyboard focus.
61 views::Textfield* textfield_; 67 views::Textfield* textfield_;
62 68
63 // The host for the modal parent. 69 // The host for the modal parent.
64 views::NativeViewHost* host_; 70 views::NativeViewHost* host_;
65 71
66 // The modal parent of the child window. The child window blocks input to this
67 // view.
68 gfx::NativeWindow modal_parent_;
69
70 // The child window. 72 // The child window.
71 views::Widget* child_; 73 views::Widget* child_;
72 74
73 DISALLOW_COPY_AND_ASSIGN(ChildModalParent); 75 DISALLOW_COPY_AND_ASSIGN(ChildModalParent);
74 }; 76 };
75 77
76 } // namespace test 78 } // namespace test
77 } // namespace ash 79 } // namespace ash
78 80
79 #endif // ASH_TEST_CHILD_MODAL_WINDOW_H_ 81 #endif // ASH_TEST_CHILD_MODAL_WINDOW_H_
OLDNEW
« no previous file with comments | « no previous file | ash/test/child_modal_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698