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

Close tab or GoBack if the user select an ARC app.

If the user chooses to continue their navigation via 'Use app' on the
intent picker, thus escaping Chrome, make sure to either close the
current tab or navigate to the previous entry (if any).

Opening a desktop PWA reparents the tab which implicitly closes it in
the current browser and sends it to an app window, this is why we don't
use the new CloseOrGoBack method for the PWA case.

Bug: 678141
Test: Build.
Change-Id: Ie1bf38db0fce959a13ac94e751a6fa20495b0040
Reviewed-on: https://chromium-review.googlesource.com/756313Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: David Jacobo <djacobo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553345}
parent 1550bd3f
......@@ -165,8 +165,10 @@ void AppsNavigationThrottle::OnIntentPickerClosed(
}
break;
case AppType::ARC:
if (!arc::ArcNavigationThrottle::MaybeLaunchOrPersistArcApp(
if (arc::ArcNavigationThrottle::MaybeLaunchOrPersistArcApp(
url, launch_name, should_launch_app, should_persist)) {
CloseOrGoBack(web_contents);
} else {
close_reason = IntentPickerCloseReason::ERROR;
}
break;
......@@ -363,6 +365,15 @@ void AppsNavigationThrottle::ShowIntentPickerBubbleForApps(
web_contents, url));
}
// static
void AppsNavigationThrottle::CloseOrGoBack(content::WebContents* tab) {
DCHECK(tab);
if (tab->GetController().CanGoBack())
tab->GetController().GoBack();
else
tab->Close();
}
void AppsNavigationThrottle::CancelNavigation() {
content::WebContents* tab = navigation_handle()->GetWebContents();
if (tab && tab->GetController().IsInitialNavigation())
......
......@@ -6,6 +6,8 @@
#define CHROME_BROWSER_CHROMEOS_APPS_INTENT_HELPER_APPS_NAVIGATION_THROTTLE_H_
#include <memory>
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/gtest_prod_util.h"
......@@ -148,6 +150,8 @@ class AppsNavigationThrottle : public content::NavigationThrottle {
const GURL& url,
std::vector<IntentPickerAppInfo> apps);
static void CloseOrGoBack(content::WebContents* tab);
void CancelNavigation();
content::NavigationThrottle::ThrottleCheckResult HandleRequest();
......
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