Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2445)

Unified Diff: chrome/browser/ui/android/tab_model/tab_model_selector_base.cc

Issue 2522373002: Create/Destroy PermissionPromptAndroid when switching tabs on Android (Closed)
Patch Set: minor change in comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model_selector_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/android/tab_model/tab_model_selector_base.cc
diff --git a/chrome/browser/ui/android/tab_model/tab_model_selector_base.cc b/chrome/browser/ui/android/tab_model/tab_model_selector_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..753eb43e7366e91526d4728ac5c5e01a87537ea8
--- /dev/null
+++ b/chrome/browser/ui/android/tab_model/tab_model_selector_base.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/android/tab_model/tab_model_selector_base.h"
+
+#include "base/android/jni_android.h"
+#include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/permissions/permission_request_manager.h"
+#include "content/public/browser/web_contents.h"
+#include "jni/TabModelSelectorBase_jni.h"
+
+using base::android::JavaParamRef;
+
+static void OnActiveTabChanged(
+ JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jobject>& java_old_web_contents,
+ const JavaParamRef<jobject>& java_new_web_contents) {
+ // Check if PermissionRequestManager is reused on Android to manage infobars.
+ // This is currently behind a switch flag.
+ if (!PermissionRequestManager::IsEnabled())
+ return;
+
+ // Visible permission infobars will get hidden and shown when switching tabs
+ // by the infobar infrastructure, but we do this explicitly to create/destroy
+ // PermissionPromptAndroid for old and new tabs. This also keeps the codepath
+ // consistent across different platforms.
+ content::WebContents* old_contents =
+ content::WebContents::FromJavaWebContents(java_old_web_contents);
+ content::WebContents* new_contents =
+ content::WebContents::FromJavaWebContents(java_new_web_contents);
+ DCHECK(new_contents);
+ if (old_contents)
+ PermissionRequestManager::FromWebContents(old_contents)->HideBubble();
+
+ if (new_contents) {
+ PermissionRequestManager::FromWebContents(new_contents)
+ ->DisplayPendingRequests();
+ }
+}
+
+// Register native methods
+bool RegisterTabModelSelectorBase(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model_selector_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698