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

Side by Side Diff: content/renderer/media/cdm/pepper_cdm_wrapper_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698