Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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. | |
| 4 | |
| 5 #include "ui/android/view_root.h" | |
| 6 | |
| 7 #include <jni.h> | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/android/jni_weak_ref.h" | |
| 12 #include "base/android/scoped_java_ref.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/observer_list.h" | |
| 15 #include "base/time/time.h" | |
| 16 #include "jni/ViewRoot_jni.h" | |
| 17 #include "ui/android/ui_android_export.h" | |
| 18 #include "ui/android/view_android.h" | |
| 19 #include "ui/gfx/geometry/vector2d_f.h" | |
| 20 | |
| 21 namespace ui { | |
| 22 | |
| 23 using base::android::JavaParamRef; | |
| 24 using base::android::JavaRef; | |
| 25 using base::android::ScopedJavaLocalRef; | |
| 26 | |
| 27 ViewRoot::ViewRoot(JNIEnv* env, | |
| 28 const base::android::JavaParamRef<jobject>& obj, | |
|
boliu
2017/01/05 19:09:29
don't these two params? then remember to mark cons
Jinsuk Kim
2017/01/05 22:30:16
Done.
| |
| 29 jlong jwindow_android) { | |
|
boliu
2017/01/05 19:09:29
nit: j prefix usually means a java type, that's no
Jinsuk Kim
2017/01/05 22:30:16
Done.
| |
| 30 WindowAndroid* window_android = | |
| 31 reinterpret_cast<WindowAndroid*>(jwindow_android); | |
| 32 window_ = window_android; | |
| 33 } | |
| 34 | |
| 35 void ViewRoot::Destroy(JNIEnv* env, | |
| 36 const base::android::JavaParamRef<jobject>& obj) { | |
| 37 delete this; | |
| 38 } | |
| 39 | |
| 40 ViewAndroid* ViewRoot::GetViewRoot() { | |
| 41 return this; | |
| 42 } | |
| 43 | |
| 44 WindowAndroid* ViewRoot::GetWindowAndroid() const { | |
| 45 return window_; | |
| 46 } | |
| 47 | |
| 48 // static | |
| 49 void ViewRoot::OnPhysicalBackingSizeChanged(JNIEnv* env, | |
| 50 const JavaParamRef<jobject>& jobj, | |
| 51 int width, | |
| 52 int height) { | |
| 53 OnPhysicalBackingSizeChangedInternal(width, height); | |
| 54 } | |
| 55 | |
| 56 // static | |
| 57 ViewRoot* ViewRoot::FromJavaObject(JNIEnv* env, | |
| 58 const JavaParamRef<jobject>& obj) { | |
| 59 if (obj.is_null()) | |
| 60 return nullptr; | |
| 61 return reinterpret_cast<ViewRoot*>(Java_ViewRoot_getNativePtr(env, obj)); | |
| 62 } | |
| 63 | |
| 64 // static | |
| 65 jlong Init(JNIEnv* env, | |
| 66 const JavaParamRef<jobject>& obj, | |
| 67 jlong window_android) { | |
| 68 return reinterpret_cast<intptr_t>(new ViewRoot(env, obj, window_android)); | |
| 69 } | |
| 70 | |
| 71 bool RegisterViewRoot(JNIEnv* env) { | |
| 72 return RegisterNativesImpl(env); | |
| 73 } | |
| 74 | |
| 75 } // namespace ui | |
| OLD | NEW |