Commit fa30ba14 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

[TabModal] Short-term fix for JS dialog not showing in web apps

Use tab interactivity if tab model is not found in the tab model list.

Bug: 875595
Change-Id: I5fd69ed11e2f30733a25eaa98e353a98fc026a5e
Reviewed-on: https://chromium-review.googlesource.com/1188753Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586187}
parent af1529d9
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ui/gfx/text_elider.h" #include "ui/gfx/text_elider.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/ui/android/javascript_dialog_android.h" #include "chrome/browser/ui/android/javascript_dialog_android.h"
#include "chrome/browser/ui/android/tab_model/tab_model.h" #include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h" #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
...@@ -40,8 +41,15 @@ app_modal::JavaScriptDialogManager* AppModalDialogManager() { ...@@ -40,8 +41,15 @@ app_modal::JavaScriptDialogManager* AppModalDialogManager() {
bool IsWebContentsForemost(content::WebContents* web_contents) { bool IsWebContentsForemost(content::WebContents* web_contents) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents); TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents);
return tab_model && tab_model->IsCurrentModel() && if (tab_model) {
tab_model->GetActiveWebContents() == web_contents; return tab_model->IsCurrentModel() &&
tab_model->GetActiveWebContents() == web_contents;
} else {
// If tab model is not found (e.g. single tab model), fall back to check
// whether the tab for this web content is interactive.
TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
return tab && tab->IsUserInteractable();
}
#else #else
Browser* browser = BrowserList::GetInstance()->GetLastActive(); Browser* browser = BrowserList::GetInstance()->GetLastActive();
DCHECK(browser); DCHECK(browser);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment