// Application controller static callback. static JSValueRef fillConfigurationFromFile(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception, ConfigFileType type) { if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr<JSStringRef> fileNameJSString(Adopt, JSValueToStringCopy(context, arguments[0], exception)); //ASSERT(!*exception); ApplicationTestController* controller = static_cast<ApplicationTestController*>(JSObjectGetPrivate(thisObject)); char* relativeURL = JSStringCopyUTF8CString(fileNameJSString.get()); if (strncmp("http://", relativeURL, 7) != 0 && strncmp("https://", relativeURL, 8) != 0 && strncmp("data:", relativeURL, 5) != 0 && strncmp("file://", relativeURL, 7) != 0) { WebView* webView = getWebView(); string mainFrameURL = webView->mainFrameURL(); size_t pos = mainFrameURL.find_last_of("/"); string absoluteURL = mainFrameURL.substr(0, pos + 1); absoluteURL += relativeURL; size_t pos2 = absoluteURL.find_last_of("?"); if (pos2 == absoluteURL.size() - 1) absoluteURL = absoluteURL.substr(0, pos2); controller->fillConfigurationFromFile((char*)absoluteURL.c_str(), type); return JSValueMakeUndefined(context); } controller->fillConfigurationFromFile(relativeURL, type); return JSValueMakeUndefined(context); }