Commit 55464ecb authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

[IntentHandling] Remove defer navigation.

In the case of getting apps from app service, there is no need to defer
the navigation. Update the code to move the icon loading code out of
defer navigation and never defer navigation.

BUG=853604

Change-Id: Idbc0dba4eb18eea16dfe907be7849877f0879395
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2367232Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800447}
parent 8a0e7eb8
......@@ -199,7 +199,7 @@ class AppsNavigationThrottle : public content::NavigationThrottle {
virtual bool ShouldCancelNavigation(content::NavigationHandle* handle);
void ShowIntentPickerForApps(
virtual void ShowIntentPickerForApps(
content::WebContents* web_contents,
IntentPickerAutoDisplayService* ui_auto_display_service,
const GURL& url,
......
......@@ -259,44 +259,30 @@ bool CommonAppsNavigationThrottle::ShouldCancelNavigation(
return false;
}
bool CommonAppsNavigationThrottle::ShouldDeferNavigation(
content::NavigationHandle* handle) {
content::WebContents* web_contents = handle->GetWebContents();
const GURL& url = handle->GetURL();
std::vector<apps::IntentPickerAppInfo> apps_for_picker =
FindAllAppsForUrl(web_contents, url, {});
if (apps_for_picker.empty())
return false;
void CommonAppsNavigationThrottle::ShowIntentPickerForApps(
content::WebContents* web_contents,
IntentPickerAutoDisplayService* ui_auto_display_service,
const GURL& url,
std::vector<IntentPickerAppInfo> apps,
IntentPickerResponse callback) {
if (apps.empty()) {
IntentPickerTabHelper::SetShouldShowIcon(web_contents, false);
ui_displayed_ = false;
return;
}
if (GetPickerShowState(apps_for_picker, web_contents, url) ==
if (GetPickerShowState(apps, web_contents, url) ==
PickerShowState::kOmnibox) {
return false;
ui_displayed_ = false;
IntentPickerTabHelper::SetShouldShowIcon(web_contents, true);
return;
}
ui_displayed_ = true;
IntentPickerTabHelper::LoadAppIcons(
web_contents, std::move(apps_for_picker),
base::BindOnce(
&CommonAppsNavigationThrottle::OnDeferredNavigationProcessed,
weak_factory_.GetWeakPtr()));
return true;
}
void CommonAppsNavigationThrottle::OnDeferredNavigationProcessed(
std::vector<apps::IntentPickerAppInfo> apps) {
content::NavigationHandle* handle = navigation_handle();
content::WebContents* web_contents = handle->GetWebContents();
const GURL& url = handle->GetURL();
ShowIntentPickerForApps(web_contents, ui_auto_display_service_, url,
std::move(apps),
base::BindOnce(&OnIntentPickerClosed, web_contents,
ui_auto_display_service_, url));
// We are about to resume the navigation, which may destroy this object.
Resume();
web_contents, std::move(apps),
base::BindOnce(&OnAppIconsLoaded, web_contents, ui_auto_display_service,
url));
}
bool CommonAppsNavigationThrottle::ShouldAutoDisplayUi(
......
......@@ -91,10 +91,12 @@ class CommonAppsNavigationThrottle : public apps::AppsNavigationThrottle {
bool ShouldCancelNavigation(content::NavigationHandle* handle) override;
bool ShouldDeferNavigation(content::NavigationHandle* handle) override;
void OnDeferredNavigationProcessed(
std::vector<apps::IntentPickerAppInfo> apps);
void ShowIntentPickerForApps(
content::WebContents* web_contents,
IntentPickerAutoDisplayService* ui_auto_display_service,
const GURL& url,
std::vector<IntentPickerAppInfo> apps,
IntentPickerResponse callback) override;
// Whether or not the intent picker UI should be displayed without the user
// clicking in the omnibox's icon.
......
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