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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp

Issue 2084183004: Only access a plugin's scriptable object, and not also its prototype chain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 { 46 {
47 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); 47 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder());
48 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper(); 48 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper();
49 if (!wrapper) 49 if (!wrapper)
50 return; 50 return;
51 51
52 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); 52 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
53 if (instance.IsEmpty()) 53 if (instance.IsEmpty())
54 return; 54 return;
55 55
56 if (!v8CallBoolean(instance->HasOwnProperty(info.GetIsolate()->GetCurrentCon text(), property)))
57 return;
58
56 v8::Local<v8::Value> value; 59 v8::Local<v8::Value> value;
57 if (!instance->Get(info.GetIsolate()->GetCurrentContext(), property).ToLocal (&value)) 60 if (!instance->Get(info.GetIsolate()->GetCurrentContext(), property).ToLocal (&value))
58 return; 61 return;
59 62
60 // We quit here to allow the binding code to look up general HTMLObjectEleme nt properties
61 // if they are not overriden by plugin.
62 if (value->IsUndefined() && !v8CallBoolean(instance->Has(info.GetIsolate()-> GetCurrentContext(), property)))
63 return;
64
65 v8SetReturnValue(info, value); 63 v8SetReturnValue(info, value);
66 } 64 }
67 65
68 template <typename ElementType, typename PropertyType> 66 template <typename ElementType, typename PropertyType>
69 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val ue, const v8::PropertyCallbackInfo<v8::Value>& info) 67 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val ue, const v8::PropertyCallbackInfo<v8::Value>& info)
70 { 68 {
71 ASSERT(!value.IsEmpty()); 69 ASSERT(!value.IsEmpty());
72 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); 70 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder());
73 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper(); 71 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper();
74 if (!wrapper) 72 if (!wrapper)
75 return; 73 return;
76 74
77 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); 75 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
78 if (instance.IsEmpty()) 76 if (instance.IsEmpty())
79 return; 77 return;
80 78
81 // FIXME: The gTalk pepper plugin is the only plugin to make use of 79 // FIXME: The gTalk pepper plugin is the only plugin to make use of
82 // SetProperty and that is being deprecated. This can be removed as soon as 80 // SetProperty and that is being deprecated. This can be removed as soon as
83 // it goes away. 81 // it goes away.
84 // Call SetProperty on a pepper plugin's scriptable object. Note that we 82 // Call SetProperty on a pepper plugin's scriptable object. Note that we
85 // never set the return value here which would indicate that the plugin has 83 // never set the return value here which would indicate that the plugin has
86 // intercepted the SetProperty call, which means that the property on the 84 // intercepted the SetProperty call, which means that the property on the
87 // DOM element will also be set. For plugin's that don't intercept the call 85 // DOM element will also be set. For plugin's that don't intercept the call
88 // (all except gTalk) this makes no difference at all. For gTalk the fact 86 // (all except gTalk) this makes no difference at all. For gTalk the fact
89 // that the property on the DOM element also gets set is inconsequential. 87 // that the property on the DOM element also gets set is inconsequential.
90 v8::Maybe<bool> unused = instance->Set(info.GetIsolate()->GetCurrentContext( ), property, value); 88 v8CallBoolean(instance->CreateDataProperty(info.GetIsolate()->GetCurrentCont ext(), property, value));
91 ALLOW_UNUSED_LOCAL(unused);
92 } 89 }
93 } // namespace 90 } // namespace
94 91
95 void V8HTMLEmbedElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, con st v8::PropertyCallbackInfo<v8::Value>& info) 92 void V8HTMLEmbedElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, con st v8::PropertyCallbackInfo<v8::Value>& info)
96 { 93 {
97 getScriptableObjectProperty<V8HTMLEmbedElement>(name.As<v8::String>(), info) ; 94 getScriptableObjectProperty<V8HTMLEmbedElement>(name.As<v8::String>(), info) ;
98 } 95 }
99 96
100 void V8HTMLObjectElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, co nst v8::PropertyCallbackInfo<v8::Value>& info) 97 void V8HTMLObjectElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, co nst v8::PropertyCallbackInfo<v8::Value>& info)
101 { 98 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLEmbedElement::t oImpl(info.Holder())->document(), UseCounter::HTMLEmbedElementLegacyCall); 161 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLEmbedElement::t oImpl(info.Holder())->document(), UseCounter::HTMLEmbedElementLegacyCall);
165 } 162 }
166 163
167 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va lue>& info) 164 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va lue>& info)
168 { 165 {
169 invokeOnScriptableObject<V8HTMLObjectElement>(info); 166 invokeOnScriptableObject<V8HTMLObjectElement>(info);
170 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLObjectElement:: toImpl(info.Holder())->document(), UseCounter::HTMLObjectElementLegacyCall); 167 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLObjectElement:: toImpl(info.Holder())->document(), UseCounter::HTMLObjectElementLegacyCall);
171 } 168 }
172 169
173 } // namespace blink 170 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698