| 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/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "jni/WindowAndroid_jni.h" | 12 #include "jni/WindowAndroid_jni.h" |
| 13 #include "ui/android/window_android_compositor.h" | 13 #include "ui/android/window_android_compositor.h" |
| 14 #include "ui/android/window_android_observer.h" | 14 #include "ui/android/window_android_observer.h" |
| 15 #include "ui/gfx/android/device_display_info.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 using base::android::AttachCurrentThread; | 19 using base::android::AttachCurrentThread; |
| 19 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
| 20 | 21 |
| 21 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { | 22 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) : compositor_(NULL) { |
| 22 java_window_.Reset(env, obj); | 23 java_window_.Reset(env, obj); |
| 24 // TODO(gsennton) have our device display info depend on our (java) display |
| 25 // context |
| 26 device_display_info_ = make_scoped_ptr(new gfx::DeviceDisplayInfo()); |
| 23 } | 27 } |
| 24 | 28 |
| 25 void WindowAndroid::Destroy(JNIEnv* env, jobject obj) { | 29 void WindowAndroid::Destroy(JNIEnv* env, jobject obj) { |
| 26 delete this; | 30 delete this; |
| 27 } | 31 } |
| 28 | 32 |
| 29 ScopedJavaLocalRef<jobject> WindowAndroid::GetJavaObject() { | 33 ScopedJavaLocalRef<jobject> WindowAndroid::GetJavaObject() { |
| 30 return base::android::ScopedJavaLocalRef<jobject>(java_window_); | 34 return base::android::ScopedJavaLocalRef<jobject>(java_window_); |
| 31 } | 35 } |
| 32 | 36 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 129 } |
| 126 | 130 |
| 127 bool WindowAndroid::CanRequestPermission(const std::string& permission) { | 131 bool WindowAndroid::CanRequestPermission(const std::string& permission) { |
| 128 JNIEnv* env = AttachCurrentThread(); | 132 JNIEnv* env = AttachCurrentThread(); |
| 129 return Java_WindowAndroid_canRequestPermission( | 133 return Java_WindowAndroid_canRequestPermission( |
| 130 env, | 134 env, |
| 131 GetJavaObject().obj(), | 135 GetJavaObject().obj(), |
| 132 base::android::ConvertUTF8ToJavaString(env, permission).obj()); | 136 base::android::ConvertUTF8ToJavaString(env, permission).obj()); |
| 133 } | 137 } |
| 134 | 138 |
| 139 const gfx::DeviceDisplayInfo& WindowAndroid::GetDeviceDisplayInfo() { |
| 140 return *device_display_info_; |
| 141 } |
| 142 |
| 135 // ---------------------------------------------------------------------------- | 143 // ---------------------------------------------------------------------------- |
| 136 // Native JNI methods | 144 // Native JNI methods |
| 137 // ---------------------------------------------------------------------------- | 145 // ---------------------------------------------------------------------------- |
| 138 | 146 |
| 139 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 147 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 140 WindowAndroid* window = new WindowAndroid(env, obj); | 148 WindowAndroid* window = new WindowAndroid(env, obj); |
| 141 return reinterpret_cast<intptr_t>(window); | 149 return reinterpret_cast<intptr_t>(window); |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace ui | 152 } // namespace ui |
| OLD | NEW |