OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 result = constructorName; | 132 result = constructorName; |
133 } | 133 } |
134 } | 134 } |
135 if (toCoreStringWithUndefinedOrNullCheck(result) == "Object" && object-> IsFunction()) | 135 if (toCoreStringWithUndefinedOrNullCheck(result) == "Object" && object-> IsFunction()) |
136 result = v8AtomicString(info.GetIsolate(), "Function"); | 136 result = v8AtomicString(info.GetIsolate(), "Function"); |
137 } | 137 } |
138 | 138 |
139 v8SetReturnValue(info, result); | 139 v8SetReturnValue(info, result); |
140 } | 140 } |
141 | 141 |
142 void V8InjectedScriptHost::isDOMWrapperMethodCustom(const v8::FunctionCallbackIn fo<v8::Value>& info) | |
143 { | |
144 if (info.Length() < 1) | |
145 return; | |
146 | |
147 v8SetReturnValue(info, V8DOMWrapper::isWrapper(info.GetIsolate(), info[0])); | |
148 } | |
149 | |
142 void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) | 150 void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) |
143 { | 151 { |
144 if (info.Length() < 1) | 152 if (info.Length() < 1) |
145 return; | 153 return; |
146 | 154 |
147 if (!info[0]->IsObject()) { | |
148 v8SetReturnValue(info, false); | |
149 return; | |
150 } | |
151 | |
152 v8SetReturnValue(info, V8HTMLAllCollection::hasInstance(info[0], info.GetIso late())); | |
153 } | |
154 | |
155 void V8InjectedScriptHost::isPopularDOMObjectMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) | |
156 { | |
157 // FIXME: Stop using this function (whilelisting) once we come up with a way | |
158 // to distinguish DOM wrappers from other obejcts. | |
159 | |
160 if (info.Length() < 1) | |
161 return; | |
162 | |
163 if (!info[0]->IsObject()) { | 155 if (!info[0]->IsObject()) { |
164 v8SetReturnValue(info, false); | 156 v8SetReturnValue(info, false); |
165 return; | 157 return; |
166 } | 158 } |
167 | 159 |
168 v8::Local<v8::Value> object = info[0]; | 160 v8SetReturnValue(info, V8HTMLAllCollection::hasInstance(info[0], info.GetIso late())); |
169 v8::Isolate* isolate = info.GetIsolate(); | |
170 bool isPopularDOMObject = false; | |
171 static bool (*hasInstances[])(v8::Local<v8::Value>, v8::Isolate*) = { | |
172 V8Blob::hasInstance, | |
173 V8DOMError::hasInstance, | |
174 V8DOMException::hasInstance, | |
175 V8Element::hasInstance, | |
176 V8Event::hasInstance, | |
177 V8EventTarget::hasInstance, | |
178 V8Location::hasInstance, | |
179 V8Navigator::hasInstance, | |
180 }; | |
181 for (size_t i = 0; i < sizeof hasInstances / sizeof *hasInstances; ++i) { | |
182 if (hasInstances[i](object, isolate)) { | |
183 isPopularDOMObject = true; | |
184 break; | |
185 } | |
186 } | |
187 | |
188 v8SetReturnValue(info, isPopularDOMObject); | |
189 } | 161 } |
190 | 162 |
191 void V8InjectedScriptHost::isTypedArrayMethodCustom(const v8::FunctionCallbackIn fo<v8::Value>& info) | 163 void V8InjectedScriptHost::isTypedArrayMethodCustom(const v8::FunctionCallbackIn fo<v8::Value>& info) |
192 { | 164 { |
193 if (info.Length() < 1) | 165 if (info.Length() < 1) |
194 return; | 166 return; |
195 v8SetReturnValue(info, info[0]->IsTypedArray()); | 167 v8SetReturnValue(info, info[0]->IsTypedArray()); |
196 } | 168 } |
197 | 169 |
198 void V8InjectedScriptHost::subtypeMethodCustom(const v8::FunctionCallbackInfo<v8 ::Value>& info) | 170 void V8InjectedScriptHost::subtypeMethodCustom(const v8::FunctionCallbackInfo<v8 ::Value>& info) |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 | 545 |
574 void V8InjectedScriptHost::setNonEnumPropertyMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) | 546 void V8InjectedScriptHost::setNonEnumPropertyMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) |
575 { | 547 { |
576 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) | 548 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) |
577 return; | 549 return; |
578 | 550 |
579 v8::Local<v8::Object> object = info[0]->ToObject(info.GetIsolate()); | 551 v8::Local<v8::Object> object = info[0]->ToObject(info.GetIsolate()); |
580 object->ForceSet(info[1], info[2], v8::DontEnum); | 552 object->ForceSet(info[1], info[2], v8::DontEnum); |
581 } | 553 } |
582 | 554 |
555 void V8InjectedScriptHost::getDOMAttributesWithObservableSideEffectOnGetMethodCu stom(const v8::FunctionCallbackInfo<v8::Value>& info) | |
556 { | |
557 // Returns DOM attributes which have observable side effect on getter, | |
558 // in the form of | |
559 // {interfaceName1: {attributeName1: true, | |
560 // attributeName2: true, | |
561 // ...}, | |
562 // interfaceName2: {...}, | |
563 // ...} | |
564 // These attributes should not be evaluated in the Inspector. | |
565 | |
566 typedef Vector<std::pair<String, bool>> AttributeSet; | |
pfeldman
2015/03/09 11:41:41
I don't see why this is being created here, it is
Yuki
2015/03/09 12:48:13
I misunderstood that you disliked to have this cod
| |
567 AttributeSet requestAttributes; | |
568 requestAttributes.append(std::make_pair("body", true)); | |
569 AttributeSet responseAttributes; | |
570 responseAttributes.append(std::make_pair("body", true)); | |
571 | |
572 Vector<std::pair<String, AttributeSet>> attributesWithSideEffect; | |
573 attributesWithSideEffect.append(std::make_pair("Request", requestAttributes) ); | |
574 attributesWithSideEffect.append(std::make_pair("Response", responseAttribute s)); | |
575 | |
576 v8SetReturnValue(info, toV8(attributesWithSideEffect, info.Holder(), info.Ge tIsolate())); | |
577 } | |
578 | |
583 void V8InjectedScriptHost::bindMethodCustom(const v8::FunctionCallbackInfo<v8::V alue>& info) | 579 void V8InjectedScriptHost::bindMethodCustom(const v8::FunctionCallbackInfo<v8::V alue>& info) |
584 { | 580 { |
585 if (info.Length() < 2 || !info[1]->IsString()) | 581 if (info.Length() < 2 || !info[1]->IsString()) |
586 return; | 582 return; |
587 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); | 583 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); |
588 if (!injectedScriptNative) | 584 if (!injectedScriptNative) |
589 return; | 585 return; |
590 | 586 |
591 v8::Handle<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); | 587 v8::Handle<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); |
592 String groupName = toCoreStringWithUndefinedOrNullCheck(v8groupName); | 588 String groupName = toCoreStringWithUndefinedOrNullCheck(v8groupName); |
(...skipping 21 matching lines...) Expand all Loading... | |
614 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); | 610 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); |
615 if (!injectedScriptNative) | 611 if (!injectedScriptNative) |
616 return; | 612 return; |
617 int id = info[0]->ToInt32(info.GetIsolate())->Value(); | 613 int id = info[0]->ToInt32(info.GetIsolate())->Value(); |
618 String groupName = injectedScriptNative->groupName(id); | 614 String groupName = injectedScriptNative->groupName(id); |
619 if (!groupName.isEmpty()) | 615 if (!groupName.isEmpty()) |
620 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); | 616 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); |
621 } | 617 } |
622 | 618 |
623 } // namespace blink | 619 } // namespace blink |
OLD | NEW |