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 "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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/android/resource_mapper.h" | 10 #include "chrome/browser/android/resource_mapper.h" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
13 #include "components/infobars/core/infobar_delegate.h" | 13 #include "components/infobars/core/infobar_delegate.h" |
14 #include "jni/InfoBar_jni.h" | 14 #include "jni/InfoBar_jni.h" |
15 | 15 |
16 | 16 |
17 // InfoBarAndroid ------------------------------------------------------------- | 17 // InfoBarAndroid ------------------------------------------------------------- |
18 | 18 |
19 InfoBarAndroid::InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate) | 19 InfoBarAndroid::InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate) |
20 : infobars::InfoBar(delegate.Pass()) { | 20 : infobars::InfoBar(delegate.Pass()) { |
21 } | 21 } |
22 | 22 |
23 InfoBarAndroid::~InfoBarAndroid() { | 23 InfoBarAndroid::~InfoBarAndroid() { |
David Trainor- moved to gerrit
2015/06/02 17:51:55
This should probably tell Java to drop the referen
Changwan Ryu
2015/06/03 04:55:41
Done.
| |
24 } | 24 } |
25 | 25 |
26 void InfoBarAndroid::ReassignJavaInfoBar(InfoBarAndroid* replacement) { | 26 void InfoBarAndroid::ReassignJavaInfoBar(InfoBarAndroid* replacement) { |
27 DCHECK(replacement); | 27 DCHECK(replacement); |
28 if (!java_info_bar_.is_null()) { | 28 if (!java_info_bar_.is_null()) { |
29 replacement->set_java_infobar(java_info_bar_); | 29 replacement->set_java_infobar(java_info_bar_); |
30 java_info_bar_.Reset(); | 30 java_info_bar_.Reset(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 void InfoBarAndroid::set_java_infobar( | 34 void InfoBarAndroid::set_java_infobar( |
35 const base::android::JavaRef<jobject>& java_info_bar) { | 35 const base::android::JavaRef<jobject>& java_info_bar) { |
36 DCHECK(java_info_bar_.is_null()); | 36 DCHECK(java_info_bar_.is_null()); |
37 java_info_bar_.Reset(java_info_bar); | 37 java_info_bar_.Reset(java_info_bar); |
38 JNIEnv* env = base::android::AttachCurrentThread(); | |
39 Java_InfoBar_setNativeInfoBar(env, java_info_bar.obj(), | |
40 reinterpret_cast<intptr_t>(this)); | |
38 } | 41 } |
39 | 42 |
40 bool InfoBarAndroid::HasSetJavaInfoBar() const { | 43 bool InfoBarAndroid::HasSetJavaInfoBar() const { |
41 return !java_info_bar_.is_null(); | 44 return !java_info_bar_.is_null(); |
42 } | 45 } |
43 | 46 |
44 void InfoBarAndroid::OnButtonClicked(JNIEnv* env, | 47 void InfoBarAndroid::OnButtonClicked(JNIEnv* env, |
45 jobject obj, | 48 jobject obj, |
46 jint action, | 49 jint action, |
47 jstring action_value) { | 50 jstring action_value) { |
(...skipping 18 matching lines...) Expand all Loading... | |
66 int InfoBarAndroid::GetEnumeratedIconId() { | 69 int InfoBarAndroid::GetEnumeratedIconId() { |
67 return ResourceMapper::MapFromChromiumId(delegate()->GetIconID()); | 70 return ResourceMapper::MapFromChromiumId(delegate()->GetIconID()); |
68 } | 71 } |
69 | 72 |
70 | 73 |
71 // Native JNI methods --------------------------------------------------------- | 74 // Native JNI methods --------------------------------------------------------- |
72 | 75 |
73 bool RegisterNativeInfoBar(JNIEnv* env) { | 76 bool RegisterNativeInfoBar(JNIEnv* env) { |
74 return RegisterNativesImpl(env); | 77 return RegisterNativesImpl(env); |
75 } | 78 } |
OLD | NEW |