Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: ui/platform_window/android/platform_window_android.cc

Issue 1455793005: Adding a way to associate Android Activities with PlatformWindowAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@auraclank_upstream_native_widget
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/platform_window/android/platform_window_android.h" 5 #include "ui/platform_window/android/platform_window_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 JNIEnv* env = base::android::AttachCurrentThread(); 65 JNIEnv* env = base::android::AttachCurrentThread();
66 Java_PlatformWindowAndroid_detach( 66 Java_PlatformWindowAndroid_detach(
67 env, java_platform_window_android_.get(env).obj()); 67 env, java_platform_window_android_.get(env).obj());
68 } 68 }
69 } 69 }
70 70
71 void PlatformWindowAndroid::Destroy(JNIEnv* env, jobject obj) { 71 void PlatformWindowAndroid::Destroy(JNIEnv* env, jobject obj) {
72 delegate_->OnClosed(); 72 delegate_->OnClosed();
73 } 73 }
74 74
75 void PlatformWindowAndroid::JavaPlatformWindowCreated(
76 JNIEnv* env, jobject obj) {
77 java_platform_window_android_ = JavaObjectWeakGlobalRef(env, obj);
78 }
79
75 void PlatformWindowAndroid::SurfaceCreated(JNIEnv* env, 80 void PlatformWindowAndroid::SurfaceCreated(JNIEnv* env,
76 jobject obj, 81 jobject obj,
77 jobject jsurface, 82 jobject jsurface,
78 float device_pixel_ratio) { 83 float device_pixel_ratio) {
79 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); 84 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface);
80 // Note: This ensures that any local references used by 85 // Note: This ensures that any local references used by
81 // ANativeWindow_fromSurface are released immediately. This is needed as a 86 // ANativeWindow_fromSurface are released immediately. This is needed as a
82 // workaround for https://code.google.com/p/android/issues/detail?id=68174 87 // workaround for https://code.google.com/p/android/issues/detail?id=68174
83 { 88 {
84 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); 89 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 150
146 void PlatformWindowAndroid::ReleaseWindow() { 151 void PlatformWindowAndroid::ReleaseWindow() {
147 ANativeWindow_release(window_); 152 ANativeWindow_release(window_);
148 window_ = NULL; 153 window_ = NULL;
149 } 154 }
150 155
151 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
152 // PlatformWindowAndroid, PlatformWindow implementation: 157 // PlatformWindowAndroid, PlatformWindow implementation:
153 158
154 void PlatformWindowAndroid::Show() { 159 void PlatformWindowAndroid::Show() {
155 if (!java_platform_window_android_.is_empty()) 160 CHECK(!java_platform_window_android_.is_empty());
156 return;
157 JNIEnv* env = base::android::AttachCurrentThread();
158 java_platform_window_android_ = JavaObjectWeakGlobalRef(
159 env, Java_PlatformWindowAndroid_createForActivity(
160 env, base::android::GetApplicationContext(),
161 reinterpret_cast<jlong>(this),
162 reinterpret_cast<jlong>(&platform_ime_controller_)).obj());
163 } 161 }
164 162
165 void PlatformWindowAndroid::Hide() { 163 void PlatformWindowAndroid::Hide() {
166 // Nothing to do. View is always visible. 164 // Nothing to do. View is always visible.
167 } 165 }
168 166
169 void PlatformWindowAndroid::Close() { 167 void PlatformWindowAndroid::Close() {
170 delegate_->OnCloseRequest(); 168 delegate_->OnCloseRequest();
171 } 169 }
172 170
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 214
217 void PlatformWindowAndroid::ConfineCursorToBounds(const gfx::Rect& bounds) { 215 void PlatformWindowAndroid::ConfineCursorToBounds(const gfx::Rect& bounds) {
218 NOTIMPLEMENTED(); 216 NOTIMPLEMENTED();
219 } 217 }
220 218
221 PlatformImeController* PlatformWindowAndroid::GetPlatformImeController() { 219 PlatformImeController* PlatformWindowAndroid::GetPlatformImeController() {
222 return &platform_ime_controller_; 220 return &platform_ime_controller_;
223 } 221 }
224 222
225 } // namespace ui 223 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698