HRESULT STDMETHODCALLTYPE WebKitUIDelegate::createWebViewWithRequest(
    /* [in] */ IWebView *sender,
    /* [in] */ IWebURLRequest *request,
    /* [in] */ IPropertyBag *features,
    /* [retval][out] */ IWebView **newWebView)
{
    AutoPtr<WindowConfig> config(WindowConfig::Default());
    BSTR burl;
    request->URL(&burl);
    std::string url = _bstr_t(burl);

    if (url.size() > 0)
    {
        config->SetURL(url);
    }

    if (features)
    {
        int fullscreen = PropertyBagGetIntProperty(features, L"fullscreen");
        if (fullscreen != -1)
            config->SetFullscreen(fullscreen == 1);

        int x = PropertyBagGetIntProperty(features, L"x");
        if (x != -1)
            config->SetX(x);

        int y = PropertyBagGetIntProperty(features, L"y");
        if (y != -1)
            config->SetY(y);

        int width = PropertyBagGetIntProperty(features, L"width");
        if (width != -1)
            config->SetWidth(width);

        int height = PropertyBagGetIntProperty(features, L"height");
        if (height != -1)
            config->SetHeight(height);
    }

    AutoPtr<UserWindow> window(UserWindow::CreateWindow(config,
        this->window->GetAutoPtr().cast<UserWindow>()));
    window->Open();

    // UserWindowWin::GetWebView returns a borrowed reference
    // but this delegate should return a new reference, so bump
    // the reference count before returning.
    *newWebView = window.cast<UserWindowWin>()->GetWebView();
    (*newWebView)->AddRef();
    return S_OK;
}
HRESULT STDMETHODCALLTYPE Win32WebKitUIDelegate::createWebViewWithRequest(
	/* [in] */ IWebView *sender,
	/* [in] */ IWebURLRequest *request,
	/* [in] */ IPropertyBag *features,
	/* [retval][out] */ IWebView **newWebView)
{
	WindowConfig *config = new WindowConfig();
	BSTR burl;
	request->URL(&burl);
	std::string url = _bstr_t(burl);

	if (url.size() > 0)
	{
		config->SetURL(url);
	}

	if (features)
	{
		int fullscreen = PropertyBagGetIntProperty(features, L"fullscreen");
		if (fullscreen != -1)
			config->SetFullscreen(fullscreen == 1);

		int x = PropertyBagGetIntProperty(features, L"x");
		if (x != -1)
			config->SetX(x);

		int y = PropertyBagGetIntProperty(features, L"y");
		if (y != -1)
			config->SetY(y);

		int width = PropertyBagGetIntProperty(features, L"width");
		if (width != -1)
			config->SetWidth(width);

		int height = PropertyBagGetIntProperty(features, L"height");
		if (height != -1)
			config->SetHeight(height);
	}

	AutoUserWindow parent = this->window->GetAutoPtr().cast<UserWindow>();
	AutoUserWindow window = UIBinding::GetInstance()->CreateWindow(config, parent);
	window->Open();

	*newWebView = window.cast<Win32UserWindow>()->GetWebView();
	return S_OK;
}