OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/confirm_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/confirm_infobar.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/android/resource_mapper.h" | 10 #include "chrome/browser/android/resource_mapper.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 base::android::ScopedJavaLocalRef<jstring> link_text = | 47 base::android::ScopedJavaLocalRef<jstring> link_text = |
48 base::android::ConvertUTF16ToJavaString( | 48 base::android::ConvertUTF16ToJavaString( |
49 env, delegate->GetLinkText()); | 49 env, delegate->GetLinkText()); |
50 | 50 |
51 ScopedJavaLocalRef<jobject> java_bitmap; | 51 ScopedJavaLocalRef<jobject> java_bitmap; |
52 if (!delegate->GetIcon().IsEmpty()) { | 52 if (!delegate->GetIcon().IsEmpty()) { |
53 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap()); | 53 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap()); |
54 } | 54 } |
55 | 55 |
56 return Java_ConfirmInfoBarDelegate_showConfirmInfoBar( | 56 return Java_ConfirmInfoBarDelegate_showConfirmInfoBar( |
57 env, java_confirm_delegate_.obj(), reinterpret_cast<intptr_t>(this), | 57 env, java_confirm_delegate_.obj(), GetEnumeratedIconId(), |
58 GetEnumeratedIconId(), java_bitmap.obj(), message_text.obj(), | 58 java_bitmap.obj(), message_text.obj(), link_text.obj(), |
59 link_text.obj(), ok_button_text.obj(), cancel_button_text.obj()); | 59 ok_button_text.obj(), cancel_button_text.obj()); |
60 } | 60 } |
61 | 61 |
62 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, jobject obj) { | 62 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, jobject obj) { |
63 if (!owner()) | 63 if (!owner()) |
64 return; // We're closing; don't call anything, it might access the owner. | 64 return; // We're closing; don't call anything, it might access the owner. |
65 | 65 |
66 if (GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB)) | 66 if (GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB)) |
67 RemoveSelf(); | 67 RemoveSelf(); |
68 } | 68 } |
69 | 69 |
(...skipping 20 matching lines...) Expand all Loading... |
90 return (delegate->GetButtons() & button) ? | 90 return (delegate->GetButtons() & button) ? |
91 delegate->GetButtonLabel(button) : base::string16(); | 91 delegate->GetButtonLabel(button) : base::string16(); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 // Native JNI methods --------------------------------------------------------- | 95 // Native JNI methods --------------------------------------------------------- |
96 | 96 |
97 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) { | 97 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) { |
98 return RegisterNativesImpl(env); | 98 return RegisterNativesImpl(env); |
99 } | 99 } |
OLD | NEW |