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/infobar_android.h" | 5 #include "chrome/browser/ui/android/infobars/infobar_android.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/strings/string_util.h" | |
12 #include "chrome/browser/android/resource_mapper.h" | 11 #include "chrome/browser/android/resource_mapper.h" |
13 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/permissions/permission_infobar_delegate.h" |
14 #include "components/infobars/core/infobar.h" | |
15 #include "components/infobars/core/infobar_delegate.h" | 13 #include "components/infobars/core/infobar_delegate.h" |
16 #include "jni/InfoBar_jni.h" | 14 #include "jni/InfoBar_jni.h" |
17 | 15 |
18 using base::android::JavaParamRef; | 16 using base::android::JavaParamRef; |
19 | 17 |
20 // InfoBarAndroid ------------------------------------------------------------- | 18 // InfoBarAndroid ------------------------------------------------------------- |
21 | 19 |
22 InfoBarAndroid::InfoBarAndroid( | 20 InfoBarAndroid::InfoBarAndroid( |
23 std::unique_ptr<infobars::InfoBarDelegate> delegate) | 21 std::unique_ptr<infobars::InfoBarDelegate> delegate) |
24 : infobars::InfoBar(std::move(delegate)) {} | 22 : infobars::InfoBar(std::move(delegate)) {} |
(...skipping 25 matching lines...) Expand all Loading... |
50 jobject InfoBarAndroid::GetJavaInfoBar() { | 48 jobject InfoBarAndroid::GetJavaInfoBar() { |
51 return java_info_bar_.obj(); | 49 return java_info_bar_.obj(); |
52 } | 50 } |
53 | 51 |
54 bool InfoBarAndroid::HasSetJavaInfoBar() const { | 52 bool InfoBarAndroid::HasSetJavaInfoBar() const { |
55 return !java_info_bar_.is_null(); | 53 return !java_info_bar_.is_null(); |
56 } | 54 } |
57 | 55 |
58 void InfoBarAndroid::OnButtonClicked(JNIEnv* env, | 56 void InfoBarAndroid::OnButtonClicked(JNIEnv* env, |
59 const JavaParamRef<jobject>& obj, | 57 const JavaParamRef<jobject>& obj, |
60 jint action) { | 58 jint action, |
| 59 jboolean persist) { |
| 60 PermissionInfobarDelegate* permission_delegate = |
| 61 delegate()->AsPermissionInfobarDelegate(); |
| 62 if (permission_delegate && permission_delegate->ShouldShowPersistenceToggle()) |
| 63 permission_delegate->SetPersist(persist); |
| 64 |
61 ProcessButton(action); | 65 ProcessButton(action); |
62 } | 66 } |
63 | 67 |
64 void InfoBarAndroid::OnCloseButtonClicked(JNIEnv* env, | 68 void InfoBarAndroid::OnCloseButtonClicked(JNIEnv* env, |
65 const JavaParamRef<jobject>& obj) { | 69 const JavaParamRef<jobject>& obj) { |
66 if (!owner()) | 70 if (!owner()) |
67 return; // We're closing; don't call anything, it might access the owner. | 71 return; // We're closing; don't call anything, it might access the owner. |
68 delegate()->InfoBarDismissed(); | 72 delegate()->InfoBarDismissed(); |
69 RemoveSelf(); | 73 RemoveSelf(); |
70 } | 74 } |
71 | 75 |
72 void InfoBarAndroid::CloseJavaInfoBar() { | 76 void InfoBarAndroid::CloseJavaInfoBar() { |
73 if (!java_info_bar_.is_null()) { | 77 if (!java_info_bar_.is_null()) { |
74 JNIEnv* env = base::android::AttachCurrentThread(); | 78 JNIEnv* env = base::android::AttachCurrentThread(); |
75 Java_InfoBar_closeInfoBar(env, java_info_bar_.obj()); | 79 Java_InfoBar_closeInfoBar(env, java_info_bar_.obj()); |
76 } | 80 } |
77 } | 81 } |
78 | 82 |
79 int InfoBarAndroid::GetEnumeratedIconId() { | 83 int InfoBarAndroid::GetEnumeratedIconId() { |
80 return ResourceMapper::MapFromChromiumId(delegate()->GetIconId()); | 84 return ResourceMapper::MapFromChromiumId(delegate()->GetIconId()); |
81 } | 85 } |
82 | 86 |
83 | 87 |
84 // Native JNI methods --------------------------------------------------------- | 88 // Native JNI methods --------------------------------------------------------- |
85 | 89 |
86 bool RegisterNativeInfoBar(JNIEnv* env) { | 90 bool RegisterNativeInfoBar(JNIEnv* env) { |
87 return RegisterNativesImpl(env); | 91 return RegisterNativesImpl(env); |
88 } | 92 } |
OLD | NEW |