Chromium Code Reviews| 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..229ac3006a8c73740ba2892c0e4f89ee0b26b117 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, |
| }; |
| @@ -259,6 +261,33 @@ void JavaScriptDialogTabHelper::WasHidden() { |
| } |
| } |
| +// 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_ && navigation_handle->IsInMainFrame()) { |
|
Charlie Reis
2016/12/01 21:36:48
nit: No braces?
What's the reason for the IsInMai
Avi (use Gerrit)
2016/12/01 23:20:08
Done.
Charlie Reis
2016/12/01 23:30:26
Cool! I thought I needed a flag, but yes, it work
Avi (use Gerrit)
2016/12/02 01:32:26
Acknowledged.
|
| + 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( |
|
Charlie Reis
2016/12/01 21:36:48
Sanity check: This is only called for browser-init
Avi (use Gerrit)
2016/12/01 23:20:07
This is intended to deal with the user clicking th
Charlie Reis
2016/12/01 23:30:26
Sounds good. (Presumably you also care about omni
Avi (use Gerrit)
2016/12/02 01:32:26
This fixes navigations that happen within the same
|
| + 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_) { |
|
Charlie Reis
2016/12/01 21:36:48
nit: No braces?
Interesting that this doesn't che
Avi (use Gerrit)
2016/12/01 23:20:08
I'm agreeing that we should drop main frame checks
|
| + CloseDialog(false, false, base::string16(), DismissalCause::TAB_NAVIGATED); |
| + } |
| +} |
| + |
| void JavaScriptDialogTabHelper::OnBrowserSetLastActive(Browser* browser) { |
| if (dialog_ && !IsWebContentsForemost(web_contents())) { |
| CloseDialog(false, false, base::string16(), |