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

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

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Created 5 years, 3 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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/files/scoped_file.h" 15 #include "base/files/scoped_file.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
19 #include "base/prefs/scoped_user_pref_update.h" 19 #include "base/prefs/scoped_user_pref_update.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/thread_task_runner_handle.h" 24 #include "base/thread_task_runner_handle.h"
25 #include "base/threading/sequenced_worker_pool.h" 25 #include "base/threading/sequenced_worker_pool.h"
26 #include "chrome/browser/after_startup_task_utils.h" 26 #include "chrome/browser/after_startup_task_utils.h"
27 #include "chrome/browser/apps/app_url_redirector.h"
27 #include "chrome/browser/browser_about_handler.h" 28 #include "chrome/browser/browser_about_handler.h"
28 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/browser_shutdown.h" 30 #include "chrome/browser/browser_shutdown.h"
30 #include "chrome/browser/browsing_data/browsing_data_helper.h" 31 #include "chrome/browser/browsing_data/browsing_data_helper.h"
31 #include "chrome/browser/browsing_data/browsing_data_remover.h" 32 #include "chrome/browser/browsing_data/browsing_data_remover.h"
32 #include "chrome/browser/character_encoding.h" 33 #include "chrome/browser/character_encoding.h"
33 #include "chrome/browser/chrome_content_browser_client_parts.h" 34 #include "chrome/browser/chrome_content_browser_client_parts.h"
34 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" 35 #include "chrome/browser/chrome_net_benchmarking_message_filter.h"
35 #include "chrome/browser/chrome_quota_permission_context.h" 36 #include "chrome/browser/chrome_quota_permission_context.h"
36 #include "chrome/browser/content_settings/cookie_settings_factory.h" 37 #include "chrome/browser/content_settings/cookie_settings_factory.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #include "components/cdm/browser/cdm_message_filter_android.h" 98 #include "components/cdm/browser/cdm_message_filter_android.h"
98 #include "components/cloud_devices/common/cloud_devices_switches.h" 99 #include "components/cloud_devices/common/cloud_devices_switches.h"
99 #include "components/content_settings/core/browser/content_settings_utils.h" 100 #include "components/content_settings/core/browser/content_settings_utils.h"
100 #include "components/content_settings/core/browser/cookie_settings.h" 101 #include "components/content_settings/core/browser/cookie_settings.h"
101 #include "components/content_settings/core/browser/host_content_settings_map.h" 102 #include "components/content_settings/core/browser/host_content_settings_map.h"
102 #include "components/content_settings/core/common/content_settings.h" 103 #include "components/content_settings/core/common/content_settings.h"
103 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_m essage_filter.h" 104 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_m essage_filter.h"
104 #include "components/dom_distiller/core/url_constants.h" 105 #include "components/dom_distiller/core/url_constants.h"
105 #include "components/google/core/browser/google_util.h" 106 #include "components/google/core/browser/google_util.h"
106 #include "components/metrics/client_info.h" 107 #include "components/metrics/client_info.h"
108 #include "components/navigation_interception/intercept_navigation_delegate.h"
107 #include "components/pref_registry/pref_registry_syncable.h" 109 #include "components/pref_registry/pref_registry_syncable.h"
108 #include "components/rappor/rappor_utils.h" 110 #include "components/rappor/rappor_utils.h"
109 #include "components/signin/core/common/profile_management_switches.h" 111 #include "components/signin/core/common/profile_management_switches.h"
110 #include "components/translate/core/common/translate_switches.h" 112 #include "components/translate/core/common/translate_switches.h"
111 #include "components/url_formatter/url_fixer.h" 113 #include "components/url_formatter/url_fixer.h"
112 #include "components/variations/variations_associated_data.h" 114 #include "components/variations/variations_associated_data.h"
113 #include "components/version_info/version_info.h" 115 #include "components/version_info/version_info.h"
114 #include "content/public/browser/browser_child_process_host.h" 116 #include "content/public/browser/browser_child_process_host.h"
115 #include "content/public/browser/browser_main_parts.h" 117 #include "content/public/browser/browser_main_parts.h"
116 #include "content/public/browser/browser_ppapi_host.h" 118 #include "content/public/browser/browser_ppapi_host.h"
117 #include "content/public/browser/browser_thread.h" 119 #include "content/public/browser/browser_thread.h"
118 #include "content/public/browser/browser_url_handler.h" 120 #include "content/public/browser/browser_url_handler.h"
119 #include "content/public/browser/child_process_data.h" 121 #include "content/public/browser/child_process_data.h"
120 #include "content/public/browser/child_process_security_policy.h" 122 #include "content/public/browser/child_process_security_policy.h"
121 #include "content/public/browser/client_certificate_delegate.h" 123 #include "content/public/browser/client_certificate_delegate.h"
124 #include "content/public/browser/navigation_throttle.h"
122 #include "content/public/browser/render_frame_host.h" 125 #include "content/public/browser/render_frame_host.h"
123 #include "content/public/browser/render_process_host.h" 126 #include "content/public/browser/render_process_host.h"
124 #include "content/public/browser/render_view_host.h" 127 #include "content/public/browser/render_view_host.h"
125 #include "content/public/browser/resource_context.h" 128 #include "content/public/browser/resource_context.h"
126 #include "content/public/browser/site_instance.h" 129 #include "content/public/browser/site_instance.h"
127 #include "content/public/browser/web_contents.h" 130 #include "content/public/browser/web_contents.h"
128 #include "content/public/common/child_process_host.h" 131 #include "content/public/common/child_process_host.h"
129 #include "content/public/common/content_descriptors.h" 132 #include "content/public/common/content_descriptors.h"
130 #include "content/public/common/sandbox_type.h" 133 #include "content/public/common/sandbox_type.h"
131 #include "content/public/common/service_registry.h" 134 #include "content/public/common/service_registry.h"
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 } 2542 }
2540 2543
2541 void ChromeContentBrowserClient::RecordURLMetric(const std::string& metric, 2544 void ChromeContentBrowserClient::RecordURLMetric(const std::string& metric,
2542 const GURL& url) { 2545 const GURL& url) {
2543 if (url.is_valid()) { 2546 if (url.is_valid()) {
2544 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), 2547 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
2545 metric, url); 2548 metric, url);
2546 } 2549 }
2547 } 2550 }
2548 2551
2552 void ChromeContentBrowserClient::AddNavigationThrottles(
2553 content::NavigationHandle* handle,
2554 WebContents* web_contents) {
2555 #if defined(OS_ANDROID)
2556 // TODO(davidben): This is insufficient to integrate with prerender properly.
2557 // https://crbug.com/370595
2558 prerender::PrerenderContents* prerender_contents =
2559 prerender::PrerenderContents::FromWebContents(web_contents);
2560 if (!prerender_contents && handle->IsInMainFrame()) {
2561 handle->RegisterThrottle(
2562 navigation_interception::InterceptNavigationDelegate::CreateThrottleFor(
2563 handle, web_contents));
2564 }
2565 #else
2566 if (handle->IsInMainFrame()) {
2567 // Redirect some navigations to apps that have registered matching URL
2568 // handlers ('url_handlers' in the manifest).
2569 scoped_ptr<content::NavigationThrottle> url_to_app_throttle =
2570 AppUrlRedirector::MaybeCreateThrottleFor(handle, web_contents);
2571 if (url_to_app_throttle)
2572 handle->RegisterThrottle(url_to_app_throttle.Pass());
2573 }
Avi (use Gerrit) 2015/09/01 16:38:47 Do we really want to do this for every WebContents
davidben 2015/09/01 21:55:17 +1. If we can manage it, I think WebContentsDelega
clamy 2015/09/03 15:30:51 I initially put that in WebContentsDelegate, but i
2574 #endif
2575 }
2576
2549 content::DevToolsManagerDelegate* 2577 content::DevToolsManagerDelegate*
2550 ChromeContentBrowserClient::GetDevToolsManagerDelegate() { 2578 ChromeContentBrowserClient::GetDevToolsManagerDelegate() {
2551 return new ChromeDevToolsManagerDelegate(); 2579 return new ChromeDevToolsManagerDelegate();
2552 } 2580 }
2553 2581
2554 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { 2582 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() {
2555 #if !defined(OS_ANDROID) 2583 #if !defined(OS_ANDROID)
2556 return new ChromeTracingDelegate(); 2584 return new ChromeTracingDelegate();
2557 #else 2585 #else
2558 return nullptr; 2586 return nullptr;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 switches::kDisableWebRtcEncryption, 2647 switches::kDisableWebRtcEncryption,
2620 }; 2648 };
2621 to_command_line->CopySwitchesFrom(from_command_line, 2649 to_command_line->CopySwitchesFrom(from_command_line,
2622 kWebRtcDevSwitchNames, 2650 kWebRtcDevSwitchNames,
2623 arraysize(kWebRtcDevSwitchNames)); 2651 arraysize(kWebRtcDevSwitchNames));
2624 } 2652 }
2625 } 2653 }
2626 #endif // defined(ENABLE_WEBRTC) 2654 #endif // defined(ENABLE_WEBRTC)
2627 2655
2628 } // namespace chrome 2656 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698