18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef DO_NO_IMPORTS 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectimport "oaidl.idl"; 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectimport "ocidl.idl"; 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*! 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @class WebScriptObject 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion WebScriptObjects are used to wrap script objects passed from 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project script environments to Objective-C. WebScriptObjects cannot be created 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project directly. In normal uses of WebKit, you gain access to the script 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project environment using the "windowScriptObject" method on WebView. 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project The following KVC methods are commonly used to access properties of the 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project WebScriptObject: 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)setValue:(id)value forKey:(NSString *)key 428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (id)valueForKey:(NSString *)key 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project As it possible to remove attributes from web script objects the following 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project additional method augments the basic KVC methods: 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)removeWebScriptKey:(NSString *)name; 488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project Also the sparse array access allowed in web script objects doesn't map well to NSArray, so 508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project the following methods can be used to access index based properties: 518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (id)webScriptValueAtIndex:(unsigned int)index; 538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value; 548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @interface WebScriptObject : NSObject 568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*/ 578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project[ 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project object, 598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project oleautomation, 608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project uuid(7022340A-649C-43fc-9214-85CA7D3BE3C7), 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project pointer_default(unique) 628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project] 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectinterface IWebScriptObject : IUnknown 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method throwException: 678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Throws an exception in the current script execution context. 688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @result Either NO if an exception could not be raised, YES otherwise. 698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project + (BOOL)throwException:(NSString *)exceptionMessage; 708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT throwException([in] BSTR exceptionMessage, [out, retval] BOOL* result); 728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method callWebScriptMethod:withArguments: 758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param name The name of the method to call in the script environment. 768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param args The arguments to pass to the script environment. 778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Calls the specified method in the script environment using the 788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project specified arguments. 798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @result Returns the result of calling the script method. 808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (id)callWebScriptMethod:(NSString *)name withArguments:(NSArray *)args; 818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT callWebScriptMethod([in] BSTR name, [in, size_is(cArgs)] const VARIANT args[], [in] int cArgs, [out, retval] VARIANT* result); 838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method evaluateWebScript: 868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param script The script to execute in the target script environment. 878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion The script will be executed in the target script environment. The format 888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project of the script is dependent of the target script environment. 898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @result Returns the result of evaluating the script in the script environment. 908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (id)evaluateWebScript:(NSString *)script; 918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT evaluateWebScript([in] BSTR script, [out, retval] VARIANT* result); 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method removeWebScriptKey: 968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param name The name of the property to remove. 978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Removes the property from the object in the script environment. 988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)removeWebScriptKey:(NSString *)name; 998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT removeWebScriptKey([in] BSTR name); 1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method toString 1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Converts the target object to a string representation. The coercion 1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project of non string objects type is dependent on the script environment. 1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @result Returns the string representation of the object. 1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (NSString *)stringRepresentation; 1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT stringRepresentation([out, retval] BSTR* stringRepresentation); 1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method propertyAtIndex: 1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param index The index of the property to return. Index based access is dependent 1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Gets the value of the property at the specified index. 1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @result The value of the property. 1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (id)webScriptValueAtIndex:(unsigned int)index; 1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT webScriptValueAtIndex([in] unsigned int index, [out, retval] VARIANT* result); 1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method setPropertyAtIndex:value: 1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param index The index of the property to set. 1238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param value The value of the property to set. 1248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Sets the property value at the specified index. 1258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value; 1268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT setWebScriptValueAtIndex([in] unsigned int index, [in] VARIANT val); 1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /*! 1308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @method setException: 1318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @param description The description of the exception. 1328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project @discussion Raises an exception in the script environment in the context of the 1338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project current object. 1348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project - (void)setException: (NSString *)description; 1358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project HRESULT setException([in] BSTR description); 1378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 138