Chromium Code Reviews| 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..4cd86b9a5b21c41a6b869c72ba09de9e4de2a95d 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -47,6 +47,7 @@ |
| #include "chrome/browser/defaults.h" |
| #include "chrome/browser/download/download_prefs.h" |
| #include "chrome/browser/font_family_cache.h" |
| +#include "chrome/browser/loader/delay_navigation_throttle.h" |
| #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h" |
| #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.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,13 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( |
| base::MakeUnique<extensions::ExtensionNavigationThrottle>(handle)); |
| #endif |
| + if (handle->IsInMainFrame()) { |
|
Charlie Harrison
2017/03/22 15:30:12
optional: Since you already have a MaybeCreate* me
Bryan McQuade
2017/03/22 18:00:01
sure, good idea, done.
|
| + 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; |
| } |