blob: 9ceee0a5e437a49eec647c6931faad42838450bd [file] [log] [blame]
[email protected]f7c4c272013-10-31 07:36:001// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]74d96982013-04-23 07:36:402// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
jaekyune4f9eed2015-02-24 02:06:585#ifndef UI_ANDROID_VIEW_ANDROID_H_
6#define UI_ANDROID_VIEW_ANDROID_H_
[email protected]74d96982013-04-23 07:36:407
sieverse6343712016-07-11 22:35:308#include <list>
9
[email protected]74d96982013-04-23 07:36:4010#include "base/android/scoped_java_ref.h"
sieverse6343712016-07-11 22:35:3011#include "base/memory/ref_counted.h"
jaekyune4f9eed2015-02-24 02:06:5812#include "ui/android/ui_android_export.h"
[email protected]74d96982013-04-23 07:36:4013
sieverse6343712016-07-11 22:35:3014namespace cc {
15class Layer;
16}
17
[email protected]74d96982013-04-23 07:36:4018namespace ui {
19
20class WindowAndroid;
21
sieverse6343712016-07-11 22:35:3022// A simple container for a UI layer.
23// At the root of the hierarchy is a WindowAndroid.
24//
jaekyune4f9eed2015-02-24 02:06:5825class UI_ANDROID_EXPORT ViewAndroid {
[email protected]74d96982013-04-23 07:36:4026 public:
sieverse6343712016-07-11 22:35:3027 // Used to construct a root view.
28 ViewAndroid(const base::android::JavaRef<jobject>& delegate,
29 WindowAndroid* root_window);
[email protected]74d96982013-04-23 07:36:4030
sieverse6343712016-07-11 22:35:3031 // Used to construct a child view.
32 ViewAndroid();
33 ~ViewAndroid();
[email protected]74d96982013-04-23 07:36:4034
sieverse6343712016-07-11 22:35:3035 // 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]74d96982013-04-23 07:36:4064};
65
66} // namespace ui
67
jaekyune4f9eed2015-02-24 02:06:5868#endif // UI_ANDROID_VIEW_ANDROID_H_