OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 | 241 |
242 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 242 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
243 { | 243 { |
244 // None of these need to be RefPtr because info and context are guaranteed | 244 // None of these need to be RefPtr because info and context are guaranteed |
245 // to hold on to them. | 245 // to hold on to them. |
246 LocalDOMWindow* window = V8Window::toImpl(info.Holder()); | 246 LocalDOMWindow* window = V8Window::toImpl(info.Holder()); |
247 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); | 247 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); |
248 | 248 |
249 ASSERT(window); | 249 ASSERT(window); |
250 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->document(), U
seCounter::WindowPostMessage); | 250 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame(), UseC
ounter::WindowPostMessage); |
251 | 251 |
252 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); | 252 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); |
253 | 253 |
254 // If called directly by WebCore we don't have a calling context. | 254 // If called directly by WebCore we don't have a calling context. |
255 if (!source) { | 255 if (!source) { |
256 exceptionState.throwTypeError("No active calling context exists."); | 256 exceptionState.throwTypeError("No active calling context exists."); |
257 exceptionState.throwIfNeeded(); | 257 exceptionState.throwIfNeeded(); |
258 return; | 258 return; |
259 } | 259 } |
260 | 260 |
261 // This function has variable arguments and can be: | 261 // This function has variable arguments and can be: |
262 // Per current spec: | 262 // Per current spec: |
263 // postMessage(message, targetOrigin) | 263 // postMessage(message, targetOrigin) |
264 // postMessage(message, targetOrigin, {sequence of transferrables}) | 264 // postMessage(message, targetOrigin, {sequence of transferrables}) |
265 // Legacy non-standard implementations in webkit allowed: | 265 // Legacy non-standard implementations in webkit allowed: |
266 // postMessage(message, {sequence of transferrables}, targetOrigin); | 266 // postMessage(message, {sequence of transferrables}, targetOrigin); |
267 MessagePortArray portArray; | 267 MessagePortArray portArray; |
268 ArrayBufferArray arrayBufferArray; | 268 ArrayBufferArray arrayBufferArray; |
269 int targetOriginArgIndex = 1; | 269 int targetOriginArgIndex = 1; |
270 if (info.Length() > 2) { | 270 if (info.Length() > 2) { |
271 int transferablesArgIndex = 2; | 271 int transferablesArgIndex = 2; |
272 if (isLegacyTargetOriginDesignation(info[2])) { | 272 if (isLegacyTargetOriginDesignation(info[2])) { |
273 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->docum
ent(), UseCounter::WindowPostMessageWithLegacyTargetOriginArgument); | 273 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame
(), UseCounter::WindowPostMessageWithLegacyTargetOriginArgument); |
274 targetOriginArgIndex = 2; | 274 targetOriginArgIndex = 2; |
275 transferablesArgIndex = 1; | 275 transferablesArgIndex = 1; |
276 } | 276 } |
277 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exc
eptionState)) { | 277 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exc
eptionState)) { |
278 exceptionState.throwIfNeeded(); | 278 exceptionState.throwIfNeeded(); |
279 return; | 279 return; |
280 } | 280 } |
281 } | 281 } |
282 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri
gin, info[targetOriginArgIndex]); | 282 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri
gin, info[targetOriginArgIndex]); |
283 | 283 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); | 547 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); |
548 if (context.IsEmpty()) | 548 if (context.IsEmpty()) |
549 return v8Undefined(); | 549 return v8Undefined(); |
550 | 550 |
551 v8::Handle<v8::Object> global = context->Global(); | 551 v8::Handle<v8::Object> global = context->Global(); |
552 ASSERT(!global.IsEmpty()); | 552 ASSERT(!global.IsEmpty()); |
553 return global; | 553 return global; |
554 } | 554 } |
555 | 555 |
556 } // namespace blink | 556 } // namespace blink |
OLD | NEW |