File indexing completed on 2023-09-24 04:06:08
0001 /* 0002 * This includes methods for marshalling/demarshalling data for 0003 * cross-context messaging 0004 * 0005 * Copyright (C) 2010 Maksim Orlovich <maksim@kde.org> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Lesser General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0020 */ 0021 #include "kjs_binding.h" 0022 #include "kjs_window.h" 0023 #include "xml/dom2_eventsimpl.h" 0024 0025 class KHTMLPart; 0026 0027 #include <QWeakPointer> 0028 0029 namespace KJS 0030 { 0031 0032 /* 0033 Deep copy of data; no guarantees are made about the domain of the result; 0034 just that it's distinct from the original. You're expected to use 0035 encapsulateMessageEventData on the result to associate it with the 0036 appropriate security domain. 0037 */ 0038 JSValue *cloneData(ExecState *exec, JSValue *data); 0039 0040 /* 0041 Note: unlike other JS->DOM routines, this method is expected to cross security 0042 domains; hence besides current ExecState (needed to set exceptions) it needs 0043 the *destination* domain, to make sure everything created uses prototypes 0044 from it. It can also return 0 if the serialization failed; in which case an 0045 exception will also be set. 0046 */ 0047 DOM::MessageEventImpl::Data *encapsulateMessageEventData(ExecState *exec, Interpreter *ctx, JSValue *data); 0048 0049 /* 0050 Warning: Unlike the above, this accessor isn't expected to cross boundaries, 0051 so it doesn't do any deep copying or the like 0052 */ 0053 JSValue *getMessageEventData(ExecState *exec, DOM::MessageEventImpl::Data *data); 0054 0055 /* 0056 Actually executes Window::PostMessage with given arguments; 0057 targetOrigin is expected to have been sanity-checked already 0058 */ 0059 class DelayedPostMessage: public Window::DelayedAction 0060 { 0061 public: 0062 DelayedPostMessage(KHTMLPart *source, const QString &_sourceOrigin, const QString &_targetOrigin, JSValue *_payload); 0063 0064 void mark() override; 0065 bool execute(Window *) override; 0066 private: 0067 QString sourceOrigin; 0068 QString targetOrigin; 0069 ProtectedPtr<JSValue> payload; 0070 QWeakPointer<KHTMLPart> source; 0071 }; 0072 0073 } 0074