summaryrefslogtreecommitdiffstats
path: root/WebKit/win/WebCoreSupport/WebChromeClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/win/WebCoreSupport/WebChromeClient.cpp')
-rw-r--r--WebKit/win/WebCoreSupport/WebChromeClient.cpp91
1 files changed, 54 insertions, 37 deletions
diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
index 1c0401f..5d39452 100644
--- a/WebKit/win/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
@@ -26,10 +26,13 @@
#include "config.h"
#include "WebChromeClient.h"
+#include "COMPropertyBag.h"
+#include "COMVariantSetter.h"
#include "WebElementPropertyBag.h"
#include "WebFrame.h"
#include "WebHistory.h"
#include "WebMutableURLRequest.h"
+#include "WebDesktopNotificationsDelegate.h"
#include "WebSecurityOrigin.h"
#include "WebView.h"
#pragma warning(push, 0)
@@ -58,6 +61,9 @@ static const size_t maxFilePathsListSize = USHRT_MAX;
WebChromeClient::WebChromeClient(WebView* webView)
: m_webView(webView)
+#if ENABLE(NOTIFICATIONS)
+ , m_notificationsDelegate(new WebDesktopNotificationsDelegate(webView))
+#endif
{
}
@@ -150,35 +156,59 @@ void WebChromeClient::takeFocus(FocusDirection direction)
}
}
+static COMPtr<IPropertyBag> createWindowFeaturesPropertyBag(const WindowFeatures& features)
+{
+ HashMap<String, COMVariant> map;
+ if (features.xSet)
+ map.set(WebWindowFeaturesXKey, features.x);
+ if (features.ySet)
+ map.set(WebWindowFeaturesYKey, features.y);
+ if (features.widthSet)
+ map.set(WebWindowFeaturesWidthKey, features.width);
+ if (features.heightSet)
+ map.set(WebWindowFeaturesHeightKey, features.height);
+ map.set(WebWindowFeaturesMenuBarVisibleKey, features.menuBarVisible);
+ map.set(WebWindowFeaturesStatusBarVisibleKey, features.statusBarVisible);
+ map.set(WebWindowFeaturesToolBarVisibleKey, features.toolBarVisible);
+ map.set(WebWindowFeaturesScrollbarsVisibleKey, features.scrollbarsVisible);
+ map.set(WebWindowFeaturesResizableKey, features.resizable);
+ map.set(WebWindowFeaturesFullscreenKey, features.fullscreen);
+ map.set(WebWindowFeaturesDialogKey, features.dialog);
+
+ return COMPtr<IPropertyBag>(AdoptCOM, COMPropertyBag<COMVariant>::adopt(map));
+}
+
Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& features)
{
- if (features.dialog) {
- COMPtr<IWebUIDelegate> delegate = uiDelegate();
- if (!delegate)
- return 0;
- COMPtr<IWebMutableURLRequest> request(AdoptCOM, WebMutableURLRequest::createInstance(frameLoadRequest.resourceRequest()));
- COMPtr<IWebView> dialog;
- if (FAILED(delegate->createModalDialog(m_webView, request.get(), &dialog)))
+ COMPtr<IWebUIDelegate> delegate = uiDelegate();
+ if (!delegate)
+ return 0;
+
+ COMPtr<IWebMutableURLRequest> request(AdoptCOM, WebMutableURLRequest::createInstance(frameLoadRequest.resourceRequest()));
+
+ COMPtr<IWebUIDelegatePrivate2> delegatePrivate(Query, delegate);
+ if (delegatePrivate) {
+ COMPtr<IWebView> newWebView;
+ HRESULT hr = delegatePrivate->createWebViewWithRequest(m_webView, request.get(), createWindowFeaturesPropertyBag(features).get(), &newWebView);
+
+ if (SUCCEEDED(hr) && newWebView)
+ return core(newWebView.get());
+
+ // If the delegate doesn't implement the IWebUIDelegatePrivate2 version of the call, fall back
+ // to the old versions (even if they support the IWebUIDelegatePrivate2 interface).
+ if (hr != E_NOTIMPL)
return 0;
- return core(dialog.get());
}
- Page* page = 0;
- IWebUIDelegate* uiDelegate = 0;
- IWebMutableURLRequest* request = WebMutableURLRequest::createInstance(frameLoadRequest.resourceRequest());
+ COMPtr<IWebView> newWebView;
- if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) {
- IWebView* webView = 0;
- if (SUCCEEDED(uiDelegate->createWebViewWithRequest(m_webView, request, &webView))) {
- page = core(webView);
- webView->Release();
- }
-
- uiDelegate->Release();
- }
+ if (features.dialog) {
+ if (FAILED(delegate->createModalDialog(m_webView, request.get(), &newWebView)))
+ return 0;
+ } else if (FAILED(delegate->createWebViewWithRequest(m_webView, request.get(), &newWebView)))
+ return 0;
- request->Release();
- return page;
+ return newWebView ? core(newWebView.get()) : 0;
}
void WebChromeClient::show()
@@ -411,20 +441,7 @@ bool WebChromeClient::tabsToLinks() const
IntRect WebChromeClient::windowResizerRect() const
{
- IntRect intRect;
-
- IWebUIDelegate* ui;
- if (SUCCEEDED(m_webView->uiDelegate(&ui)) && ui) {
- IWebUIDelegatePrivate* uiPrivate;
- if (SUCCEEDED(ui->QueryInterface(IID_IWebUIDelegatePrivate, (void**)&uiPrivate))) {
- RECT r;
- if (SUCCEEDED(uiPrivate->webViewResizerRect(m_webView, &r)))
- intRect = IntRect(r.left, r.top, r.right-r.left, r.bottom-r.top);
- uiPrivate->Release();
- }
- ui->Release();
- }
- return intRect;
+ return IntRect();
}
void WebChromeClient::repaint(const IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly)
@@ -469,7 +486,7 @@ IntPoint WebChromeClient::screenToWindow(const IntPoint& point) const
return result;
}
-PlatformWidget WebChromeClient::platformWindow() const
+PlatformPageClient WebChromeClient::platformPageClient() const
{
HWND viewWindow;
if (FAILED(m_webView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewWindow))))