Commit a242af07 authored by David Jacobo's avatar David Jacobo Committed by Commit Bot

Close ArcExternalProtocolDialog auth tabs

Automatically close tabs after the user is authenticated and redirected
to an ARC app. ArcWebContentsData can be removed via
ArcExternalProtocolDialog as well as in AppsNavigationThrottle, with
this we try to reduce the scope of the flag as much as possible while
still allowing the user to bypass the UI and automatically close tabs
left behind in the process.

Bug: 838294
Test: Build, unit_tests still works
Change-Id: Ifb812a3fab2fe7f49f07b4fbaee754ac96ea158f
Reviewed-on: https://chromium-review.googlesource.com/1026870
Commit-Queue: David Jacobo <djacobo@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558113}
parent e80f5c9a
...@@ -43,11 +43,18 @@ void ShowFallbackExternalProtocolDialog(int render_process_host_id, ...@@ -43,11 +43,18 @@ void ShowFallbackExternalProtocolDialog(int render_process_host_id,
new ExternalProtocolDialog(web_contents, url); new ExternalProtocolDialog(web_contents, url);
} }
void CloseTabIfNeeded(int render_process_host_id, int routing_id) { void CloseTabIfNeeded(int render_process_host_id,
int routing_id,
bool safe_to_bypass_ui) {
WebContents* web_contents = WebContents* web_contents =
tab_util::GetWebContentsByID(render_process_host_id, routing_id); tab_util::GetWebContentsByID(render_process_host_id, routing_id);
if (web_contents && web_contents->GetController().IsInitialNavigation()) if (!web_contents)
return;
if (web_contents->GetController().IsInitialNavigation() ||
safe_to_bypass_ui) {
web_contents->Close(); web_contents->Close();
}
} }
// Tells whether or not Chrome is an app candidate for the current navigation. // Tells whether or not Chrome is an app candidate for the current navigation.
...@@ -115,7 +122,7 @@ void HandleUrlInArc(int render_process_host_id, ...@@ -115,7 +122,7 @@ void HandleUrlInArc(int render_process_host_id,
instance->HandleIntent(CreateIntentInfo(url_and_activity.first, ui_bypassed), instance->HandleIntent(CreateIntentInfo(url_and_activity.first, ui_bypassed),
std::move(activity)); std::move(activity));
CloseTabIfNeeded(render_process_host_id, routing_id); CloseTabIfNeeded(render_process_host_id, routing_id, ui_bypassed);
} }
// A helper function called by GetAction(). // A helper function called by GetAction().
...@@ -305,10 +312,11 @@ GURL GetUrlToNavigateOnDeactivate( ...@@ -305,10 +312,11 @@ GURL GetUrlToNavigateOnDeactivate(
void OnIntentPickerDialogDeactivated( void OnIntentPickerDialogDeactivated(
int render_process_host_id, int render_process_host_id,
int routing_id, int routing_id,
bool safe_to_bypass_ui,
const std::vector<mojom::IntentHandlerInfoPtr>& handlers) { const std::vector<mojom::IntentHandlerInfoPtr>& handlers) {
const GURL url_to_open_in_chrome = GetUrlToNavigateOnDeactivate(handlers); const GURL url_to_open_in_chrome = GetUrlToNavigateOnDeactivate(handlers);
if (url_to_open_in_chrome.is_empty()) if (url_to_open_in_chrome.is_empty())
CloseTabIfNeeded(render_process_host_id, routing_id); CloseTabIfNeeded(render_process_host_id, routing_id, safe_to_bypass_ui);
else else
OpenUrlInChrome(render_process_host_id, routing_id, url_to_open_in_chrome); OpenUrlInChrome(render_process_host_id, routing_id, url_to_open_in_chrome);
} }
...@@ -386,7 +394,7 @@ void OnIntentPickerClosed(int render_process_host_id, ...@@ -386,7 +394,7 @@ void OnIntentPickerClosed(int render_process_host_id,
case chromeos::IntentPickerCloseReason::DIALOG_DEACTIVATED: case chromeos::IntentPickerCloseReason::DIALOG_DEACTIVATED:
// The user didn't select any ARC activity. // The user didn't select any ARC activity.
OnIntentPickerDialogDeactivated(render_process_host_id, routing_id, OnIntentPickerDialogDeactivated(render_process_host_id, routing_id,
handlers); safe_to_bypass_ui, handlers);
break; break;
} }
......
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