| 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" |
| 11 #include "chrome/browser/ui/android/infobars/infobar_android.h" | 11 #include "chrome/browser/ui/android/infobars/infobar_android.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 "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "jni/InfoBarContainer_jni.h" | 15 #include "jni/InfoBarContainer_jni.h" |
| 16 | 16 |
| 17 | 17 |
| 18 // InfoBarContainerAndroid ---------------------------------------------------- | 18 // InfoBarContainerAndroid ---------------------------------------------------- |
| 19 | 19 |
| 20 InfoBarContainerAndroid::InfoBarContainerAndroid(JNIEnv* env, | 20 InfoBarContainerAndroid::InfoBarContainerAndroid(JNIEnv* env, |
| 21 jobject obj) | 21 jobject obj) |
| 22 : infobars::InfoBarContainer(NULL), | 22 : infobars::InfoBarContainer(NULL), |
| 23 weak_java_infobar_container_(env, obj) {} | 23 weak_java_infobar_container_(env, obj) {} |
| 24 | 24 |
| 25 InfoBarContainerAndroid::~InfoBarContainerAndroid() { | 25 InfoBarContainerAndroid::~InfoBarContainerAndroid() { |
| 26 RemoveAllInfoBarsForDestruction(); | 26 RemoveAllInfoBarsForDestruction(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void InfoBarContainerAndroid::SetWebContents(JNIEnv* env, | 29 void InfoBarContainerAndroid::SetWebContents( |
| 30 jobject obj, | 30 JNIEnv* env, |
| 31 jobject web_contents) { | 31 const JavaParamRef<jobject>& obj, |
| 32 const JavaParamRef<jobject>& web_contents) { |
| 32 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 33 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
| 33 content::WebContents::FromJavaWebContents(web_contents)); | 34 content::WebContents::FromJavaWebContents(web_contents)); |
| 34 ChangeInfoBarManager(infobar_service); | 35 ChangeInfoBarManager(infobar_service); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void InfoBarContainerAndroid::Destroy(JNIEnv* env, jobject obj) { | 38 void InfoBarContainerAndroid::Destroy(JNIEnv* env, |
| 39 const JavaParamRef<jobject>& obj) { |
| 38 delete this; | 40 delete this; |
| 39 } | 41 } |
| 40 | 42 |
| 41 void InfoBarContainerAndroid::PlatformSpecificAddInfoBar( | 43 void InfoBarContainerAndroid::PlatformSpecificAddInfoBar( |
| 42 infobars::InfoBar* infobar, | 44 infobars::InfoBar* infobar, |
| 43 size_t position) { | 45 size_t position) { |
| 44 DCHECK(infobar); | 46 DCHECK(infobar); |
| 45 InfoBarAndroid* android_bar = static_cast<InfoBarAndroid*>(infobar); | 47 InfoBarAndroid* android_bar = static_cast<InfoBarAndroid*>(infobar); |
| 46 if (!android_bar) { | 48 if (!android_bar) { |
| 47 // TODO(bulach): CLANK: implement other types of InfoBars. | 49 // TODO(bulach): CLANK: implement other types of InfoBars. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 86 |
| 85 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 87 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 86 InfoBarContainerAndroid* infobar_container = | 88 InfoBarContainerAndroid* infobar_container = |
| 87 new InfoBarContainerAndroid(env, obj); | 89 new InfoBarContainerAndroid(env, obj); |
| 88 return reinterpret_cast<intptr_t>(infobar_container); | 90 return reinterpret_cast<intptr_t>(infobar_container); |
| 89 } | 91 } |
| 90 | 92 |
| 91 bool RegisterInfoBarContainer(JNIEnv* env) { | 93 bool RegisterInfoBarContainer(JNIEnv* env) { |
| 92 return RegisterNativesImpl(env); | 94 return RegisterNativesImpl(env); |
| 93 } | 95 } |
| OLD | NEW |