Index: chrome/browser/chrome_content_browser_client.cc |
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
index 5d484d3b395bfa100a761302baa44b2b37c8e1c2..c544ce9c93f84a170424e10e058a94fc954cc9b1 100644 |
--- a/chrome/browser/chrome_content_browser_client.cc |
+++ b/chrome/browser/chrome_content_browser_client.cc |
@@ -53,6 +53,7 @@ |
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
#include "chrome/browser/net_benchmarking.h" |
#include "chrome/browser/notifications/platform_notification_service_impl.h" |
+#include "chrome/browser/page_load_metrics/experiments/delay_navigation_throttle.h" |
#include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h" |
#include "chrome/browser/password_manager/chrome_password_manager_client.h" |
#include "chrome/browser/permissions/permission_context_base.h" |
@@ -3362,6 +3363,16 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( |
content::NavigationHandle* handle) { |
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles; |
+ // MetricsNavigationThrottle requires that it runs before NavigationThrottles |
+ // that may delay or cancel navigations, so only NavigationThrottles that |
+ // don't delay or cancel navigations (e.g. throttles that are only observing |
+ // callbacks without affecting navigation behavior) should be added before |
+ // MetricsNavigationThrottle. |
+ if (handle->IsInMainFrame()) { |
+ throttles.push_back( |
+ page_load_metrics::MetricsNavigationThrottle::Create(handle)); |
+ } |
+ |
#if BUILDFLAG(ENABLE_PLUGINS) |
std::unique_ptr<content::NavigationThrottle> flash_url_throttle = |
FlashDownloadInterception::MaybeCreateThrottleFor(handle); |
@@ -3369,11 +3380,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( |
throttles.push_back(std::move(flash_url_throttle)); |
#endif |
- if (handle->IsInMainFrame()) { |
- throttles.push_back( |
- page_load_metrics::MetricsNavigationThrottle::Create(handle)); |
- } |
- |
#if defined(OS_ANDROID) |
// TODO(davidben): This is insufficient to integrate with prerender properly. |
// https://crbug.com/370595 |
@@ -3429,6 +3435,11 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( |
base::MakeUnique<extensions::ExtensionNavigationThrottle>(handle)); |
#endif |
+ std::unique_ptr<content::NavigationThrottle> delay_navigation_throttle = |
+ DelayNavigationThrottle::MaybeCreateThrottleFor(handle); |
+ if (delay_navigation_throttle) |
+ throttles.push_back(std::move(delay_navigation_throttle)); |
+ |
return throttles; |
} |