WebCoreBundleWin.cpp [plain text]
#include "config.h"
#include "WebCoreBundleWin.h"
#if USE(CF)
#include "WebCoreInstanceHandle.h"
#include <CoreFoundation/CFBundle.h>
#include <windows.h>
#include <wtf/RetainPtr.h>
namespace WebCore {
static CFBundleRef createWebKitBundle()
{
if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) {
CFRetain(existingBundle);
return existingBundle;
}
wchar_t dllPathBuffer[MAX_PATH];
DWORD length = ::GetModuleFileNameW(WebCore::instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer));
ASSERT(length);
ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer));
RetainPtr<CFStringRef> dllPath = adoptCF(CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull));
RetainPtr<CFURLRef> dllURL = adoptCF(CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false));
RetainPtr<CFURLRef> dllDirectoryURL = adoptCF(CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get()));
RetainPtr<CFURLRef> resourcesDirectoryURL = adoptCF(CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true));
return CFBundleCreate(0, resourcesDirectoryURL.get());
}
CFBundleRef webKitBundle()
{
static CFBundleRef bundle = createWebKitBundle();
ASSERT(bundle);
return bundle;
}
}
#endif