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()) { | |
Bernhard Bauer
2016/11/24 15:30:40
Return early if it's disabled?
lshang
2016/11/25 00:41:06
Done.
| |
23 content::WebContents* old_contents = | |
24 content::WebContents::FromJavaWebContents(java_old_web_contents); | |
25 content::WebContents* new_contents = | |
26 content::WebContents::FromJavaWebContents(java_new_web_contents); | |
27 DCHECK(new_contents); | |
28 | |
29 if (old_contents && PermissionRequestManager::FromWebContents(old_contents)) | |
30 PermissionRequestManager::FromWebContents(old_contents)->HideBubble(); | |
Bernhard Bauer
2016/11/24 15:30:40
When is the PermissionRequestManager null?
lshang
2016/11/25 00:41:06
I guess https://cs.chromium.org/chromium/src/chrom
Bernhard Bauer
2016/11/25 09:52:24
Please don't try to avoid crashes "just in case";
| |
31 | |
32 if (new_contents && | |
33 PermissionRequestManager::FromWebContents(new_contents)) { | |
34 PermissionRequestManager::FromWebContents(new_contents) | |
35 ->DisplayPendingRequests(); | |
36 } | |
37 } | |
38 } | |
39 | |
40 // Register native methods | |
41 bool RegisterTabModelSelectorBase(JNIEnv* env) { | |
42 return RegisterNativesImpl(env); | |
43 } | |
OLD | NEW |