OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_ANDROID_VIEW_ANDROID_H_ | 5 #ifndef UI_ANDROID_VIEW_ANDROID_H_ |
6 #define UI_ANDROID_VIEW_ANDROID_H_ | 6 #define UI_ANDROID_VIEW_ANDROID_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "ui/android/ui_android_export.h" | 12 #include "ui/android/ui_android_export.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 class Layer; | 15 class Layer; |
16 } | 16 } |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 | 19 |
20 class WindowAndroid; | 20 class WindowAndroid; |
21 | 21 |
22 // A simple container for a UI layer. | 22 // A simple container for a UI layer. |
23 // At the root of the hierarchy is a WindowAndroid. | 23 // At the root of the hierarchy is a WindowAndroid, when attached. |
24 // | |
25 class UI_ANDROID_EXPORT ViewAndroid { | 24 class UI_ANDROID_EXPORT ViewAndroid { |
26 public: | 25 public: |
27 // Used to construct a root view. | 26 // A ViewAndroid may have its own delegate or otherwise will |
28 ViewAndroid(const base::android::JavaRef<jobject>& delegate, | 27 // use the next available parent's delegate. |
29 WindowAndroid* root_window); | 28 ViewAndroid(const base::android::JavaRef<jobject>& delegate); |
30 | |
31 // Used to construct a child view. | |
32 ViewAndroid(); | 29 ViewAndroid(); |
33 ~ViewAndroid(); | 30 virtual ~ViewAndroid(); |
34 | 31 |
35 // Returns the window at the root of this hierarchy, or |null| | 32 // Returns the window at the root of this hierarchy, or |null| |
36 // if disconnected. | 33 // if disconnected. |
37 WindowAndroid* GetWindowAndroid() const; | 34 virtual WindowAndroid* GetWindowAndroid(); |
38 | |
39 // Set the root |WindowAndroid|. This is only valid for root | |
40 // nodes and must not be called for children. | |
41 void SetWindowAndroid(WindowAndroid* root_window); | |
42 | 35 |
43 // Returns the Java delegate for this view. This is used to delegate work | 36 // Returns the Java delegate for this view. This is used to delegate work |
44 // up to the embedding view (or the embedder that can deal with the | 37 // up to the embedding view (or the embedder that can deal with the |
45 // implementation details). | 38 // implementation details). |
46 const base::android::JavaRef<jobject>& GetViewAndroidDelegate() const; | 39 const base::android::JavaRef<jobject>& GetViewAndroidDelegate() const; |
47 | 40 |
48 // Used to return and set the layer for this view. May be |null|. | 41 // Used to return and set the layer for this view. May be |null|. |
49 cc::Layer* GetLayer() const; | 42 cc::Layer* GetLayer() const; |
50 void SetLayer(scoped_refptr<cc::Layer> layer); | 43 void SetLayer(scoped_refptr<cc::Layer> layer); |
51 | 44 |
52 // Add/remove this view as a child of another view. | 45 // Adds this view as a child of another view. |
53 void AddChild(ViewAndroid* child); | 46 void AddChild(ViewAndroid* child); |
| 47 |
| 48 // Detaches this view from its parent. |
| 49 void RemoveFromParent(); |
| 50 |
| 51 protected: |
| 52 ViewAndroid* parent_; |
| 53 |
| 54 private: |
54 void RemoveChild(ViewAndroid* child); | 55 void RemoveChild(ViewAndroid* child); |
55 | 56 |
56 private: | |
57 ViewAndroid* parent_; | |
58 std::list<ViewAndroid*> children_; | 57 std::list<ViewAndroid*> children_; |
59 WindowAndroid* window_; | |
60 scoped_refptr<cc::Layer> layer_; | 58 scoped_refptr<cc::Layer> layer_; |
61 base::android::ScopedJavaGlobalRef<jobject> delegate_; | 59 base::android::ScopedJavaGlobalRef<jobject> delegate_; |
62 | 60 |
63 DISALLOW_COPY_AND_ASSIGN(ViewAndroid); | 61 DISALLOW_COPY_AND_ASSIGN(ViewAndroid); |
64 }; | 62 }; |
65 | 63 |
66 } // namespace ui | 64 } // namespace ui |
67 | 65 |
68 #endif // UI_ANDROID_VIEW_ANDROID_H_ | 66 #endif // UI_ANDROID_VIEW_ANDROID_H_ |
OLD | NEW |