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

Unified Diff: chrome/browser/ui/android/infobars/confirm_infobar.cc

Issue 24562006: Cleanup upstreamed Android infobar code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/android/infobars/confirm_infobar.cc
===================================================================
--- chrome/browser/ui/android/infobars/confirm_infobar.cc (revision 225273)
+++ chrome/browser/ui/android/infobars/confirm_infobar.cc (working copy)
@@ -11,73 +11,63 @@
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "jni/ConfirmInfoBarDelegate_jni.h"
-using base::android::ConvertUTF16ToJavaString;
-using base::android::ScopedJavaLocalRef;
+// ConfirmInfoBarDelegate -----------------------------------------------------
+
// static
InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
return new ConfirmInfoBar(owner, this);
}
+
+// ConfirmInfoBar -------------------------------------------------------------
+
ConfirmInfoBar::ConfirmInfoBar(InfoBarService* owner, InfoBarDelegate* delegate)
: InfoBarAndroid(owner, delegate),
delegate_(delegate->AsConfirmInfoBarDelegate()),
- java_confirm_delegate_() {}
+ java_confirm_delegate_() {
+}
-ConfirmInfoBar::~ConfirmInfoBar() {}
+ConfirmInfoBar::~ConfirmInfoBar() {
+}
-ScopedJavaLocalRef<jobject> ConfirmInfoBar::CreateRenderInfoBar(JNIEnv* env) {
+base::android::ScopedJavaLocalRef<jobject> ConfirmInfoBar::CreateRenderInfoBar(
+ JNIEnv* env) {
java_confirm_delegate_.Reset(Java_ConfirmInfoBarDelegate_create(env));
- ScopedJavaLocalRef<jstring> ok_button_text =
- ConvertUTF16ToJavaString(env, GetTextFor(InfoBarAndroid::ACTION_OK));
- ScopedJavaLocalRef<jstring> cancel_button_text =
- ConvertUTF16ToJavaString(env, GetTextFor(InfoBarAndroid::ACTION_CANCEL));
- ScopedJavaLocalRef<jstring> message_text =
- ConvertUTF16ToJavaString(env, GetMessage());
+ base::android::ScopedJavaLocalRef<jstring> ok_button_text =
+ base::android::ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
+ base::android::ScopedJavaLocalRef<jstring> cancel_button_text =
+ base::android::ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
+ base::android::ScopedJavaLocalRef<jstring> message_text =
+ base::android::ConvertUTF16ToJavaString(
+ env, delegate_->GetMessageText());
return Java_ConfirmInfoBarDelegate_showConfirmInfoBar(
- env,
- java_confirm_delegate_.obj(),
- reinterpret_cast<jint>(this),
- GetEnumeratedIconId(),
- message_text.obj(),
- ok_button_text.obj(),
+ env, java_confirm_delegate_.obj(), reinterpret_cast<jint>(this),
+ GetEnumeratedIconId(), message_text.obj(), ok_button_text.obj(),
cancel_button_text.obj());
}
void ConfirmInfoBar::ProcessButton(int action,
const std::string& action_value) {
- DCHECK(action == InfoBarAndroid::ACTION_OK ||
- action == InfoBarAndroid::ACTION_CANCEL);
- if ((action == InfoBarAndroid::ACTION_OK) ? delegate_->Accept()
- : delegate_->Cancel())
+ DCHECK((action == InfoBarAndroid::ACTION_OK) ||
+ (action == InfoBarAndroid::ACTION_CANCEL));
+ if ((action == InfoBarAndroid::ACTION_OK) ?
+ delegate_->Accept() : delegate_->Cancel())
CloseInfoBar();
}
-string16 ConfirmInfoBar::GetTextFor(ActionType action) {
- int buttons = delegate_->GetButtons();
- switch (action) {
- case InfoBarAndroid::ACTION_OK:
- if (buttons & ConfirmInfoBarDelegate::BUTTON_OK)
- return delegate_->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK);
- break;
- case InfoBarAndroid::ACTION_CANCEL:
- if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL)
- return delegate_->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL);
- break;
- default:
- break;
- }
- return string16();
+string16 ConfirmInfoBar::GetTextFor(
+ ConfirmInfoBarDelegate::InfoBarButton button) {
+ return (delegate_->GetButtons() & button) ?
+ delegate_->GetButtonLabel(button) : string16();
}
-string16 ConfirmInfoBar::GetMessage() {
- return delegate_->GetMessageText();
-}
-// -----------------------------------------------------------------------------
-// Native JNI methods for confirm delegate.
-// -----------------------------------------------------------------------------
+// Native JNI methods ---------------------------------------------------------
+
bool RegisterConfirmInfoBarDelegate(JNIEnv* env) {
return RegisterNativesImpl(env);
}
« no previous file with comments | « chrome/browser/ui/android/infobars/confirm_infobar.h ('k') | chrome/browser/ui/android/infobars/infobar_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698