Commit 5fbf258f authored by Jiewei Qian's avatar Jiewei Qian Committed by Commit Bot

web-app-tab-helper: SetAppId early in ReadyToCommitNavigation

This CL is a preparation to perform App (tab) specific setup when the
app is launched. WebAppTabHelper will determine the AppId right before
the navigation is to be committed.

It is okay to do this because DidFinishNavigation is always called right
after ReadyToCommitNavigation. So we will end up navigating to the page,
thus this change will not lead to behavior differences.

Bug: 1024655
Change-Id: I3be85ae7e0ba5b87c25a150207a8b35468a60bfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2059694
Commit-Queue: Jiewei Qian  <qjw@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742514}
parent 4b66293f
...@@ -57,18 +57,25 @@ void WebAppTabHelper::SetAppId(const AppId& app_id) { ...@@ -57,18 +57,25 @@ void WebAppTabHelper::SetAppId(const AppId& app_id) {
OnAssociatedAppChanged(); OnAssociatedAppChanged();
} }
void WebAppTabHelper::DidFinishNavigation( void WebAppTabHelper::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) if (!navigation_handle->IsInMainFrame())
return; return;
is_error_page_ = navigation_handle->IsErrorPage();
const GURL& url = navigation_handle->GetURL(); const GURL& url = navigation_handle->GetURL();
const AppId app_id = FindAppIdWithUrlInScope(url); const AppId app_id = FindAppIdWithUrlInScope(url);
SetAppId(app_id); SetAppId(app_id);
}
void WebAppTabHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
return;
is_error_page_ = navigation_handle->IsErrorPage();
provider_->manifest_update_manager().MaybeUpdate(url, app_id, web_contents()); provider_->manifest_update_manager().MaybeUpdate(navigation_handle->GetURL(),
GetAppId(), web_contents());
ReinstallPlaceholderAppIfNecessary(navigation_handle->GetURL()); ReinstallPlaceholderAppIfNecessary(navigation_handle->GetURL());
} }
......
...@@ -39,6 +39,8 @@ class WebAppTabHelper : public WebAppTabHelperBase, ...@@ -39,6 +39,8 @@ class WebAppTabHelper : public WebAppTabHelperBase,
const base::UnguessableToken& GetAudioFocusGroupIdForTesting() const override; const base::UnguessableToken& GetAudioFocusGroupIdForTesting() const override;
// content::WebContentsObserver: // content::WebContentsObserver:
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFinishNavigation( void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override; content::NavigationHandle* navigation_handle) override;
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override; void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
......
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