| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/android/window_android.h" | 5 #include "ui/android/window_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/jni_weak_ref.h" | 11 #include "base/android/jni_weak_ref.h" |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "jni/WindowAndroid_jni.h" | 13 #include "jni/WindowAndroid_jni.h" |
| 14 #include "ui/android/window_android_compositor.h" | 14 #include "ui/android/window_android_compositor.h" |
| 15 #include "ui/android/window_android_observer.h" | 15 #include "ui/android/window_android_observer.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 using base::android::AttachCurrentThread; | 19 using base::android::AttachCurrentThread; |
| 20 using base::android::JavaRef; | |
| 21 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
| 22 | 21 |
| 23 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { | 22 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { |
| 24 java_window_.Reset(env, obj); | 23 java_window_.Reset(env, obj); |
| 25 } | 24 } |
| 26 | 25 |
| 27 void WindowAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 26 void WindowAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 28 delete this; | 27 delete this; |
| 29 } | 28 } |
| 30 | 29 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 136 } |
| 138 | 137 |
| 139 bool WindowAndroid::CanRequestPermission(const std::string& permission) { | 138 bool WindowAndroid::CanRequestPermission(const std::string& permission) { |
| 140 JNIEnv* env = AttachCurrentThread(); | 139 JNIEnv* env = AttachCurrentThread(); |
| 141 return Java_WindowAndroid_canRequestPermission( | 140 return Java_WindowAndroid_canRequestPermission( |
| 142 env, | 141 env, |
| 143 GetJavaObject().obj(), | 142 GetJavaObject().obj(), |
| 144 base::android::ConvertUTF8ToJavaString(env, permission).obj()); | 143 base::android::ConvertUTF8ToJavaString(env, permission).obj()); |
| 145 } | 144 } |
| 146 | 145 |
| 147 void WindowAndroid::StartDragAndDrop( | |
| 148 const JavaRef<jobject>& jview_android_delegate, | |
| 149 const JavaRef<jstring>& jtext, | |
| 150 const JavaRef<jobject>& jimage) { | |
| 151 JNIEnv* env = AttachCurrentThread(); | |
| 152 Java_WindowAndroid_startDragAndDrop(env, GetJavaObject().obj(), | |
| 153 jview_android_delegate.obj(), jtext.obj(), | |
| 154 jimage.obj()); | |
| 155 } | |
| 156 | |
| 157 WindowAndroid* WindowAndroid::GetWindowAndroid() const { | 146 WindowAndroid* WindowAndroid::GetWindowAndroid() const { |
| 158 DCHECK(parent_ == nullptr); | 147 DCHECK(parent_ == nullptr); |
| 159 return const_cast<WindowAndroid*>(this); | 148 return const_cast<WindowAndroid*>(this); |
| 160 } | 149 } |
| 161 | 150 |
| 162 // ---------------------------------------------------------------------------- | 151 // ---------------------------------------------------------------------------- |
| 163 // Native JNI methods | 152 // Native JNI methods |
| 164 // ---------------------------------------------------------------------------- | 153 // ---------------------------------------------------------------------------- |
| 165 | 154 |
| 166 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 155 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 167 WindowAndroid* window = new WindowAndroid(env, obj); | 156 WindowAndroid* window = new WindowAndroid(env, obj); |
| 168 return reinterpret_cast<intptr_t>(window); | 157 return reinterpret_cast<intptr_t>(window); |
| 169 } | 158 } |
| 170 | 159 |
| 171 } // namespace ui | 160 } // namespace ui |
| OLD | NEW |