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.h" | 10 #include "chrome/browser/infobars/infobar.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void InfoBarContainerAndroid::PlatformSpecificReplaceInfoBar( | 72 void InfoBarContainerAndroid::PlatformSpecificReplaceInfoBar( |
73 InfoBar* old_infobar, | 73 InfoBar* old_infobar, |
74 InfoBar* new_infobar) { | 74 InfoBar* new_infobar) { |
75 static_cast<InfoBarAndroid*>(new_infobar)->PassJavaInfoBar( | 75 static_cast<InfoBarAndroid*>(new_infobar)->PassJavaInfoBar( |
76 static_cast<InfoBarAndroid*>(old_infobar)); | 76 static_cast<InfoBarAndroid*>(old_infobar)); |
77 } | 77 } |
78 | 78 |
79 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { | 79 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { |
80 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar); | 80 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar); |
81 android_infobar->CloseJavaInfoBar(); | 81 android_infobar->CloseJavaInfoBar(); |
| 82 base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar); |
82 } | 83 } |
83 | 84 |
84 | 85 |
85 // Native JNI methods --------------------------------------------------------- | 86 // Native JNI methods --------------------------------------------------------- |
86 | 87 |
87 static jlong Init(JNIEnv* env, | 88 static jlong Init(JNIEnv* env, |
88 jobject obj, | 89 jobject obj, |
89 jlong native_web_contents, | 90 jlong native_web_contents, |
90 jobject auto_login_delegate) { | 91 jobject auto_login_delegate) { |
91 InfoBarContainerAndroid* infobar_container = | 92 InfoBarContainerAndroid* infobar_container = |
92 new InfoBarContainerAndroid(env, obj, auto_login_delegate); | 93 new InfoBarContainerAndroid(env, obj, auto_login_delegate); |
93 infobar_container->ChangeInfoBarService(InfoBarService::FromWebContents( | 94 infobar_container->ChangeInfoBarService(InfoBarService::FromWebContents( |
94 reinterpret_cast<content::WebContents*>(native_web_contents))); | 95 reinterpret_cast<content::WebContents*>(native_web_contents))); |
95 return reinterpret_cast<intptr_t>(infobar_container); | 96 return reinterpret_cast<intptr_t>(infobar_container); |
96 } | 97 } |
97 | 98 |
98 bool RegisterInfoBarContainer(JNIEnv* env) { | 99 bool RegisterInfoBarContainer(JNIEnv* env) { |
99 return RegisterNativesImpl(env); | 100 return RegisterNativesImpl(env); |
100 } | 101 } |
OLD | NEW |