Index: ui/android/view_android.h |
diff --git a/ui/android/view_android.h b/ui/android/view_android.h |
index 607a1acc72ae4dad10cfc8216cd5d76831b33c6f..2849109ead46b0eb33208a26a31dabdcd2373027 100644 |
--- a/ui/android/view_android.h |
+++ b/ui/android/view_android.h |
@@ -18,6 +18,7 @@ class Layer; |
namespace ui { |
+class EventHandler; |
class WindowAndroid; |
// A simple container for a UI layer. |
@@ -54,9 +55,14 @@ class UI_ANDROID_EXPORT ViewAndroid { |
// Default copy/assign disabled by move constructor. |
}; |
- // A ViewAndroid may have its own delegate or otherwise will |
- // use the next available parent's delegate. |
- ViewAndroid(const base::android::JavaRef<jobject>& delegate); |
+ // Client interface used to forward events from Java to native views. |
+ // Calls not handled by a client are dispatched to its children along |
+ // the hierarchy of ViewAndroid. Overriden method should return true |
+ // to indicate that the event was handled and stop the processing. |
+ class ViewClient { |
boliu
2016/12/02 23:53:22
put this in a separate file, presumably this will
Jinsuk Kim
2016/12/05 11:07:44
Done.
|
+ public: |
+ bool OnPhysicalBackingSizeChanged(int width, int height) { return false; } |
boliu
2016/12/02 23:53:22
virtual? also I think inlining virtual method is n
Jinsuk Kim
2016/12/05 11:07:44
Done.
|
+ }; |
ViewAndroid(); |
virtual ~ViewAndroid(); |
@@ -71,19 +77,28 @@ class UI_ANDROID_EXPORT ViewAndroid { |
void SetDelegate(const base::android::JavaRef<jobject>& delegate); |
+ EventHandler* GetEventHandler(); |
+ |
// Adds this view as a child of another view. |
void AddChild(ViewAndroid* child); |
// Detaches this view from its parent. |
void RemoveFromParent(); |
+ void SetViewClient(ViewClient* client) { client_ = client; } |
boliu
2016/12/02 23:53:22
can we pass this in on construction?
Jinsuk Kim
2016/12/05 11:07:44
Done.
|
+ |
bool StartDragAndDrop(const base::android::JavaRef<jstring>& jtext, |
const base::android::JavaRef<jobject>& jimage); |
+ gfx::Size GetPhysicalBackingSize(); |
+ |
ScopedAnchorView AcquireAnchorView(); |
void SetAnchorRect(const base::android::JavaRef<jobject>& anchor, |
const gfx::RectF& bounds); |
+ // Internal implementation of ViewClient forwarding calls to the interface. |
+ bool OnPhysicalBackingSizeChanged(int width, int height); |
+ |
protected: |
ViewAndroid* parent_; |
@@ -99,6 +114,8 @@ class UI_ANDROID_EXPORT ViewAndroid { |
std::list<ViewAndroid*> children_; |
scoped_refptr<cc::Layer> layer_; |
JavaObjectWeakGlobalRef delegate_; |
+ ViewClient* client_; |
+ EventHandler* handler_; |
DISALLOW_COPY_AND_ASSIGN(ViewAndroid); |
}; |