[Win][MiniBrowser] Change to use WebKit by default if it's available
authorBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2018 00:23:03 +0000 (00:23 +0000)
committerBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2018 00:23:03 +0000 (00:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186633

When MiniBrowser is built with WebKit, use it by default. Also add command
line switch for WebKitLegacy.

Reviewed by Youenn Fablet.

* MiniBrowser/win/Common.cpp:
(parseCommandLine):
(dllLauncherEntryPoint): Deleted.
* MiniBrowser/win/Common.h:
* MiniBrowser/win/WinMain.cpp:
(wWinMain):
(dllLauncherEntryPoint):

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

Tools/ChangeLog
Tools/MiniBrowser/win/Common.cpp
Tools/MiniBrowser/win/Common.h
Tools/MiniBrowser/win/WinMain.cpp

index 2e76256..656706c 100644 (file)
@@ -1,3 +1,21 @@
+2018-06-14  Basuke Suzuki  <Basuke.Suzuki@sony.com>
+
+        [Win][MiniBrowser] Change to use WebKit by default if it's available
+        https://bugs.webkit.org/show_bug.cgi?id=186633
+
+        When MiniBrowser is built with WebKit, use it by default. Also add command
+        line switch for WebKitLegacy.
+
+        Reviewed by Youenn Fablet.
+
+        * MiniBrowser/win/Common.cpp:
+        (parseCommandLine):
+        (dllLauncherEntryPoint): Deleted.
+        * MiniBrowser/win/Common.h:
+        * MiniBrowser/win/WinMain.cpp:
+        (wWinMain):
+        (dllLauncherEntryPoint):
+
 2018-06-14  Matt Lewis  <jlewis3@apple.com>
 
         Unreviewed, rolling out r232823.
index fa25f54..3588fc4 100644 (file)
@@ -165,29 +165,30 @@ HRESULT displayAuthDialog(HWND hwnd, std::wstring& username, std::wstring& passw
     return result > 0 ? S_OK : E_FAIL;
 }
 
-void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL)
+CommandLineOptions parseCommandLine()
 {
-    usesLayeredWebView = false;
-    useFullDesktop = false;
-    pageLoadTesting = false;
+    CommandLineOptions options;
 
     int argc = 0;
     WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
     for (int i = 1; i < argc; ++i) {
         if (!wcsicmp(argv[i], L"--transparent"))
-            usesLayeredWebView = true;
+            options.usesLayeredWebView = true;
         else if (!wcsicmp(argv[i], L"--desktop"))
-            useFullDesktop = true;
+            options.useFullDesktop = true;
         else if (!wcsicmp(argv[i], L"--performance"))
-            pageLoadTesting = true;
+            options.pageLoadTesting = true;
         else if (!wcsicmp(argv[i], L"--highDPI"))
             continue; // ignore
-        else if (!requestedURL)
-            requestedURL = argv[i];
+        else if (!wcsicmp(argv[i], L"--wk1") || !wcsicmp(argv[i], L"--legacy"))
+            options.windowType = MainWindow::BrowserWindowType::WebKitLegacy;
+#if ENABLE(WEBKIT)
+        else if (!wcsicmp(argv[i], L"--wk2") || !wcsicmp(argv[i], L"--webkit"))
+            options.windowType = MainWindow::BrowserWindowType::WebKit;
+#endif
+        else if (!options.requestedURL)
+            options.requestedURL = argv[i];
     }
-}
 
-extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
-{
-    return wWinMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
+    return options;
 }
index 985fe77..085a313 100644 (file)
 #include "MainWindow.h"
 #include "WebKitLegacyBrowserWindow.h"
 
+struct CommandLineOptions {
+    bool usesLayeredWebView { };
+    bool useFullDesktop { };
+    bool pageLoadTesting { };
+    MainWindow::BrowserWindowType windowType;
+    _bstr_t requestedURL;
+
+    CommandLineOptions()
+#if ENABLE(WEBKIT)
+        : windowType(MainWindow::BrowserWindowType::WebKit)
+#else
+        : windowType(MainWindow::BrowserWindowType::WebKitLegacy)
+#endif
+    {
+    }
+};
+
 void computeFullDesktopFrame();
 bool getAppDataFolder(_bstr_t& directory);
-void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL);
+CommandLineOptions parseCommandLine();
 void createCrashReport(EXCEPTION_POINTERS*);
 HRESULT displayAuthDialog(HWND, std::wstring& username, std::wstring& password);
 
index c96a677..426a09e 100644 (file)
@@ -50,14 +50,9 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
     InitCtrlEx.dwICC  = 0x00004000; // ICC_STANDARD_CLASSES;
     InitCommonControlsEx(&InitCtrlEx);
 
-    bool usesLayeredWebView = false;
-    bool useFullDesktop = false;
-    bool pageLoadTesting = false;
-    _bstr_t requestedURL;
+    auto options = parseCommandLine();
 
-    parseCommandLine(usesLayeredWebView, useFullDesktop, pageLoadTesting, requestedURL);
-
-    if (useFullDesktop)
+    if (options.useFullDesktop)
         computeFullDesktopFrame();
 
     // Init COM
@@ -65,8 +60,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
 
     ::SetProcessDPIAware();
 
-    auto& mainWindow = MainWindow::create(MainWindow::BrowserWindowType::WebKitLegacy).leakRef();
-    HRESULT hr = mainWindow.init(hInst, usesLayeredWebView, pageLoadTesting);
+    auto& mainWindow = MainWindow::create(options.windowType).leakRef();
+    HRESULT hr = mainWindow.init(hInst, options.usesLayeredWebView, options.pageLoadTesting);
     if (FAILED(hr))
         goto exit;
 
@@ -74,8 +69,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
 
     hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER));
 
-    if (requestedURL.length())
-        mainWindow.loadURL(requestedURL.GetBSTR());
+    if (options.requestedURL.length())
+        mainWindow.loadURL(options.requestedURL.GetBSTR());
     else
         mainWindow.browserWindow()->loadHTMLString(_bstr_t(defaultHTML).GetBSTR());
 
@@ -104,3 +99,8 @@ exit:
 
     return static_cast<int>(msg.wParam);
 }
+
+extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
+{
+    return wWinMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
+}