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

Side by Side Diff: ui/gfx/android/window_android.cc

Issue 10916160: Upstreaming SelectFileDialog for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yaron's nits Created 8 years, 3 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "window_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_helper.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "jni/NativeWindow_jni.h"
11
12 namespace ui {
13
14 using base::android::AttachCurrentThread;
15 using base::android::ScopedJavaLocalRef;
16
17 struct WindowAndroid::JavaObject {
18 jweak obj_;
19 ScopedJavaLocalRef<jobject> WindowAndroid(JNIEnv* env) {
sky 2012/09/13 16:24:04 Generally structs shouldn't have methods.
aurimas (slooooooooow) 2012/09/14 00:06:59 Done.
20 return GetRealObject(env, obj_);
21 }
22 };
23
24 WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) {
25 java_object_ = new JavaObject;
26 java_object_->obj_ = env->NewWeakGlobalRef(obj);
27 }
28
29 WindowAndroid::~WindowAndroid() {
30 if (java_object_->obj_) {
31 JNIEnv* env = AttachCurrentThread();
32 env->DeleteWeakGlobalRef(java_object_->obj_);
33 java_object_->obj_ = 0;
sky 2012/09/13 16:24:04 NULL
aurimas (slooooooooow) 2012/09/14 00:06:59 Done.
34 }
35 delete java_object_;
36 }
37
38 void WindowAndroid::Destroy(JNIEnv* env, jobject obj) {
39 delete this;
sky 2012/09/13 16:24:04 If this is the only way to delte 'this' then make
aurimas (slooooooooow) 2012/09/14 00:06:59 Done.
40 }
41
42 ScopedJavaLocalRef<jobject> WindowAndroid::GetJavaObject() {
43 JNIEnv* env = AttachCurrentThread();
44 return GetRealObject(env, java_object_->obj_);
45 }
46
47 bool WindowAndroid::RegisterWindowAndroid(JNIEnv* env) {
48 return RegisterNativesImpl(env);
49 }
50
51
52 // ----------------------------------------------------------------------------
53 // Native JNI methods
54 // ----------------------------------------------------------------------------
55
56 jint Init(JNIEnv* env, jobject obj) {
57 WindowAndroid* window = new WindowAndroid(env, obj);
58 return reinterpret_cast<jint>(window);
59 }
60
61 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698