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
3 // found in the LICENSE file.
5 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
6 #define MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/memory/weak_ptr.h"
11 #include "mojo/services/native_viewport/native_viewport.h"
12 #include "mojo/services/native_viewport/native_viewport_export.h"
13 #include "ui/events/event_constants.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/sequential_id_generator.h"
16 #include "ui/gfx/size.h"
19 class GLInProcessContext
;
27 class MOJO_NATIVE_VIEWPORT_EXPORT NativeViewportAndroid
28 : public NativeViewport
{
30 static MOJO_NATIVE_VIEWPORT_EXPORT
bool Register(JNIEnv
* env
);
32 explicit NativeViewportAndroid(shell::Context
* context
,
33 NativeViewportDelegate
* delegate
);
34 virtual ~NativeViewportAndroid();
36 void Destroy(JNIEnv
* env
, jobject obj
);
37 void SurfaceCreated(JNIEnv
* env
, jobject obj
, jobject jsurface
);
38 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
);
39 void SurfaceSetSize(JNIEnv
* env
, jobject obj
, jint width
, jint height
);
40 bool TouchEvent(JNIEnv
* env
, jobject obj
, jint pointer_id
, jint action
,
41 jfloat x
, jfloat y
, jlong time_ms
);
44 // Overridden from NativeViewport:
45 virtual void Init(const gfx::Rect
& bounds
) OVERRIDE
;
46 virtual void Show() OVERRIDE
;
47 virtual void Hide() OVERRIDE
;
48 virtual void Close() OVERRIDE
;
49 virtual gfx::Size
GetSize() OVERRIDE
;
50 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
51 virtual void SetCapture() OVERRIDE
;
52 virtual void ReleaseCapture() OVERRIDE
;
56 NativeViewportDelegate
* delegate_
;
57 shell::Context
* context_
;
58 ANativeWindow
* window_
;
60 ui::SequentialIDGenerator id_generator_
;
62 base::WeakPtrFactory
<NativeViewportAndroid
> weak_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(NativeViewportAndroid
);
68 } // namespace services
71 #endif // MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_