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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2763613002: Add DelayNavigationThrottle (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 40 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
41 #include "chrome/browser/budget_service/budget_service_impl.h" 41 #include "chrome/browser/budget_service/budget_service_impl.h"
42 #include "chrome/browser/chrome_content_browser_client_parts.h" 42 #include "chrome/browser/chrome_content_browser_client_parts.h"
43 #include "chrome/browser/chrome_quota_permission_context.h" 43 #include "chrome/browser/chrome_quota_permission_context.h"
44 #include "chrome/browser/content_settings/cookie_settings_factory.h" 44 #include "chrome/browser/content_settings/cookie_settings_factory.h"
45 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 45 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
46 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 46 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
47 #include "chrome/browser/defaults.h" 47 #include "chrome/browser/defaults.h"
48 #include "chrome/browser/download/download_prefs.h" 48 #include "chrome/browser/download/download_prefs.h"
49 #include "chrome/browser/font_family_cache.h" 49 #include "chrome/browser/font_family_cache.h"
50 #include "chrome/browser/loader/delay_navigation_throttle.h"
50 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 51 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
51 #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h" 52 #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h"
52 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 53 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
53 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 54 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
54 #include "chrome/browser/net_benchmarking.h" 55 #include "chrome/browser/net_benchmarking.h"
55 #include "chrome/browser/notifications/platform_notification_service_impl.h" 56 #include "chrome/browser/notifications/platform_notification_service_impl.h"
56 #include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h" 57 #include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h"
57 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 58 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
58 #include "chrome/browser/permissions/permission_context_base.h" 59 #include "chrome/browser/permissions/permission_context_base.h"
59 #include "chrome/browser/platform_util.h" 60 #include "chrome/browser/platform_util.h"
(...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), 3356 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
3356 metric, url); 3357 metric, url);
3357 } 3358 }
3358 } 3359 }
3359 3360
3360 std::vector<std::unique_ptr<content::NavigationThrottle>> 3361 std::vector<std::unique_ptr<content::NavigationThrottle>>
3361 ChromeContentBrowserClient::CreateThrottlesForNavigation( 3362 ChromeContentBrowserClient::CreateThrottlesForNavigation(
3362 content::NavigationHandle* handle) { 3363 content::NavigationHandle* handle) {
3363 std::vector<std::unique_ptr<content::NavigationThrottle>> throttles; 3364 std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
3364 3365
3366 // MetricsNavigationThrottle requires that it runs before NavigationThrottles
3367 // that may delay or cancel navigations, so only NavigationThrottles that
3368 // don't delay or cancel navigations (e.g. throttles that are only observing
3369 // callbacks without affecting navigation behavior) should be added before
3370 // MetricsNavigationThrottle.
3371 if (handle->IsInMainFrame()) {
3372 throttles.push_back(
3373 page_load_metrics::MetricsNavigationThrottle::Create(handle));
3374 }
3375
3365 #if BUILDFLAG(ENABLE_PLUGINS) 3376 #if BUILDFLAG(ENABLE_PLUGINS)
3366 std::unique_ptr<content::NavigationThrottle> flash_url_throttle = 3377 std::unique_ptr<content::NavigationThrottle> flash_url_throttle =
3367 FlashDownloadInterception::MaybeCreateThrottleFor(handle); 3378 FlashDownloadInterception::MaybeCreateThrottleFor(handle);
3368 if (flash_url_throttle) 3379 if (flash_url_throttle)
3369 throttles.push_back(std::move(flash_url_throttle)); 3380 throttles.push_back(std::move(flash_url_throttle));
3370 #endif 3381 #endif
3371 3382
3372 if (handle->IsInMainFrame()) {
3373 throttles.push_back(
3374 page_load_metrics::MetricsNavigationThrottle::Create(handle));
3375 }
3376
3377 #if defined(OS_ANDROID) 3383 #if defined(OS_ANDROID)
3378 // TODO(davidben): This is insufficient to integrate with prerender properly. 3384 // TODO(davidben): This is insufficient to integrate with prerender properly.
3379 // https://crbug.com/370595 3385 // https://crbug.com/370595
3380 prerender::PrerenderContents* prerender_contents = 3386 prerender::PrerenderContents* prerender_contents =
3381 prerender::PrerenderContents::FromWebContents(handle->GetWebContents()); 3387 prerender::PrerenderContents::FromWebContents(handle->GetWebContents());
3382 if (!prerender_contents && handle->IsInMainFrame()) { 3388 if (!prerender_contents && handle->IsInMainFrame()) {
3383 throttles.push_back( 3389 throttles.push_back(
3384 navigation_interception::InterceptNavigationDelegate::CreateThrottleFor( 3390 navigation_interception::InterceptNavigationDelegate::CreateThrottleFor(
3385 handle)); 3391 handle));
3386 } 3392 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 } 3428 }
3423 } 3429 }
3424 } 3430 }
3425 #endif 3431 #endif
3426 3432
3427 #if BUILDFLAG(ENABLE_EXTENSIONS) 3433 #if BUILDFLAG(ENABLE_EXTENSIONS)
3428 throttles.push_back( 3434 throttles.push_back(
3429 base::MakeUnique<extensions::ExtensionNavigationThrottle>(handle)); 3435 base::MakeUnique<extensions::ExtensionNavigationThrottle>(handle));
3430 #endif 3436 #endif
3431 3437
3438 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.
3439 std::unique_ptr<content::NavigationThrottle> delay_navigation_throttle =
3440 DelayNavigationThrottle::MaybeCreateThrottleFor(handle);
3441 if (delay_navigation_throttle)
3442 throttles.push_back(std::move(delay_navigation_throttle));
3443 }
3444
3432 return throttles; 3445 return throttles;
3433 } 3446 }
3434 3447
3435 std::unique_ptr<content::NavigationUIData> 3448 std::unique_ptr<content::NavigationUIData>
3436 ChromeContentBrowserClient::GetNavigationUIData( 3449 ChromeContentBrowserClient::GetNavigationUIData(
3437 content::NavigationHandle* navigation_handle) { 3450 content::NavigationHandle* navigation_handle) {
3438 return base::MakeUnique<ChromeNavigationUIData>(navigation_handle); 3451 return base::MakeUnique<ChromeNavigationUIData>(navigation_handle);
3439 } 3452 }
3440 3453
3441 content::DevToolsManagerDelegate* 3454 content::DevToolsManagerDelegate*
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { 3579 RedirectNonUINonIOBrowserThreadsToTaskScheduler() {
3567 return variations::GetVariationParamValue( 3580 return variations::GetVariationParamValue(
3568 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; 3581 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true";
3569 } 3582 }
3570 3583
3571 // static 3584 // static
3572 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( 3585 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting(
3573 const storage::QuotaSettings* settings) { 3586 const storage::QuotaSettings* settings) {
3574 g_default_quota_settings = settings; 3587 g_default_quota_settings = settings;
3575 } 3588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698