| 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_container_android.h" | 5 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 void InfoBarContainerAndroid::AttachJavaInfoBar(InfoBarAndroid* android_bar) { | 58 void InfoBarContainerAndroid::AttachJavaInfoBar(InfoBarAndroid* android_bar) { |
| 59 if (android_bar->HasSetJavaInfoBar()) | 59 if (android_bar->HasSetJavaInfoBar()) |
| 60 return; | 60 return; |
| 61 JNIEnv* env = base::android::AttachCurrentThread(); | 61 JNIEnv* env = base::android::AttachCurrentThread(); |
| 62 base::android::ScopedJavaLocalRef<jobject> java_infobar = | 62 base::android::ScopedJavaLocalRef<jobject> java_infobar = |
| 63 android_bar->CreateRenderInfoBar(env); | 63 android_bar->CreateRenderInfoBar(env); |
| 64 Java_InfoBarContainer_addInfoBar( | 64 Java_InfoBarContainer_addInfoBar( |
| 65 env, weak_java_infobar_container_.get(env).obj(), java_infobar.obj()); | 65 env, weak_java_infobar_container_.get(env).obj(), java_infobar.obj()); |
| 66 android_bar->set_java_infobar(java_infobar); | 66 android_bar->SetJavaInfoBar(java_infobar); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void InfoBarContainerAndroid::PlatformSpecificReplaceInfoBar( | 69 void InfoBarContainerAndroid::PlatformSpecificReplaceInfoBar( |
| 70 infobars::InfoBar* old_infobar, | 70 infobars::InfoBar* old_infobar, |
| 71 infobars::InfoBar* new_infobar) { | 71 infobars::InfoBar* new_infobar) { |
| 72 static_cast<InfoBarAndroid*>(new_infobar)->PassJavaInfoBar( | 72 static_cast<InfoBarAndroid*>(new_infobar)->PassJavaInfoBar( |
| 73 static_cast<InfoBarAndroid*>(old_infobar)); | 73 static_cast<InfoBarAndroid*>(old_infobar)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar( | 76 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar( |
| 77 infobars::InfoBar* infobar) { | 77 infobars::InfoBar* infobar) { |
| 78 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar); | 78 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar); |
| 79 android_infobar->CloseJavaInfoBar(); | 79 android_infobar->CloseJavaInfoBar(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 // Native JNI methods --------------------------------------------------------- | 83 // Native JNI methods --------------------------------------------------------- |
| 84 | 84 |
| 85 static jlong Init(JNIEnv* env, jobject obj) { | 85 static jlong Init(JNIEnv* env, jobject obj) { |
| 86 InfoBarContainerAndroid* infobar_container = | 86 InfoBarContainerAndroid* infobar_container = |
| 87 new InfoBarContainerAndroid(env, obj); | 87 new InfoBarContainerAndroid(env, obj); |
| 88 return reinterpret_cast<intptr_t>(infobar_container); | 88 return reinterpret_cast<intptr_t>(infobar_container); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool RegisterInfoBarContainer(JNIEnv* env) { | 91 bool RegisterInfoBarContainer(JNIEnv* env) { |
| 92 return RegisterNativesImpl(env); | 92 return RegisterNativesImpl(env); |
| 93 } | 93 } |
| OLD | NEW |