Commit 45eee3a5 authored by Eric Lawrence's avatar Eric Lawrence Committed by Commit Bot

StartupObserver should detect downloads

The StartupObserver class monitors the startup of the browser and is
used to defer BEST_EFFORT tasks until after the browser has completed
startup and the active tab's page has finished loading.

The StartupObserver previously failed to detect the case where the
browser as launched to the url of a file download; it would then wait
for an additional navigation in the first tab or would wait until a
failsafe timeout was reached before indicating startup was complete.

This change signals completion in the scenario where a file download
takes place in the first tab. The failsafe timeout remains set at 3
minutes.

Bug: 1006954
Change-Id: Ia1e056f1a54ccc561d1dcf306161470beefe42e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846099Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Eric Lawrence [MSFT] <ericlaw@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#705711}
parent 6434a38c
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page_visibility_state.h" #include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -180,6 +181,14 @@ class StartupObserver : public WebContentsObserver { ...@@ -180,6 +181,14 @@ class StartupObserver : public WebContentsObserver {
OnStartupComplete(); OnStartupComplete();
} }
// Starting the browser with a file download url will not result in
// DidFinishLoad firing, so watch for this case too. crbug.com/1006954
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override {
if (navigation_handle->IsInMainFrame() && navigation_handle->IsDownload())
OnStartupComplete();
}
void WebContentsDestroyed() override { OnStartupComplete(); } void WebContentsDestroyed() override { OnStartupComplete(); }
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
......
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