| 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/test/test_mojo_service.mojom.h" | 15 #include "content/public/test/test_service.mojom.h" |
| 16 #include "content/shell/common/shell_switches.h" | 16 #include "content/shell/common/shell_switches.h" |
| 17 #include "content/shell/renderer/shell_render_view_observer.h" | 17 #include "content/shell/renderer/shell_render_view_observer.h" |
| 18 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
| 19 #include "mojo/public/cpp/system/message_pipe.h" | 19 #include "mojo/public/cpp/system/message_pipe.h" |
| 20 #include "services/shell/public/cpp/interface_registry.h" | 20 #include "services/shell/public/cpp/interface_registry.h" |
| 21 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 21 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 22 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
| 23 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
| 24 | 24 |
| 25 #if defined(ENABLE_PLUGINS) | 25 #if defined(ENABLE_PLUGINS) |
| 26 #include "ppapi/shared_impl/ppapi_switches.h" | 26 #include "ppapi/shared_impl/ppapi_switches.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 30 #include "base/feature_list.h" | 30 #include "base/feature_list.h" |
| 31 #include "media/base/media_switches.h" | 31 #include "media/base/media_switches.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // A test Mojo service which can be driven by browser tests for various reasons. | 38 // A test service which can be driven by browser tests for various reasons. |
| 39 class TestMojoServiceImpl : public mojom::TestMojoService { | 39 class TestServiceImpl : public mojom::TestService { |
| 40 public: | 40 public: |
| 41 explicit TestMojoServiceImpl(mojom::TestMojoServiceRequest request) | 41 explicit TestServiceImpl(mojom::TestServiceRequest request) |
| 42 : binding_(this, std::move(request)) { | 42 : binding_(this, std::move(request)) { |
| 43 binding_.set_connection_error_handler( | 43 binding_.set_connection_error_handler( |
| 44 base::Bind(&TestMojoServiceImpl::OnConnectionError, | 44 base::Bind(&TestServiceImpl::OnConnectionError, |
| 45 base::Unretained(this))); | 45 base::Unretained(this))); |
| 46 } | 46 } |
| 47 | 47 |
| 48 ~TestMojoServiceImpl() override {} | 48 ~TestServiceImpl() override {} |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 void OnConnectionError() { delete this; } | 51 void OnConnectionError() { delete this; } |
| 52 | 52 |
| 53 // mojom::TestMojoService: | 53 // mojom::TestService: |
| 54 void DoSomething(const DoSomethingCallback& callback) override { | 54 void DoSomething(const DoSomethingCallback& callback) override { |
| 55 // Instead of responding normally, unbind the pipe, write some garbage, | 55 // Instead of responding normally, unbind the pipe, write some garbage, |
| 56 // and go away. | 56 // and go away. |
| 57 const std::string kBadMessage = "This is definitely not a valid response!"; | 57 const std::string kBadMessage = "This is definitely not a valid response!"; |
| 58 mojo::ScopedMessagePipeHandle pipe = binding_.Unbind().PassMessagePipe(); | 58 mojo::ScopedMessagePipeHandle pipe = binding_.Unbind().PassMessagePipe(); |
| 59 MojoResult rv = mojo::WriteMessageRaw( | 59 MojoResult rv = mojo::WriteMessageRaw( |
| 60 pipe.get(), kBadMessage.data(), kBadMessage.size(), nullptr, 0, | 60 pipe.get(), kBadMessage.data(), kBadMessage.size(), nullptr, 0, |
| 61 MOJO_WRITE_MESSAGE_FLAG_NONE); | 61 MOJO_WRITE_MESSAGE_FLAG_NONE); |
| 62 DCHECK_EQ(rv, MOJO_RESULT_OK); | 62 DCHECK_EQ(rv, MOJO_RESULT_OK); |
| 63 | 63 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 void GetRequestorName(const GetRequestorNameCallback& callback) override { | 76 void GetRequestorName(const GetRequestorNameCallback& callback) override { |
| 77 callback.Run("Not implemented."); | 77 callback.Run("Not implemented."); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void CreateSharedBuffer(const std::string& message, | 80 void CreateSharedBuffer(const std::string& message, |
| 81 const CreateSharedBufferCallback& callback) override { | 81 const CreateSharedBufferCallback& callback) override { |
| 82 NOTREACHED(); | 82 NOTREACHED(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 mojo::Binding<mojom::TestMojoService> binding_; | 85 mojo::Binding<mojom::TestService> binding_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(TestMojoServiceImpl); | 87 DISALLOW_COPY_AND_ASSIGN(TestServiceImpl); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 void CreateTestMojoService(mojom::TestMojoServiceRequest request) { | 90 void CreateTestService(mojom::TestServiceRequest request) { |
| 91 // Owns itself. | 91 // Owns itself. |
| 92 new TestMojoServiceImpl(std::move(request)); | 92 new TestServiceImpl(std::move(request)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 ShellContentRendererClient::ShellContentRendererClient() {} | 97 ShellContentRendererClient::ShellContentRendererClient() {} |
| 98 | 98 |
| 99 ShellContentRendererClient::~ShellContentRendererClient() { | 99 ShellContentRendererClient::~ShellContentRendererClient() { |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ShellContentRendererClient::RenderThreadStarted() { | 102 void ShellContentRendererClient::RenderThreadStarted() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 129 void ShellContentRendererClient::DidInitializeWorkerContextOnWorkerThread( | 129 void ShellContentRendererClient::DidInitializeWorkerContextOnWorkerThread( |
| 130 v8::Local<v8::Context> context) { | 130 v8::Local<v8::Context> context) { |
| 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 132 switches::kExposeInternalsForTesting)) { | 132 switches::kExposeInternalsForTesting)) { |
| 133 blink::WebTestingSupport::injectInternalsObject(context); | 133 blink::WebTestingSupport::injectInternalsObject(context); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ShellContentRendererClient::ExposeInterfacesToBrowser( | 137 void ShellContentRendererClient::ExposeInterfacesToBrowser( |
| 138 shell::InterfaceRegistry* interface_registry) { | 138 shell::InterfaceRegistry* interface_registry) { |
| 139 interface_registry->AddInterface<mojom::TestMojoService>( | 139 interface_registry->AddInterface<mojom::TestService>( |
| 140 base::Bind(&CreateTestMojoService)); | 140 base::Bind(&CreateTestService)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
| 144 void ShellContentRendererClient::AddSupportedKeySystems( | 144 void ShellContentRendererClient::AddSupportedKeySystems( |
| 145 std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) { | 145 std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) { |
| 146 if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) | 146 if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 static const char kExternalClearKeyKeySystem[] = | 149 static const char kExternalClearKeyKeySystem[] = |
| 150 "org.chromium.externalclearkey"; | 150 "org.chromium.externalclearkey"; |
| 151 key_systems->emplace_back( | 151 key_systems->emplace_back( |
| 152 new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); | 152 new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); |
| 153 } | 153 } |
| 154 #endif | 154 #endif |
| 155 | 155 |
| 156 } // namespace content | 156 } // namespace content |
| OLD | NEW |