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

Side by Side Diff: chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android.cc

Issue 230453004: Remove InfoBarDelegate::web_contents() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 6 years, 8 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env, 84 void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env,
85 jobject obj, 85 jobject obj,
86 jstring result) { 86 jstring result) {
87 if (!infobar()->owner()) 87 if (!infobar()->owner())
88 return; // We're closing; don't call anything, it might access the owner. 88 return; // We're closing; don't call anything, it might access the owner.
89 89
90 // TODO(miguelg): Test whether the Stop() and RemoveInfoBar() calls here are 90 // TODO(miguelg): Test whether the Stop() and RemoveInfoBar() calls here are
91 // necessary, or whether OpenURL() will do this for us. 91 // necessary, or whether OpenURL() will do this for us.
92 content::WebContents* contents = web_contents(); 92 content::WebContents* contents =
93 InfoBarService::WebContentsFromInfoBar(infobar());
93 contents->Stop(); 94 contents->Stop();
94 infobar()->RemoveSelf(); 95 infobar()->RemoveSelf();
95 // WARNING: |this| may be deleted at this point! Do not access any members! 96 // WARNING: |this| may be deleted at this point! Do not access any members!
96 contents->OpenURL(content::OpenURLParams( 97 contents->OpenURL(content::OpenURLParams(
97 GURL(base::android::ConvertJavaStringToUTF8(env, result)), 98 GURL(base::android::ConvertJavaStringToUTF8(env, result)),
98 content::Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK, 99 content::Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK,
99 false)); 100 false));
100 } 101 }
101 102
102 void AutoLoginInfoBarDelegateAndroid::LoginFailed(JNIEnv* env, jobject obj) { 103 void AutoLoginInfoBarDelegateAndroid::LoginFailed(JNIEnv* env, jobject obj) {
103 if (!infobar()->owner()) 104 if (!infobar()->owner())
104 return; // We're closing; don't call anything, it might access the owner. 105 return; // We're closing; don't call anything, it might access the owner.
105 106
106 // TODO(miguelg): Using SimpleAlertInfoBarDelegate::Create() animates in a new 107 // TODO(miguelg): Using SimpleAlertInfoBarDelegate::Create() animates in a new
107 // infobar while we animate the current one closed. It would be better to use 108 // infobar while we animate the current one closed. It would be better to use
108 // ReplaceInfoBar(). 109 // ReplaceInfoBar().
109 InfoBarService* infobar_service = 110 InfoBarService* infobar_service = InfoBarService::FromWebContents(
110 InfoBarService::FromWebContents(web_contents()); 111 InfoBarService::WebContentsFromInfoBar(infobar()));
111 DCHECK(infobar_service); 112 DCHECK(infobar_service);
112 SimpleAlertInfoBarDelegate::Create( 113 SimpleAlertInfoBarDelegate::Create(
113 infobar_service, IDR_INFOBAR_WARNING, 114 infobar_service, IDR_INFOBAR_WARNING,
114 l10n_util::GetStringUTF16(IDS_AUTO_LOGIN_FAILED), false); 115 l10n_util::GetStringUTF16(IDS_AUTO_LOGIN_FAILED), false);
115 infobar()->RemoveSelf(); 116 infobar()->RemoveSelf();
116 } 117 }
117 118
118 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) { 119 void AutoLoginInfoBarDelegateAndroid::LoginDismiss(JNIEnv* env, jobject obj) {
119 infobar()->RemoveSelf(); 120 infobar()->RemoveSelf();
120 } 121 }
121 122
122 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) { 123 bool AutoLoginInfoBarDelegateAndroid::Register(JNIEnv* env) {
123 return RegisterNativesImpl(env); 124 return RegisterNativesImpl(env);
124 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698