OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 "window_android.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_helper.h" |
| 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "jni/NativeWindow_jni.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 using base::android::AttachCurrentThread; |
| 15 using base::android::ScopedJavaLocalRef; |
| 16 |
| 17 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) |
| 18 : weak_java_window_(env, obj) { |
| 19 } |
| 20 |
| 21 void WindowAndroid::Destroy(JNIEnv* env, jobject obj) { |
| 22 delete this; |
| 23 } |
| 24 |
| 25 ScopedJavaLocalRef<jobject> WindowAndroid::GetJavaObject() { |
| 26 JNIEnv* env = AttachCurrentThread(); |
| 27 return weak_java_window_.get(env); |
| 28 } |
| 29 |
| 30 bool WindowAndroid::RegisterWindowAndroid(JNIEnv* env) { |
| 31 return RegisterNativesImpl(env); |
| 32 } |
| 33 |
| 34 WindowAndroid::~WindowAndroid() { |
| 35 } |
| 36 |
| 37 // ---------------------------------------------------------------------------- |
| 38 // Native JNI methods |
| 39 // ---------------------------------------------------------------------------- |
| 40 |
| 41 jint Init(JNIEnv* env, jobject obj) { |
| 42 WindowAndroid* window = new WindowAndroid(env, obj); |
| 43 return reinterpret_cast<jint>(window); |
| 44 } |
| 45 |
| 46 } // namespace ui |
OLD | NEW |