Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2763613002: Add DelayNavigationThrottle (Closed)
Patch Set: address some comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0df85c90cfa1d5cd6bdb6e98ee147102697d362b 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,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;
}

Powered by Google App Engine
This is Rietveld 408576698