OLD | NEW |
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/renderer/chrome_render_thread_observer.h" | 5 #include "chrome/renderer/chrome_render_thread_observer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
32 #include "chrome/common/media/media_resource_provider.h" | 32 #include "chrome/common/media/media_resource_provider.h" |
33 #include "chrome/common/net/net_resource_provider.h" | 33 #include "chrome/common/net/net_resource_provider.h" |
34 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
35 #include "chrome/common/resource_usage_reporter.mojom.h" | 35 #include "chrome/common/resource_usage_reporter.mojom.h" |
36 #include "chrome/common/resource_usage_reporter_type_converters.h" | 36 #include "chrome/common/resource_usage_reporter_type_converters.h" |
37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
38 #include "chrome/renderer/content_settings_observer.h" | 38 #include "chrome/renderer/content_settings_observer.h" |
39 #include "chrome/renderer/security_filter_peer.h" | 39 #include "chrome/renderer/security_filter_peer.h" |
40 #include "components/visitedlink/renderer/visitedlink_slave.h" | 40 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 41 #include "content/public/child/child_thread.h" |
41 #include "content/public/child/resource_dispatcher_delegate.h" | 42 #include "content/public/child/resource_dispatcher_delegate.h" |
42 #include "content/public/common/associated_interface_registry.h" | 43 #include "content/public/common/associated_interface_registry.h" |
43 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
| 45 #include "content/public/common/service_manager_connection.h" |
44 #include "content/public/common/service_names.mojom.h" | 46 #include "content/public/common/service_names.mojom.h" |
| 47 #include "content/public/common/simple_connection_filter.h" |
45 #include "content/public/renderer/render_thread.h" | 48 #include "content/public/renderer/render_thread.h" |
46 #include "content/public/renderer/render_view.h" | 49 #include "content/public/renderer/render_view.h" |
47 #include "content/public/renderer/render_view_visitor.h" | 50 #include "content/public/renderer/render_view_visitor.h" |
48 #include "extensions/features/features.h" | 51 #include "extensions/features/features.h" |
49 #include "media/base/localized_strings.h" | 52 #include "media/base/localized_strings.h" |
50 #include "mojo/public/cpp/bindings/strong_binding.h" | 53 #include "mojo/public/cpp/bindings/strong_binding.h" |
51 #include "net/base/net_errors.h" | 54 #include "net/base/net_errors.h" |
52 #include "net/base/net_module.h" | 55 #include "net/base/net_module.h" |
| 56 #include "services/service_manager/public/cpp/binder_registry.h" |
53 #include "services/service_manager/public/cpp/connector.h" | 57 #include "services/service_manager/public/cpp/connector.h" |
54 #include "services/service_manager/public/cpp/interface_registry.h" | |
55 #include "third_party/WebKit/public/platform/WebCache.h" | 58 #include "third_party/WebKit/public/platform/WebCache.h" |
56 #include "third_party/WebKit/public/web/WebDocument.h" | 59 #include "third_party/WebKit/public/web/WebDocument.h" |
57 #include "third_party/WebKit/public/web/WebFrame.h" | 60 #include "third_party/WebKit/public/web/WebFrame.h" |
58 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 61 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
59 #include "third_party/WebKit/public/web/WebView.h" | 62 #include "third_party/WebKit/public/web/WebView.h" |
60 | 63 |
61 #if BUILDFLAG(ENABLE_EXTENSIONS) | 64 #if BUILDFLAG(ENABLE_EXTENSIONS) |
62 #include "chrome/renderer/extensions/extension_localization_peer.h" | 65 #include "chrome/renderer/extensions/extension_localization_peer.h" |
63 #endif | 66 #endif |
64 | 67 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 237 |
235 bool ChromeRenderThreadObserver::is_incognito_process_ = false; | 238 bool ChromeRenderThreadObserver::is_incognito_process_ = false; |
236 | 239 |
237 ChromeRenderThreadObserver::ChromeRenderThreadObserver() | 240 ChromeRenderThreadObserver::ChromeRenderThreadObserver() |
238 : visited_link_slave_(new visitedlink::VisitedLinkSlave), | 241 : visited_link_slave_(new visitedlink::VisitedLinkSlave), |
239 weak_factory_(this) { | 242 weak_factory_(this) { |
240 RenderThread* thread = RenderThread::Get(); | 243 RenderThread* thread = RenderThread::Get(); |
241 resource_delegate_.reset(new RendererResourceDelegate()); | 244 resource_delegate_.reset(new RendererResourceDelegate()); |
242 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); | 245 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); |
243 | 246 |
244 thread->GetInterfaceRegistry()->AddInterface( | |
245 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr())); | |
246 | |
247 // Configure modules that need access to resources. | 247 // Configure modules that need access to resources. |
248 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 248 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
249 media::SetLocalizedStringProvider( | 249 media::SetLocalizedStringProvider( |
250 chrome_common_media::LocalizedStringProvider); | 250 chrome_common_media::LocalizedStringProvider); |
251 | 251 |
252 // chrome-native: is a scheme used for placeholder navigations that allow | 252 // chrome-native: is a scheme used for placeholder navigations that allow |
253 // UIs to be drawn with platform native widgets instead of HTML. These pages | 253 // UIs to be drawn with platform native widgets instead of HTML. These pages |
254 // should not be accessible. No code should be runnable in these pages, | 254 // should not be accessible. No code should be runnable in these pages, |
255 // so it should not need to access anything nor should it allow javascript | 255 // so it should not need to access anything nor should it allow javascript |
256 // URLs since it should never be visible to the user. | 256 // URLs since it should never be visible to the user. |
257 // See also ChromeContentClient::AddAdditionalSchemes that adds it as an | 257 // See also ChromeContentClient::AddAdditionalSchemes that adds it as an |
258 // empty document scheme. | 258 // empty document scheme. |
259 WebString native_scheme(WebString::FromASCII(chrome::kChromeNativeScheme)); | 259 WebString native_scheme(WebString::FromASCII(chrome::kChromeNativeScheme)); |
260 WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(native_scheme); | 260 WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(native_scheme); |
261 WebSecurityPolicy::RegisterURLSchemeAsNotAllowingJavascriptURLs( | 261 WebSecurityPolicy::RegisterURLSchemeAsNotAllowingJavascriptURLs( |
262 native_scheme); | 262 native_scheme); |
263 | 263 |
264 thread->GetInterfaceRegistry()->AddInterface( | 264 auto registry = base::MakeUnique<service_manager::BinderRegistry>(); |
265 visited_link_slave_->GetBindCallback()); | 265 registry->AddInterface( |
| 266 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr()), |
| 267 base::ThreadTaskRunnerHandle::Get()); |
| 268 registry->AddInterface(visited_link_slave_->GetBindCallback(), |
| 269 base::ThreadTaskRunnerHandle::Get()); |
| 270 if (content::ChildThread::Get()) { |
| 271 content::ChildThread::Get() |
| 272 ->GetServiceManagerConnection() |
| 273 ->AddConnectionFilter(base::MakeUnique<content::SimpleConnectionFilter>( |
| 274 std::move(registry))); |
| 275 } |
266 } | 276 } |
267 | 277 |
268 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {} | 278 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {} |
269 | 279 |
270 void ChromeRenderThreadObserver::RegisterMojoInterfaces( | 280 void ChromeRenderThreadObserver::RegisterMojoInterfaces( |
271 content::AssociatedInterfaceRegistry* associated_interfaces) { | 281 content::AssociatedInterfaceRegistry* associated_interfaces) { |
272 associated_interfaces->AddInterface(base::Bind( | 282 associated_interfaces->AddInterface(base::Bind( |
273 &ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest, | 283 &ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest, |
274 base::Unretained(this))); | 284 base::Unretained(this))); |
275 } | 285 } |
(...skipping 29 matching lines...) Expand all Loading... |
305 | 315 |
306 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( | 316 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( |
307 chrome::mojom::RendererConfigurationAssociatedRequest request) { | 317 chrome::mojom::RendererConfigurationAssociatedRequest request) { |
308 renderer_configuration_bindings_.AddBinding(this, std::move(request)); | 318 renderer_configuration_bindings_.AddBinding(this, std::move(request)); |
309 } | 319 } |
310 | 320 |
311 const RendererContentSettingRules* | 321 const RendererContentSettingRules* |
312 ChromeRenderThreadObserver::content_setting_rules() const { | 322 ChromeRenderThreadObserver::content_setting_rules() const { |
313 return &content_setting_rules_; | 323 return &content_setting_rules_; |
314 } | 324 } |
OLD | NEW |