| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ppapi/features/features.h" | 5 #include "ppapi/features/features.h" |
| 6 | 6 |
| 7 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 7 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 8 #include "content/renderer/media/cdm/pepper_cdm_wrapper_impl.h" | 8 #include "content/renderer/media/cdm/pepper_cdm_wrapper_impl.h" |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 13 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 13 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 14 #include "third_party/WebKit/public/platform/URLConversion.h" | 14 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
| 17 #include "third_party/WebKit/public/web/WebElement.h" | 17 #include "third_party/WebKit/public/web/WebElement.h" |
| 18 #include "third_party/WebKit/public/web/WebFrame.h" | 18 #include "third_party/WebKit/public/web/WebFrame.h" |
| 19 #include "third_party/WebKit/public/web/WebHelperPlugin.h" | 19 #include "third_party/WebKit/public/web/WebHelperPlugin.h" |
| 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebPlugin.h" | 21 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 22 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 22 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 23 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
| 24 #include "url/origin.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 void WebHelperPluginDeleter::operator()(blink::WebHelperPlugin* plugin) const { | 28 void WebHelperPluginDeleter::operator()(blink::WebHelperPlugin* plugin) const { |
| 28 plugin->destroy(); | 29 plugin->destroy(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 std::unique_ptr<PepperCdmWrapper> PepperCdmWrapperImpl::Create( | 32 std::unique_ptr<PepperCdmWrapper> PepperCdmWrapperImpl::Create( |
| 32 blink::WebLocalFrame* frame, | 33 blink::WebLocalFrame* frame, |
| 33 const std::string& pluginType, | 34 const std::string& pluginType, |
| 34 const GURL& security_origin) { | 35 const GURL& security_origin) { |
| 35 DCHECK(frame); | 36 DCHECK(frame); |
| 36 | 37 |
| 37 // The frame security origin could be different from the origin where the CDM | 38 // The frame security origin could be different from the origin where the CDM |
| 38 // creation was initiated, e.g. due to navigation. | 39 // creation was initiated, e.g. due to navigation. |
| 39 // Note: The code will continue after navigation to the "same" origin, even | 40 // Note: The code will continue after navigation to the "same" origin, even |
| 40 // though the CDM is no longer necessary. | 41 // though the CDM is no longer necessary. |
| 41 // TODO: Consider avoiding this possibility entirely. http://crbug.com/575236 | 42 // TODO: Consider avoiding this possibility entirely. http://crbug.com/575236 |
| 42 GURL frame_security_origin( | 43 GURL frame_security_origin(url::Origin(frame->getSecurityOrigin()).GetURL()); |
| 43 blink::WebStringToGURL(frame->getSecurityOrigin().toString())); | |
| 44 if (frame_security_origin != security_origin) { | 44 if (frame_security_origin != security_origin) { |
| 45 LOG(ERROR) << "Frame has a different origin than the EME call."; | 45 LOG(ERROR) << "Frame has a different origin than the EME call."; |
| 46 return std::unique_ptr<PepperCdmWrapper>(); | 46 return std::unique_ptr<PepperCdmWrapper>(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ScopedHelperPlugin helper_plugin(blink::WebHelperPlugin::create( | 49 ScopedHelperPlugin helper_plugin(blink::WebHelperPlugin::create( |
| 50 blink::WebString::fromUTF8(pluginType), frame)); | 50 blink::WebString::fromUTF8(pluginType), frame)); |
| 51 if (!helper_plugin) | 51 if (!helper_plugin) |
| 52 return std::unique_ptr<PepperCdmWrapper>(); | 52 return std::unique_ptr<PepperCdmWrapper>(); |
| 53 | 53 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 helper_plugin_.reset(); | 90 helper_plugin_.reset(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 ContentDecryptorDelegate* PepperCdmWrapperImpl::GetCdmDelegate() { | 93 ContentDecryptorDelegate* PepperCdmWrapperImpl::GetCdmDelegate() { |
| 94 return plugin_instance_->GetContentDecryptorDelegate(); | 94 return plugin_instance_->GetContentDecryptorDelegate(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace content | 97 } // namespace content |
| 98 | 98 |
| 99 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 99 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| OLD | NEW |