| 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::JavaParamRef; | 20 using base::android::JavaParamRef; |
| 21 using base::android::JavaRef; | |
| 22 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
| 23 | 22 |
| 24 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { | 23 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { |
| 25 java_window_.Reset(env, obj); | 24 java_window_.Reset(env, obj); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void WindowAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 27 void WindowAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 29 delete this; | 28 delete this; |
| 30 } | 29 } |
| 31 | 30 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 137 } |
| 139 | 138 |
| 140 bool WindowAndroid::CanRequestPermission(const std::string& permission) { | 139 bool WindowAndroid::CanRequestPermission(const std::string& permission) { |
| 141 JNIEnv* env = AttachCurrentThread(); | 140 JNIEnv* env = AttachCurrentThread(); |
| 142 return Java_WindowAndroid_canRequestPermission( | 141 return Java_WindowAndroid_canRequestPermission( |
| 143 env, | 142 env, |
| 144 GetJavaObject().obj(), | 143 GetJavaObject().obj(), |
| 145 base::android::ConvertUTF8ToJavaString(env, permission).obj()); | 144 base::android::ConvertUTF8ToJavaString(env, permission).obj()); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void WindowAndroid::StartDragAndDrop( | |
| 149 const JavaRef<jobject>& jview_android_delegate, | |
| 150 const JavaRef<jstring>& jtext, | |
| 151 const JavaRef<jobject>& jimage) { | |
| 152 JNIEnv* env = AttachCurrentThread(); | |
| 153 Java_WindowAndroid_startDragAndDrop(env, GetJavaObject().obj(), | |
| 154 jview_android_delegate.obj(), jtext.obj(), | |
| 155 jimage.obj()); | |
| 156 } | |
| 157 | |
| 158 WindowAndroid* WindowAndroid::GetWindowAndroid() const { | 147 WindowAndroid* WindowAndroid::GetWindowAndroid() const { |
| 159 DCHECK(parent_ == nullptr); | 148 DCHECK(parent_ == nullptr); |
| 160 return const_cast<WindowAndroid*>(this); | 149 return const_cast<WindowAndroid*>(this); |
| 161 } | 150 } |
| 162 | 151 |
| 163 // ---------------------------------------------------------------------------- | 152 // ---------------------------------------------------------------------------- |
| 164 // Native JNI methods | 153 // Native JNI methods |
| 165 // ---------------------------------------------------------------------------- | 154 // ---------------------------------------------------------------------------- |
| 166 | 155 |
| 167 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 156 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 168 WindowAndroid* window = new WindowAndroid(env, obj); | 157 WindowAndroid* window = new WindowAndroid(env, obj); |
| 169 return reinterpret_cast<intptr_t>(window); | 158 return reinterpret_cast<intptr_t>(window); |
| 170 } | 159 } |
| 171 | 160 |
| 172 } // namespace ui | 161 } // namespace ui |
| OLD | NEW |