OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android
.h" | 5 #include "chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android
.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_helper.h" | 8 #include "base/android/jni_helper.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 bool AutoLoginInfoBarDelegateAndroid::Accept() { | 62 bool AutoLoginInfoBarDelegateAndroid::Accept() { |
63 JNIEnv* env = base::android::AttachCurrentThread(); | 63 JNIEnv* env = base::android::AttachCurrentThread(); |
64 ScopedJavaLocalRef<jobject> delegate = | 64 ScopedJavaLocalRef<jobject> delegate = |
65 weak_java_auto_login_delegate_.get(env); | 65 weak_java_auto_login_delegate_.get(env); |
66 DCHECK(delegate.obj()); | 66 DCHECK(delegate.obj()); |
67 Java_AutoLoginDelegate_logIn(env, delegate.obj(), | 67 Java_AutoLoginDelegate_logIn(env, delegate.obj(), |
68 reinterpret_cast<intptr_t>(this)); | 68 reinterpret_cast<intptr_t>(this)); |
69 // Do not close the infobar on accept, it will be closed as part | 69 // Do not close the infobar on accept, it will be closed as part |
70 // of the log in callback. | 70 // of the log in callback. |
| 71 RecordHistogramAction(ACCEPTED); |
71 return false; | 72 return false; |
72 } | 73 } |
73 | 74 |
74 bool AutoLoginInfoBarDelegateAndroid::Cancel() { | 75 bool AutoLoginInfoBarDelegateAndroid::Cancel() { |
75 JNIEnv* env = base::android::AttachCurrentThread(); | 76 JNIEnv* env = base::android::AttachCurrentThread(); |
76 ScopedJavaLocalRef<jobject> delegate = | 77 ScopedJavaLocalRef<jobject> delegate = |
77 weak_java_auto_login_delegate_.get(env); | 78 weak_java_auto_login_delegate_.get(env); |
78 DCHECK(delegate.obj()); | 79 DCHECK(delegate.obj()); |
79 Java_AutoLoginDelegate_cancelLogIn(env, delegate.obj(), | 80 Java_AutoLoginDelegate_cancelLogIn(env, delegate.obj(), |
80 reinterpret_cast<intptr_t>(this)); | 81 reinterpret_cast<intptr_t>(this)); |
| 82 RecordHistogramAction(REJECTED); |
81 return true; | 83 return true; |
82 } | 84 } |
83 | 85 |
84 void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env, | 86 void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env, |
85 jobject obj, | 87 jobject obj, |
86 jstring result) { | 88 jstring result) { |
87 if (!infobar()->owner()) | 89 if (!infobar()->owner()) |
88 return; // We're closing; don't call anything, it might access the owner. | 90 return; // We're closing; don't call anything, it might access the owner. |
89 | 91 |
90 // TODO(miguelg): Test whether the Stop() and RemoveInfoBar() calls here are | 92 // TODO(miguelg): Test whether the Stop() and RemoveInfoBar() calls here are |
(...skipping 25 matching lines...) Expand all Loading... |
116 infobar()->RemoveSelf(); | 118 infobar()->RemoveSelf(); |
117 } | 119 } |
118 | 120 |
119 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) { | 121 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) { |
120 infobar()->RemoveSelf(); | 122 infobar()->RemoveSelf(); |
121 } | 123 } |
122 | 124 |
123 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) { | 125 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) { |
124 return RegisterNativesImpl(env); | 126 return RegisterNativesImpl(env); |
125 } | 127 } |
OLD | NEW |