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

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

Issue 1893983002: Simplify handling of Transferable objects while (de)serializing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove Transferable.cpp, not needed after all. Created 4 years, 8 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 /* 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 19 matching lines...) Expand all
30 30
31 #include "bindings/core/v8/V8Window.h" 31 #include "bindings/core/v8/V8Window.h"
32 32
33 #include "bindings/core/v8/BindingSecurity.h" 33 #include "bindings/core/v8/BindingSecurity.h"
34 #include "bindings/core/v8/ExceptionMessages.h" 34 #include "bindings/core/v8/ExceptionMessages.h"
35 #include "bindings/core/v8/ExceptionState.h" 35 #include "bindings/core/v8/ExceptionState.h"
36 #include "bindings/core/v8/ScriptController.h" 36 #include "bindings/core/v8/ScriptController.h"
37 #include "bindings/core/v8/ScriptSourceCode.h" 37 #include "bindings/core/v8/ScriptSourceCode.h"
38 #include "bindings/core/v8/SerializedScriptValue.h" 38 #include "bindings/core/v8/SerializedScriptValue.h"
39 #include "bindings/core/v8/SerializedScriptValueFactory.h" 39 #include "bindings/core/v8/SerializedScriptValueFactory.h"
40 #include "bindings/core/v8/TransferableMessagePort.h" 40 #include "bindings/core/v8/Transferables.h"
41 #include "bindings/core/v8/V8Binding.h" 41 #include "bindings/core/v8/V8Binding.h"
42 #include "bindings/core/v8/V8EventListener.h" 42 #include "bindings/core/v8/V8EventListener.h"
43 #include "bindings/core/v8/V8EventListenerList.h" 43 #include "bindings/core/v8/V8EventListenerList.h"
44 #include "bindings/core/v8/V8HTMLCollection.h" 44 #include "bindings/core/v8/V8HTMLCollection.h"
45 #include "bindings/core/v8/V8HiddenValue.h" 45 #include "bindings/core/v8/V8HiddenValue.h"
46 #include "bindings/core/v8/V8Node.h" 46 #include "bindings/core/v8/V8Node.h"
47 #include "core/dom/DOMArrayBuffer.h" 47 #include "core/dom/DOMArrayBuffer.h"
48 #include "core/dom/ExceptionCode.h" 48 #include "core/dom/ExceptionCode.h"
49 #include "core/dom/MessagePort.h" 49 #include "core/dom/MessagePort.h"
50 #include "core/frame/FrameView.h" 50 #include "core/frame/FrameView.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 exceptionState.throwIfNeeded(); 186 exceptionState.throwIfNeeded();
187 return; 187 return;
188 } 188 }
189 189
190 // This function has variable arguments and can be: 190 // This function has variable arguments and can be:
191 // Per current spec: 191 // Per current spec:
192 // postMessage(message, targetOrigin) 192 // postMessage(message, targetOrigin)
193 // postMessage(message, targetOrigin, {sequence of transferrables}) 193 // postMessage(message, targetOrigin, {sequence of transferrables})
194 // Legacy non-standard implementations in webkit allowed: 194 // Legacy non-standard implementations in webkit allowed:
195 // postMessage(message, {sequence of transferrables}, targetOrigin); 195 // postMessage(message, {sequence of transferrables}, targetOrigin);
196 TransferableArray* transferables = new TransferableArray; 196 Transferables transferables;
197 int targetOriginArgIndex = 1; 197 int targetOriginArgIndex = 1;
198 if (info.Length() > 2) { 198 if (info.Length() > 2) {
199 int transferablesArgIndex = 2; 199 int transferablesArgIndex = 2;
200 if (isLegacyTargetOriginDesignation(info[2])) { 200 if (isLegacyTargetOriginDesignation(info[2])) {
201 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame (), UseCounter::WindowPostMessageWithLegacyTargetOriginArgument); 201 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame (), UseCounter::WindowPostMessageWithLegacyTargetOriginArgument);
202 targetOriginArgIndex = 2; 202 targetOriginArgIndex = 2;
203 transferablesArgIndex = 1; 203 transferablesArgIndex = 1;
204 } 204 }
205 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, *transferables, exceptionState)) { 205 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) {
206 exceptionState.throwIfNeeded(); 206 exceptionState.throwIfNeeded();
207 return; 207 return;
208 } 208 }
209 } 209 }
210 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri gin, info[targetOriginArgIndex]); 210 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri gin, info[targetOriginArgIndex]);
211 211
212 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan ce().create(info.GetIsolate(), info[0], transferables, exceptionState); 212 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan ce().create(info.GetIsolate(), info[0], &transferables, exceptionState);
213 if (exceptionState.throwIfNeeded()) 213 if (exceptionState.throwIfNeeded())
214 return; 214 return;
215 215
216 MessagePortArray* portArray; 216 window->postMessage(message.release(), transferables.messagePorts, targetOri gin, source, exceptionState);
217 if (auto* messagePorts = TransferableMessagePort::get(*transferables))
218 portArray = &(messagePorts->getArray());
219 else
220 portArray = new MessagePortArray;
221 window->postMessage(message.release(), portArray, targetOrigin, source, exce ptionState);
222 exceptionState.throwIfNeeded(); 217 exceptionState.throwIfNeeded();
223 } 218 }
224 219
225 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 220 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
226 { 221 {
227 DOMWindow* impl = V8Window::toImpl(info.Holder()); 222 DOMWindow* impl = V8Window::toImpl(info.Holder());
228 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win dow", info.Holder(), info.GetIsolate()); 223 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win dow", info.Holder(), info.GetIsolate());
229 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), impl, exceptionState)) { 224 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
230 exceptionState.throwIfNeeded(); 225 exceptionState.throwIfNeeded();
231 return; 226 return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 return BindingSecurity::shouldAllowAccessTo(isolate, callingDOMWindow(isolat e), targetWindow, DoNotReportSecurityError); 367 return BindingSecurity::shouldAllowAccessTo(isolate, callingDOMWindow(isolat e), targetWindow, DoNotReportSecurityError);
373 } 368 }
374 369
375 bool V8Window::securityCheckCustom(v8::Local<v8::Context> accessingContext, v8:: Local<v8::Object> accessedObject, v8::Local<v8::Value> data) 370 bool V8Window::securityCheckCustom(v8::Local<v8::Context> accessingContext, v8:: Local<v8::Object> accessedObject, v8::Local<v8::Value> data)
376 { 371 {
377 // TODO(jochen): Take accessingContext into account. 372 // TODO(jochen): Take accessingContext into account.
378 return securityCheck(accessedObject); 373 return securityCheck(accessedObject);
379 } 374 }
380 375
381 } // namespace blink 376 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698