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" |
11 #include "chrome/browser/infobars/infobar.h" | 11 #include "chrome/browser/infobars/infobar.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" | 13 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" |
13 #include "chrome/browser/ui/auto_login_infobar_delegate.h" | 14 #include "chrome/browser/ui/auto_login_infobar_delegate.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
17 #include "jni/AutoLoginDelegate_jni.h" | 18 #include "jni/AutoLoginDelegate_jni.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 | 20 |
20 using base::android::ConvertUTF8ToJavaString; | 21 using base::android::ConvertUTF8ToJavaString; |
21 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 false)); | 99 false)); |
99 } | 100 } |
100 | 101 |
101 void AutoLoginInfoBarDelegateAndroid::LoginFailed(JNIEnv* env, jobject obj) { | 102 void AutoLoginInfoBarDelegateAndroid::LoginFailed(JNIEnv* env, jobject obj) { |
102 if (!infobar()->owner()) | 103 if (!infobar()->owner()) |
103 return; // We're closing; don't call anything, it might access the owner. | 104 return; // We're closing; don't call anything, it might access the owner. |
104 | 105 |
105 // TODO(miguelg): Using SimpleAlertInfoBarDelegate::Create() animates in a new | 106 // TODO(miguelg): Using SimpleAlertInfoBarDelegate::Create() animates in a new |
106 // infobar while we animate the current one closed. It would be better to use | 107 // infobar while we animate the current one closed. It would be better to use |
107 // ReplaceInfoBar(). | 108 // ReplaceInfoBar(). |
| 109 InfoBarService* infobar_service = |
| 110 InfoBarService::FromWebContents(web_contents()); |
| 111 DCHECK(infobar_service); |
108 SimpleAlertInfoBarDelegate::Create( | 112 SimpleAlertInfoBarDelegate::Create( |
109 infobar()->owner(), IDR_INFOBAR_WARNING, | 113 infobar_service, IDR_INFOBAR_WARNING, |
110 l10n_util::GetStringUTF16(IDS_AUTO_LOGIN_FAILED), false); | 114 l10n_util::GetStringUTF16(IDS_AUTO_LOGIN_FAILED), false); |
111 infobar()->RemoveSelf(); | 115 infobar()->RemoveSelf(); |
112 } | 116 } |
113 | 117 |
114 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) { | 118 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) { |
115 infobar()->RemoveSelf(); | 119 infobar()->RemoveSelf(); |
116 } | 120 } |
117 | 121 |
118 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) { | 122 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) { |
119 return RegisterNativesImpl(env); | 123 return RegisterNativesImpl(env); |
120 } | 124 } |
OLD | NEW |