Title: [231707] trunk/Tools
Revision
231707
Author
[email protected]
Date
2018-05-11 10:37:04 -0700 (Fri, 11 May 2018)

Log Message

[Win][MiniBrowser] Move WK1 related code into MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=185418

Reviewed by Alex Christensen.

All WK1 related code should be moved into MiniBrowser for the preparation
of Bug 184770.

This change moves the initilization code of MiniBrowse into MiniBrowser::init().

* MiniBrowser/win/Common.cpp:
(getAppDataFolder): Removed `static` keyword to be called from MiniBrowser.cpp.
(setCacheFolder): This is only for WK1. Moved into MiniBrowser.cpp.
* MiniBrowser/win/Common.h: Added.
* MiniBrowser/win/MiniBrowser.cpp:
(MiniBrowser::init): Moved the initilization code from wWinMain.
(MiniBrowser::setCacheFolder): Moved from Common.cpp and made it a method.
* MiniBrowser/win/MiniBrowser.h:
(MiniBrowser::setCacheFolder): Changed to a private method.
(MiniBrowser::subclassForLayeredWindow): Changed to a private method.
* MiniBrowser/win/WinMain.cpp:
(wWinMain): Moved MiniBrowse initilization code into MiniBrowser.cpp.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (231706 => 231707)


--- trunk/Tools/ChangeLog	2018-05-11 17:29:42 UTC (rev 231706)
+++ trunk/Tools/ChangeLog	2018-05-11 17:37:04 UTC (rev 231707)
@@ -1,3 +1,28 @@
+2018-05-11  Fujii Hironori  <[email protected]>
+
+        [Win][MiniBrowser] Move WK1 related code into MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=185418
+
+        Reviewed by Alex Christensen.
+
+        All WK1 related code should be moved into MiniBrowser for the preparation
+        of Bug 184770.
+
+        This change moves the initilization code of MiniBrowse into MiniBrowser::init().
+
+        * MiniBrowser/win/Common.cpp:
+        (getAppDataFolder): Removed `static` keyword to be called from MiniBrowser.cpp.
+        (setCacheFolder): This is only for WK1. Moved into MiniBrowser.cpp.
+        * MiniBrowser/win/Common.h: Added.
+        * MiniBrowser/win/MiniBrowser.cpp:
+        (MiniBrowser::init): Moved the initilization code from wWinMain.
+        (MiniBrowser::setCacheFolder): Moved from Common.cpp and made it a method.
+        * MiniBrowser/win/MiniBrowser.h:
+        (MiniBrowser::setCacheFolder): Changed to a private method.
+        (MiniBrowser::subclassForLayeredWindow): Changed to a private method.
+        * MiniBrowser/win/WinMain.cpp:
+        (wWinMain): Moved MiniBrowse initilization code into MiniBrowser.cpp.
+
 2018-05-11  Brady Eidson  <[email protected]>
 
         Make sure history navigations reuse the existing process when necessary.

Modified: trunk/Tools/MiniBrowser/win/Common.cpp (231706 => 231707)


--- trunk/Tools/MiniBrowser/win/Common.cpp	2018-05-11 17:29:42 UTC (rev 231706)
+++ trunk/Tools/MiniBrowser/win/Common.cpp	2018-05-11 17:37:04 UTC (rev 231707)
@@ -26,11 +26,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#include "AccessibilityDelegate.h"
 #include "DOMDefaultImpl.h"
-#include "PrintWebUIDelegate.h"
-#include "ResourceLoadDelegate.h"
-#include "WebDownloadDelegate.h"
 #include "MiniBrowser.h"
 #include "MiniBrowserReplace.h"
 #include <WebKitLegacy/WebKitCOMAPI.h>
@@ -154,7 +150,7 @@
     return TRUE;
 }
 
-static bool getAppDataFolder(_bstr_t& directory)
+bool getAppDataFolder(_bstr_t& directory)
 {
     wchar_t appDataDirectory[MAX_PATH];
     if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
@@ -171,22 +167,6 @@
     return true;
 }
 
-static bool setCacheFolder()
-{
-    IWebCachePtr webCache = gMiniBrowser->webCache();
-    if (!webCache)
-        return false;
-
-    _bstr_t appDataFolder;
-    if (!getAppDataFolder(appDataFolder))
-        return false;
-
-    appDataFolder += L"\\cache";
-    webCache->setCacheFolder(appDataFolder);
-
-    return true;
-}
-
 void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
 {
     _bstr_t directory;

Added: trunk/Tools/MiniBrowser/win/Common.h (0 => 231707)


--- trunk/Tools/MiniBrowser/win/Common.h	                        (rev 0)
+++ trunk/Tools/MiniBrowser/win/Common.h	2018-05-11 17:37:04 UTC (rev 231707)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+bool getAppDataFolder(_bstr_t& directory);
+
+extern POINT s_windowPosition;
+extern SIZE s_windowSize;

Modified: trunk/Tools/MiniBrowser/win/MiniBrowser.cpp (231706 => 231707)


--- trunk/Tools/MiniBrowser/win/MiniBrowser.cpp	2018-05-11 17:29:42 UTC (rev 231706)
+++ trunk/Tools/MiniBrowser/win/MiniBrowser.cpp	2018-05-11 17:37:04 UTC (rev 231707)
@@ -29,9 +29,15 @@
 #include "stdafx.h"
 #include "MiniBrowser.h"
 
+#include "AccessibilityDelegate.h"
+#include "Common.h"
 #include "DOMDefaultImpl.h"
 #include "MiniBrowserLibResource.h"
 #include "MiniBrowserReplace.h"
+#include "MiniBrowserWebHost.h"
+#include "PrintWebUIDelegate.h"
+#include "ResourceLoadDelegate.h"
+#include "WebDownloadDelegate.h"
 #include <WebKitLegacy/WebKitCOMAPI.h>
 #include <wtf/ExportMacros.h>
 #include <wtf/Platform.h>
@@ -63,7 +69,7 @@
 {
 }
 
-HRESULT MiniBrowser::init()
+HRESULT MiniBrowser::init(_bstr_t& requestedURL)
 {
     updateDeviceScaleFactor();
 
@@ -84,10 +90,73 @@
         return hr;
 
     hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(m_webCache), reinterpret_cast<void**>(&m_webCache.GetInterfacePtr()));
+    if (FAILED(hr))
+        return hr;
 
+    if (!seedInitialDefaultPreferences())
+        return E_FAIL;
+
+    if (!setToDefaultPreferences())
+        return E_FAIL;
+
+    if (!setCacheFolder())
+        return E_FAIL;
+
+    auto webHost = new MiniBrowserWebHost(this, m_hURLBarWnd);
+
+    hr = setFrameLoadDelegate(webHost);
+    if (FAILED(hr))
+        return hr;
+
+    hr = setFrameLoadDelegatePrivate(webHost);
+    if (FAILED(hr))
+        return hr;
+
+    hr = setUIDelegate(new PrintWebUIDelegate());
+    if (FAILED (hr))
+        return hr;
+
+    hr = setAccessibilityDelegate(new AccessibilityDelegate());
+    if (FAILED (hr))
+        return hr;
+
+    hr = setResourceLoadDelegate(new ResourceLoadDelegate(this));
+    if (FAILED(hr))
+        return hr;
+
+    IWebDownloadDelegatePtr downloadDelegate;
+    downloadDelegate.Attach(new WebDownloadDelegate());
+    hr = setDownloadDelegate(downloadDelegate);
+    if (FAILED(hr))
+        return hr;
+
+    RECT clientRect;
+    ::GetClientRect(m_hMainWnd, &clientRect);
+    if (usesLayeredWebView())
+        clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
+
+    hr = prepareViews(m_hMainWnd, clientRect, requestedURL.GetBSTR());
+    if (FAILED(hr))
+        return hr;
+
+    if (usesLayeredWebView())
+        subclassForLayeredWindow();
+
     return hr;
 }
 
+bool MiniBrowser::setCacheFolder()
+{
+    _bstr_t appDataFolder;
+    if (!getAppDataFolder(appDataFolder))
+        return false;
+
+    appDataFolder += L"\\cache";
+    webCache()->setCacheFolder(appDataFolder);
+
+    return true;
+}
+
 HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL)
 {
     if (!m_webView)

Modified: trunk/Tools/MiniBrowser/win/MiniBrowser.h (231706 => 231707)


--- trunk/Tools/MiniBrowser/win/MiniBrowser.h	2018-05-11 17:29:42 UTC (rev 231706)
+++ trunk/Tools/MiniBrowser/win/MiniBrowser.h	2018-05-11 17:37:04 UTC (rev 231707)
@@ -49,7 +49,7 @@
 public:
     MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
 
-    HRESULT init();
+    HRESULT init(_bstr_t& requestedURL);
     HRESULT prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL);
 
     HRESULT loadURL(const BSTR& passedURL);
@@ -98,10 +98,11 @@
 
     HGDIOBJ urlBarFont() { return m_hURLBarFont; }
     HWND hwnd() { return m_viewWnd; }
-    void subclassForLayeredWindow();
 
 private:
+    void subclassForLayeredWindow();
     void generateFontForScaleFactor(float);
+    bool setCacheFolder();
 
     std::vector<IWebHistoryItemPtr> m_historyItems;
 

Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (231706 => 231707)


--- trunk/Tools/MiniBrowser/win/WinMain.cpp	2018-05-11 17:29:42 UTC (rev 231706)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp	2018-05-11 17:37:04 UTC (rev 231707)
@@ -30,7 +30,6 @@
 
 #include "stdafx.h"
 #include "MiniBrowserLibResource.h"
-#include "MiniBrowserWebHost.h"
 #include "Common.cpp"
 
 namespace WebCore {
@@ -103,68 +102,15 @@
 
     SetFocus(hURLBarWnd);
 
-    RECT clientRect;
-    ::GetClientRect(hMainWnd, &clientRect);
-
-    if (usesLayeredWebView)
-        clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
-
-    MiniBrowserWebHost* webHost = nullptr;
-
-    IWebDownloadDelegatePtr downloadDelegate;
-    downloadDelegate.Attach(new WebDownloadDelegate());
-
     gMiniBrowser = new MiniBrowser(hMainWnd, hURLBarWnd, usesLayeredWebView, pageLoadTesting);
     if (!gMiniBrowser)
         goto exit;
-
-    if (!gMiniBrowser->seedInitialDefaultPreferences())
-        goto exit;
-
-    if (!gMiniBrowser->setToDefaultPreferences())
-        goto exit;
-
-    HRESULT hr = gMiniBrowser->init();
+    HRESULT hr = gMiniBrowser->init(requestedURL);
     if (FAILED(hr))
         goto exit;
 
-    if (!setCacheFolder())
-        goto exit;
-
-    webHost = new MiniBrowserWebHost(gMiniBrowser, hURLBarWnd);
-
-    hr = gMiniBrowser->setFrameLoadDelegate(webHost);
-    if (FAILED(hr))
-        goto exit;
-
-    hr = gMiniBrowser->setFrameLoadDelegatePrivate(webHost);
-    if (FAILED(hr))
-        goto exit;
-
-    hr = gMiniBrowser->setUIDelegate(new PrintWebUIDelegate());
-    if (FAILED (hr))
-        goto exit;
-
-    hr = gMiniBrowser->setAccessibilityDelegate(new AccessibilityDelegate());
-    if (FAILED (hr))
-        goto exit;
-
-    hr = gMiniBrowser->setResourceLoadDelegate(new ResourceLoadDelegate(gMiniBrowser));
-    if (FAILED(hr))
-        goto exit;
-
-    hr = gMiniBrowser->setDownloadDelegate(downloadDelegate);
-    if (FAILED(hr))
-        goto exit;
-
-    hr = gMiniBrowser->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR());
-    if (FAILED(hr))
-        goto exit;
     gViewWindow = gMiniBrowser->hwnd();
 
-    if (gMiniBrowser->usesLayeredWebView())
-        gMiniBrowser->subclassForLayeredWindow();
-
     resizeSubViews();
 
     ShowWindow(gViewWindow, nCmdShow);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to