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 "chrome/browser/chromeos/input_method/hidable_area.h" | |
6 | |
7 #include "ui/views/layout/fill_layout.h" | |
8 | |
9 namespace chromeos { | |
10 namespace input_method { | |
11 | |
12 HidableArea::HidableArea() { | |
13 place_holder_.reset(new views::View); | |
14 place_holder_->set_owned_by_client(); // Won't own | |
15 | |
16 // Initially show nothing. | |
17 SetLayoutManager(new views::FillLayout); | |
18 AddChildView(place_holder_.get()); | |
19 } | |
20 | |
21 HidableArea::~HidableArea() { | |
22 } | |
23 | |
24 void HidableArea::SetContents(views::View* contents) { | |
25 contents_.reset(contents); | |
26 contents_->set_owned_by_client(); // Won't own | |
27 } | |
28 | |
29 void HidableArea::Show() { | |
30 if (contents_.get() && contents_->parent() != this) { | |
31 RemoveAllChildViews(false); // Don't delete child views. | |
32 AddChildView(contents_.get()); | |
33 } | |
34 } | |
35 | |
36 void HidableArea::Hide() { | |
37 if (IsShown()) { | |
38 RemoveAllChildViews(false); // Don't delete child views. | |
39 AddChildView(place_holder_.get()); | |
40 } | |
41 } | |
42 | |
43 bool HidableArea::IsShown() const { | |
44 return contents_.get() && contents_->parent() == this; | |
45 } | |
46 | |
47 } // namespace input_method | |
48 } // namespace chromeos | |
OLD | NEW |