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()); | |
Ted C
2015/11/05 23:15:58
DeviceDisplayInfo seems very tied to the applicati
gsennton
2015/11/06 16:52:14
Right, so the idea would be to no longer hold on t
Ted C
2015/11/25 19:35:52
Again, I don't know what the lifecycles of either
gsennton
2015/12/02 15:37:05
Looking at this again, I don't think we should hol
Ted C
2015/12/03 04:23:56
I think the best approach in many of these cases w
boliu
2015/12/08 08:21:54
+1
gsennton
2015/12/10 12:29:54
Yeah, the idea with this patch is to only add the
| |
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() { | |
AKV
2015/11/04 14:20:48
DCHECK(device_display_info_) ?
boliu
2015/12/08 08:21:54
or just make device_display_info_ const
gsennton
2015/12/10 12:29:54
I don't think we want to make it const since it sh
boliu
2015/12/10 16:38:20
Pointer can be const, pointee (?) don't need to be
gsennton
2015/12/14 18:10:32
Done.
| |
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 |