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

Unified Diff: chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc

Issue 2541173003: Allow navigation while a JavaScript dialog is up. (Closed)
Patch Set: test cleaner 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/javascript_dialogs/javascript_dialog_tab_helper.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
diff --git a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
index 228350fa12cad54b97ae342c52aadc781c9b4938..f23e226ea843de8a7085ba0234e1d1dd32c45614 100644
--- a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
+++ b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "components/app_modal/javascript_dialog_manager.h"
+#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper);
@@ -66,6 +67,7 @@ enum class JavaScriptDialogTabHelper::DismissalCause {
TAB_HIDDEN = 4,
BROWSER_SWITCHED = 5,
DIALOG_BUTTON_CLICKED = 6,
+ TAB_NAVIGATED = 7,
MAX,
};
@@ -244,9 +246,10 @@ void JavaScriptDialogTabHelper::CancelDialogs(
content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) {
- if (dialog_)
+ if (dialog_) {
CloseDialog(suppress_callbacks, false, base::string16(),
DismissalCause::CANCEL_DIALOGS_CALLED);
+ }
// Cancel any app-modal dialogs being run by the app-modal dialog system.
return AppModalDialogManager()->CancelDialogs(
@@ -254,9 +257,33 @@ void JavaScriptDialogTabHelper::CancelDialogs(
}
void JavaScriptDialogTabHelper::WasHidden() {
- if (dialog_) {
+ if (dialog_)
CloseDialog(false, false, base::string16(), DismissalCause::TAB_HIDDEN);
- }
+}
+
+// This function handles the case where browser-side navigation (PlzNavigate) is
+// enabled. DidStartNavigationToPendingEntry, below, handles the case where
+// PlzNavigate is not enabled. TODO(avi): When the non-PlzNavigate code is
+// removed, remove DidStartNavigationToPendingEntry.
+void JavaScriptDialogTabHelper::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ // Close the dialog if the user started a new navigation. This allows reloads
+ // and history navigations to proceed.
+ if (dialog_)
+ CloseDialog(false, false, base::string16(), DismissalCause::TAB_NAVIGATED);
+}
+
+// This function handles the case where browser-side navigation (PlzNavigate) is
+// not enabled. DidStartNavigation, above, handles the case where PlzNavigate is
+// enabled. TODO(avi): When the non-PlzNavigate code is removed, remove
+// DidStartNavigationToPendingEntry.
+void JavaScriptDialogTabHelper::DidStartNavigationToPendingEntry(
+ const GURL& url,
+ content::ReloadType reload_type) {
+ // Close the dialog if the user started a new navigation. This allows reloads
+ // and history navigations to proceed.
+ if (dialog_)
+ CloseDialog(false, false, base::string16(), DismissalCause::TAB_NAVIGATED);
}
void JavaScriptDialogTabHelper::OnBrowserSetLastActive(Browser* browser) {
« no previous file with comments | « chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698