[email protected] | f7c4c27 | 2013-10-31 07:36:00 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
jaekyun | e4f9eed | 2015-02-24 02:06:58 | [diff] [blame] | 5 | #ifndef UI_ANDROID_VIEW_ANDROID_H_ |
6 | #define UI_ANDROID_VIEW_ANDROID_H_ | ||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 7 | |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 8 | #include <list> |
9 | |||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 10 | #include "base/android/scoped_java_ref.h" |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
jaekyun | e4f9eed | 2015-02-24 02:06:58 | [diff] [blame] | 12 | #include "ui/android/ui_android_export.h" |
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 13 | |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 14 | namespace cc { |
15 | class Layer; | ||||
16 | } | ||||
17 | |||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 18 | namespace ui { |
19 | |||||
20 | class WindowAndroid; | ||||
21 | |||||
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 22 | // A simple container for a UI layer. |
23 | // At the root of the hierarchy is a WindowAndroid. | ||||
24 | // | ||||
jaekyun | e4f9eed | 2015-02-24 02:06:58 | [diff] [blame] | 25 | class UI_ANDROID_EXPORT ViewAndroid { |
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 26 | public: |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 27 | // Used to construct a root view. |
28 | ViewAndroid(const base::android::JavaRef<jobject>& delegate, | ||||
29 | WindowAndroid* root_window); | ||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 30 | |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 31 | // Used to construct a child view. |
32 | ViewAndroid(); | ||||
33 | ~ViewAndroid(); | ||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 34 | |
sievers | e634371 | 2016-07-11 22:35:30 | [diff] [blame] | 35 | // Returns the window at the root of this hierarchy, or |null| |
36 | // if disconnected. | ||||
37 | WindowAndroid* GetWindowAndroid() const; | ||||
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 | |||||
43 | // 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 | ||||
45 | // implementation details). | ||||
46 | const base::android::JavaRef<jobject>& GetViewAndroidDelegate() const; | ||||
47 | |||||
48 | // Used to return and set the layer for this view. May be |null|. | ||||
49 | cc::Layer* GetLayer() const; | ||||
50 | void SetLayer(scoped_refptr<cc::Layer> layer); | ||||
51 | |||||
52 | // Add/remove this view as a child of another view. | ||||
53 | void AddChild(ViewAndroid* child); | ||||
54 | void RemoveChild(ViewAndroid* child); | ||||
55 | |||||
56 | private: | ||||
57 | ViewAndroid* parent_; | ||||
58 | std::list<ViewAndroid*> children_; | ||||
59 | WindowAndroid* window_; | ||||
60 | scoped_refptr<cc::Layer> layer_; | ||||
61 | base::android::ScopedJavaGlobalRef<jobject> delegate_; | ||||
62 | |||||
63 | DISALLOW_COPY_AND_ASSIGN(ViewAndroid); | ||||
[email protected] | 74d9698 | 2013-04-23 07:36:40 | [diff] [blame] | 64 | }; |
65 | |||||
66 | } // namespace ui | ||||
67 | |||||
jaekyun | e4f9eed | 2015-02-24 02:06:58 | [diff] [blame] | 68 | #endif // UI_ANDROID_VIEW_ANDROID_H_ |