| 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 "content/shell/renderer/shell_content_renderer_client.h" | 5 #include "content/shell/renderer/shell_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/cdm/renderer/external_clear_key_key_system_properties.h" | 13 #include "components/cdm/renderer/external_clear_key_key_system_properties.h" |
| 14 #include "components/web_cache/renderer/web_cache_impl.h" | 14 #include "components/web_cache/renderer/web_cache_impl.h" |
| 15 #include "content/public/child/child_thread.h" |
| 16 #include "content/public/common/service_manager_connection.h" |
| 17 #include "content/public/common/simple_connection_filter.h" |
| 15 #include "content/public/test/test_service.mojom.h" | 18 #include "content/public/test/test_service.mojom.h" |
| 16 #include "content/shell/common/shell_switches.h" | 19 #include "content/shell/common/shell_switches.h" |
| 17 #include "content/shell/renderer/shell_render_view_observer.h" | 20 #include "content/shell/renderer/shell_render_view_observer.h" |
| 18 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 19 #include "mojo/public/cpp/system/message_pipe.h" | 22 #include "mojo/public/cpp/system/message_pipe.h" |
| 20 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
| 21 #include "services/service_manager/public/cpp/interface_registry.h" | 24 #include "services/service_manager/public/cpp/binder_registry.h" |
| 22 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 25 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 23 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 24 #include "v8/include/v8.h" | 27 #include "v8/include/v8.h" |
| 25 | 28 |
| 26 #if BUILDFLAG(ENABLE_PLUGINS) | 29 #if BUILDFLAG(ENABLE_PLUGINS) |
| 27 #include "ppapi/shared_impl/ppapi_switches.h" // nogncheck | 30 #include "ppapi/shared_impl/ppapi_switches.h" // nogncheck |
| 28 #endif | 31 #endif |
| 29 | 32 |
| 30 #if defined(ENABLE_MOJO_CDM) | 33 #if defined(ENABLE_MOJO_CDM) |
| 31 #include "base/feature_list.h" | 34 #include "base/feature_list.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 98 |
| 96 } // namespace | 99 } // namespace |
| 97 | 100 |
| 98 ShellContentRendererClient::ShellContentRendererClient() {} | 101 ShellContentRendererClient::ShellContentRendererClient() {} |
| 99 | 102 |
| 100 ShellContentRendererClient::~ShellContentRendererClient() { | 103 ShellContentRendererClient::~ShellContentRendererClient() { |
| 101 } | 104 } |
| 102 | 105 |
| 103 void ShellContentRendererClient::RenderThreadStarted() { | 106 void ShellContentRendererClient::RenderThreadStarted() { |
| 104 web_cache_impl_.reset(new web_cache::WebCacheImpl()); | 107 web_cache_impl_.reset(new web_cache::WebCacheImpl()); |
| 108 |
| 109 auto registry = base::MakeUnique<service_manager::BinderRegistry>(); |
| 110 registry->AddInterface<mojom::TestService>( |
| 111 base::Bind(&CreateTestService), base::ThreadTaskRunnerHandle::Get()); |
| 112 content::ChildThread::Get() |
| 113 ->GetServiceManagerConnection() |
| 114 ->AddConnectionFilter( |
| 115 base::MakeUnique<SimpleConnectionFilter>(std::move(registry))); |
| 105 } | 116 } |
| 106 | 117 |
| 107 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { | 118 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { |
| 108 new ShellRenderViewObserver(render_view); | 119 new ShellRenderViewObserver(render_view); |
| 109 } | 120 } |
| 110 | 121 |
| 111 bool ShellContentRendererClient::IsPluginAllowedToUseCompositorAPI( | 122 bool ShellContentRendererClient::IsPluginAllowedToUseCompositorAPI( |
| 112 const GURL& url) { | 123 const GURL& url) { |
| 113 #if BUILDFLAG(ENABLE_PLUGINS) | 124 #if BUILDFLAG(ENABLE_PLUGINS) |
| 114 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 125 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 128 } | 139 } |
| 129 | 140 |
| 130 void ShellContentRendererClient::DidInitializeWorkerContextOnWorkerThread( | 141 void ShellContentRendererClient::DidInitializeWorkerContextOnWorkerThread( |
| 131 v8::Local<v8::Context> context) { | 142 v8::Local<v8::Context> context) { |
| 132 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 143 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 switches::kExposeInternalsForTesting)) { | 144 switches::kExposeInternalsForTesting)) { |
| 134 blink::WebTestingSupport::InjectInternalsObject(context); | 145 blink::WebTestingSupport::InjectInternalsObject(context); |
| 135 } | 146 } |
| 136 } | 147 } |
| 137 | 148 |
| 138 void ShellContentRendererClient::ExposeInterfacesToBrowser( | |
| 139 service_manager::InterfaceRegistry* interface_registry) { | |
| 140 interface_registry->AddInterface<mojom::TestService>( | |
| 141 base::Bind(&CreateTestService)); | |
| 142 } | |
| 143 | |
| 144 #if defined(ENABLE_MOJO_CDM) | 149 #if defined(ENABLE_MOJO_CDM) |
| 145 void ShellContentRendererClient::AddSupportedKeySystems( | 150 void ShellContentRendererClient::AddSupportedKeySystems( |
| 146 std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) { | 151 std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) { |
| 147 if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) | 152 if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) |
| 148 return; | 153 return; |
| 149 | 154 |
| 150 static const char kExternalClearKeyKeySystem[] = | 155 static const char kExternalClearKeyKeySystem[] = |
| 151 "org.chromium.externalclearkey"; | 156 "org.chromium.externalclearkey"; |
| 152 key_systems->emplace_back( | 157 key_systems->emplace_back( |
| 153 new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); | 158 new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); |
| 154 } | 159 } |
| 155 #endif | 160 #endif |
| 156 | 161 |
| 157 } // namespace content | 162 } // namespace content |
| OLD | NEW |