Source/WebCore: Added adoptCOM to COMPtr on Windows.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Oct 2013 20:20:02 +0000 (20:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Oct 2013 20:20:02 +0000 (20:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122069

Patch by Alex Christensen <achristensen@webkit.org> on 2013-10-01
Reviewed by Brent Fulgham.

* platform/win/COMPtr.h:
(adoptCOM): Added.

Source/WebKit/win: Implemented createWebViewWithRequest in WinLauncher.
https://bugs.webkit.org/show_bug.cgi?id=122069

Patch by Alex Christensen <achristensen@webkit.org> on 2013-10-01
Reviewed by Brent Fulgham.

* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::createWindow):
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchCreatePage):
Pass request url from the NavigationAction to createWebViewWithRequest.

Tools: Implemented createWebViewWithRequest in WinLauncher.
https://bugs.webkit.org/show_bug.cgi?id=122069

Patch by Alex Christensen <achristensen@webkit.org> on 2013-10-01
Reviewed by Brent Fulgham.

* WinLauncher/PrintWebUIDelegate.cpp:
(PrintWebUIDelegate::createWebViewWithRequest): Added.
* WinLauncher/PrintWebUIDelegate.h:
Removed createWebViewWithRequest stub.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/win/COMPtr.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Tools/ChangeLog
Tools/WinLauncher/PrintWebUIDelegate.cpp
Tools/WinLauncher/PrintWebUIDelegate.h

index 7d39bf6db6b2933ecfd513e980c630904563fdfe..1108bd4d4a6e489a4cc0bd1aeaf01b116c63b17f 100644 (file)
@@ -1,3 +1,13 @@
+2013-10-01  Alex Christensen  <achristensen@webkit.org>
+
+        Added adoptCOM to COMPtr on Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=122069
+
+        Reviewed by Brent Fulgham.
+
+        * platform/win/COMPtr.h:
+        (adoptCOM): Added.
+
 2013-10-01  Jer Noble  <jer.noble@apple.com>
 
         Unreviewed build fix; The addedFunction and removedFunction arguments to determineChangedTracksFromNewTracksAndOldItems
index c1a925dabcdd90dc4dbf6beda35539975852f221..314a0ae5b156a29e24f684271af89b7a66a0a50a 100644 (file)
@@ -101,6 +101,11 @@ private:
     T* m_ptr;
 };
 
+template<typename T> inline COMPtr<T> adoptCOM(T *ptr)
+{
+    return COMPtr<T>(AdoptCOM, ptr);
+}
+
 template<typename T> inline void COMPtr<T>::clear()
 {
     if (T* ptr = m_ptr) {
index ab17ae29bccf4ac3a70ac2f548543b1cc2979eaf..7fc5767c78115fe3a74e5b584ffd306a56a6efcd 100644 (file)
@@ -1,3 +1,16 @@
+2013-10-01  Alex Christensen  <achristensen@webkit.org>
+
+        Implemented createWebViewWithRequest in WinLauncher.
+        https://bugs.webkit.org/show_bug.cgi?id=122069
+
+        Reviewed by Brent Fulgham.
+
+        * WebCoreSupport/WebChromeClient.cpp:
+        (WebChromeClient::createWindow):
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchCreatePage):
+        Pass request url from the NavigationAction to createWebViewWithRequest.
+
 2013-09-30  Andreas Kling  <akling@apple.com>
 
         Try to fix the Windows build.
index 9f19c3c3292e5dc35f0586e6dcab78b2bba03866..3ddf0ee25200d3e223db9a813c2d9b10f7f33e69 100644 (file)
@@ -194,14 +194,13 @@ static COMPtr<IPropertyBag> createWindowFeaturesPropertyBag(const WindowFeatures
     return COMPtr<IPropertyBag>(AdoptCOM, COMPropertyBag<COMVariant>::adopt(map));
 }
 
-Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& features, const NavigationAction&)
+Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& features, const NavigationAction& navigationAction)
 {
     COMPtr<IWebUIDelegate> delegate = uiDelegate();
     if (!delegate)
         return 0;
 
-    // Just create a blank request because createWindow() is only required to create window but not to load URL.
-    COMPtr<IWebMutableURLRequest> request(AdoptCOM, WebMutableURLRequest::createInstance());
+    COMPtr<WebMutableURLRequest> request = adoptCOM(WebMutableURLRequest::createInstance(ResourceRequest(navigationAction.url())));
 
     COMPtr<IWebUIDelegatePrivate2> delegatePrivate(Query, delegate);
     if (delegatePrivate) {
index 0cdfd84651d237a5f68737aa16e396582c668a83..f4cb8ce21568940a736670334bb955aedc95e98f 100644 (file)
@@ -529,7 +529,7 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones)
     }
 }
 
-Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction&)
+Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
 {
     WebView* webView = m_webFrame->webView();
 
@@ -538,7 +538,8 @@ Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction&)
         return 0;
 
     COMPtr<IWebView> newWebView;
-    if (FAILED(ui->createWebViewWithRequest(webView, 0, &newWebView)))
+    COMPtr<WebMutableURLRequest> request = adoptCOM(WebMutableURLRequest::createInstance(ResourceRequest(navigationAction.url())));
+    if (FAILED(ui->createWebViewWithRequest(webView, request.get(), &newWebView)) || !newWebView)
         return 0;
 
     COMPtr<IWebFrame> mainFrame;
index e27b420580867af76f7c4557215248cd7a013bf3..b477adf8154fd1a4c0f3a76ed0b0094fdedd42fb 100644 (file)
@@ -1,3 +1,15 @@
+2013-10-01  Alex Christensen  <achristensen@webkit.org>
+
+        Implemented createWebViewWithRequest in WinLauncher.
+        https://bugs.webkit.org/show_bug.cgi?id=122069
+
+        Reviewed by Brent Fulgham.
+
+        * WinLauncher/PrintWebUIDelegate.cpp:
+        (PrintWebUIDelegate::createWebViewWithRequest): Added.
+        * WinLauncher/PrintWebUIDelegate.h:
+        Removed createWebViewWithRequest stub.
+
 2013-10-01  Tim Horton  <timothy_horton@apple.com>
 
         [wk2] WebKitTestRunner's window snapshots are blank with tiled drawing
index 720c7a24f51dda41a8f5315ac7f6fa389526c9a4..799fa6f772c5a3706825c1e7cd2e160b768f1637 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2009, 2013 Apple Inc. All Rights Reserved.
  * Copyright (C) 2009 Brent Fulgham. All Rights Reserved.
+ * Copyright (C) 2013 Alex Christensen. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 static const int MARGIN = 20;
 
+HRESULT STDMETHODCALLTYPE PrintWebUIDelegate::createWebViewWithRequest(IWebView*, IWebURLRequest* request, IWebView**)
+{
+    if (!request)
+        return E_POINTER;
+
+    TCHAR executablePath[MAX_PATH];
+    DWORD length = ::GetModuleFileName(GetModuleHandle(0), executablePath, ARRAYSIZE(executablePath));
+    if (!length)
+        return E_FAIL;
+
+    _bstr_t url;
+    HRESULT hr = request->URL(&url.GetBSTR());
+    if (FAILED(hr))
+        return E_FAIL;
+
+    std::wstring command = std::wstring(L"\"") + executablePath + L"\" " + (const wchar_t*)url;
+
+    PROCESS_INFORMATION processInformation;
+    STARTUPINFOW startupInfo;
+    memset(&startupInfo, 0, sizeof(startupInfo));
+    if (!::CreateProcessW(0, (LPWSTR)command.c_str(), 0, 0, 0, 0, 0, 0, &startupInfo, &processInformation))
+        return E_FAIL;
+
+    return S_OK;
+}
+
 HRESULT PrintWebUIDelegate::QueryInterface(REFIID riid, void** ppvObject)
 {
     *ppvObject = 0;
index 9749a9807b55573e2e904674d724e71a638916ba..d4d5223e93f922e9a13ae50dc7f7a0dfbddd224d 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual ULONG STDMETHODCALLTYPE AddRef(void);
     virtual ULONG STDMETHODCALLTYPE Release(void);
 
-    virtual HRESULT STDMETHODCALLTYPE createWebViewWithRequest(IWebView*, IWebURLRequest*, IWebView**) { return E_NOTIMPL; }
+    virtual HRESULT STDMETHODCALLTYPE createWebViewWithRequest(IWebView*, IWebURLRequest*, IWebView**);
     virtual HRESULT STDMETHODCALLTYPE webViewShow(IWebView*) { return E_NOTIMPL; }
     virtual HRESULT STDMETHODCALLTYPE webViewClose(IWebView*) { return E_NOTIMPL; }
     virtual HRESULT STDMETHODCALLTYPE webViewFocus(IWebView*) { return E_NOTIMPL; }