| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/android/tab_model/tab_model_selector_base.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "chrome/browser/android/tab_android.h" | |
| 9 #include "chrome/browser/permissions/permission_request_manager.h" | |
| 10 #include "content/public/browser/web_contents.h" | |
| 11 #include "jni/TabModelSelectorBase_jni.h" | |
| 12 | |
| 13 using base::android::JavaParamRef; | |
| 14 | |
| 15 static void OnActiveTabChanged( | |
| 16 JNIEnv* env, | |
| 17 const JavaParamRef<jclass>& clazz, | |
| 18 const JavaParamRef<jobject>& java_old_web_contents, | |
| 19 const JavaParamRef<jobject>& java_new_web_contents) { | |
| 20 // Check if PermissionRequestManager is reused on Android to manage infobars. | |
| 21 // This is currently behind a switch flag. | |
| 22 if (!PermissionRequestManager::IsEnabled()) | |
| 23 return; | |
| 24 | |
| 25 // Visible permission infobars will get hidden and shown when switching tabs | |
| 26 // by the infobar infrastructure, but we do this explicitly to create/destroy | |
| 27 // PermissionPromptAndroid for old and new tabs. This also keeps the codepath | |
| 28 // consistent across different platforms. | |
| 29 content::WebContents* old_contents = | |
| 30 content::WebContents::FromJavaWebContents(java_old_web_contents); | |
| 31 content::WebContents* new_contents = | |
| 32 content::WebContents::FromJavaWebContents(java_new_web_contents); | |
| 33 DCHECK(new_contents); | |
| 34 if (old_contents) | |
| 35 PermissionRequestManager::FromWebContents(old_contents)->HideBubble(); | |
| 36 | |
| 37 if (new_contents) { | |
| 38 PermissionRequestManager::FromWebContents(new_contents) | |
| 39 ->DisplayPendingRequests(); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 // Register native methods | |
| 44 bool RegisterTabModelSelectorBase(JNIEnv* env) { | |
| 45 return RegisterNativesImpl(env); | |
| 46 } | |
| OLD | NEW |