| 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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 jobject obj, | 60 jobject obj, |
| 61 jint action, | 61 jint action, |
| 62 jstring action_value) { | 62 jstring action_value) { |
| 63 DCHECK(delegate_); | 63 DCHECK(delegate_); |
| 64 std::string value = base::android::ConvertJavaStringToUTF8(env, action_value); | 64 std::string value = base::android::ConvertJavaStringToUTF8(env, action_value); |
| 65 ProcessButton(action, value); | 65 ProcessButton(action, value); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void InfoBarAndroid::OnCloseButtonClicked(JNIEnv* env, jobject obj) { | 68 void InfoBarAndroid::OnCloseButtonClicked(JNIEnv* env, jobject obj) { |
| 69 delegate_->InfoBarDismissed(); | 69 delegate_->InfoBarDismissed(); |
| 70 } | 70 RemoveSelf(); |
| 71 | |
| 72 void InfoBarAndroid::OnInfoBarClosed(JNIEnv* env, jobject obj) { | |
| 73 java_info_bar_.Reset(); // So we don't notify Java. | |
| 74 if (owner()) | |
| 75 RemoveSelf(); | |
| 76 } | 71 } |
| 77 | 72 |
| 78 void InfoBarAndroid::CloseJavaInfoBar() { | 73 void InfoBarAndroid::CloseJavaInfoBar() { |
| 79 if (!java_info_bar_.is_null()) { | 74 if (!java_info_bar_.is_null()) { |
| 80 JNIEnv* env = base::android::AttachCurrentThread(); | 75 JNIEnv* env = base::android::AttachCurrentThread(); |
| 81 Java_InfoBar_closeInfoBar(env, java_info_bar_.obj()); | 76 Java_InfoBar_closeInfoBar(env, java_info_bar_.obj()); |
| 82 } | 77 } |
| 83 } | 78 } |
| 84 | 79 |
| 85 int InfoBarAndroid::GetEnumeratedIconId() { | 80 int InfoBarAndroid::GetEnumeratedIconId() { |
| 86 DCHECK(delegate_); | 81 DCHECK(delegate_); |
| 87 return ResourceMapper::MapFromChromiumId(delegate_->GetIconID()); | 82 return ResourceMapper::MapFromChromiumId(delegate_->GetIconID()); |
| 88 } | 83 } |
| 89 | 84 |
| 90 | 85 |
| 91 // Native JNI methods --------------------------------------------------------- | 86 // Native JNI methods --------------------------------------------------------- |
| 92 | 87 |
| 93 bool RegisterNativeInfoBar(JNIEnv* env) { | 88 bool RegisterNativeInfoBar(JNIEnv* env) { |
| 94 return RegisterNativesImpl(env); | 89 return RegisterNativesImpl(env); |
| 95 } | 90 } |
| OLD | NEW |