| Index: chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android.cc
|
| ===================================================================
|
| --- chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android.cc (revision 226624)
|
| +++ chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android.cc (working copy)
|
| @@ -8,6 +8,7 @@
|
| #include "base/android/jni_helper.h"
|
| #include "base/android/jni_string.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/infobars/infobar.h"
|
| #include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
|
| #include "chrome/browser/ui/auto_login_infobar_delegate.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -19,10 +20,10 @@
|
| using base::android::ConvertUTF8ToJavaString;
|
| using base::android::ScopedJavaLocalRef;
|
|
|
| +
|
| AutoLoginInfoBarDelegateAndroid::AutoLoginInfoBarDelegateAndroid(
|
| - InfoBarService* owner,
|
| const Params& params)
|
| - : AutoLoginInfoBarDelegate(owner, params),
|
| + : AutoLoginInfoBarDelegate(params),
|
| params_(params) {
|
| }
|
|
|
| @@ -61,10 +62,8 @@
|
| ScopedJavaLocalRef<jobject> delegate =
|
| weak_java_auto_login_delegate_.get(env);
|
| DCHECK(delegate.obj());
|
| -
|
| Java_AutoLoginDelegate_logIn(env, delegate.obj(),
|
| reinterpret_cast<jint>(this));
|
| -
|
| // Do not close the infobar on accept, it will be closed as part
|
| // of the log in callback.
|
| return false;
|
| @@ -83,16 +82,21 @@
|
| void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env,
|
| jobject obj,
|
| jstring result) {
|
| - if (owner()) {
|
| - content::WebContents* web_contents = owner()->web_contents();
|
| - if (web_contents) {
|
| - web_contents->Stop();
|
| - web_contents->OpenURL(content::OpenURLParams(
|
| - GURL(base::android::ConvertJavaStringToUTF8(env, result)),
|
| - content::Referrer(), CURRENT_TAB,
|
| - content::PAGE_TRANSITION_AUTO_BOOKMARK, false));
|
| - }
|
| - owner()->RemoveInfoBar(this);
|
| + // TODO(pkasting): Can this and LoginFailed() really be called when the
|
| + // infobar is unowned?
|
| + if (infobar()->owner()) {
|
| + content::WebContents* contents = web_contents();
|
| + contents->Stop();
|
| + // It's not obvious whether calling OpenURL() will auto-close us or not. If
|
| + // it did, we wouldn't want to try to RemoveSelf() afterwards. So for
|
| + // safety, we always call RemoveSelf() directly, and then navigate
|
| + // afterwards.
|
| + infobar()->RemoveSelf();
|
| + // WARNING: |this| may be deleted at this point! Do not access any members!
|
| + contents->OpenURL(content::OpenURLParams(
|
| + GURL(base::android::ConvertJavaStringToUTF8(env, result)),
|
| + content::Referrer(), CURRENT_TAB,
|
| + content::PAGE_TRANSITION_LINK, false));
|
| }
|
| }
|
|
|
| @@ -100,17 +104,16 @@
|
| ScopedJavaLocalRef<jobject> delegate =
|
| weak_java_auto_login_delegate_.get(env);
|
| DCHECK(delegate.obj());
|
| - if (owner()) {
|
| + if (infobar()->owner()) {
|
| SimpleAlertInfoBarDelegate::Create(
|
| - owner(), IDR_INFOBAR_WARNING,
|
| + infobar()->owner(), IDR_INFOBAR_WARNING,
|
| l10n_util::GetStringUTF16(IDS_AUTO_LOGIN_FAILED), false);
|
| - owner()->RemoveInfoBar(this);
|
| + infobar()->RemoveSelf();
|
| }
|
| }
|
|
|
| void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) {
|
| - if (owner())
|
| - owner()->RemoveInfoBar(this);
|
| + infobar()->RemoveSelf();
|
| }
|
|
|
| bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) {
|
|
|