Changeset 231707 in webkit


Ignore:
Timestamp:
May 11, 2018 10:37:04 AM (6 years ago)
Author:
Fujii Hironori
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.

Location:
trunk/Tools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r231704 r231707  
     12018-05-11  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win][MiniBrowser] Move WK1 related code into MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=185418
     5
     6        Reviewed by Alex Christensen.
     7
     8        All WK1 related code should be moved into MiniBrowser for the preparation
     9        of Bug 184770.
     10
     11        This change moves the initilization code of MiniBrowse into MiniBrowser::init().
     12
     13        * MiniBrowser/win/Common.cpp:
     14        (getAppDataFolder): Removed `static` keyword to be called from MiniBrowser.cpp.
     15        (setCacheFolder): This is only for WK1. Moved into MiniBrowser.cpp.
     16        * MiniBrowser/win/Common.h: Added.
     17        * MiniBrowser/win/MiniBrowser.cpp:
     18        (MiniBrowser::init): Moved the initilization code from wWinMain.
     19        (MiniBrowser::setCacheFolder): Moved from Common.cpp and made it a method.
     20        * MiniBrowser/win/MiniBrowser.h:
     21        (MiniBrowser::setCacheFolder): Changed to a private method.
     22        (MiniBrowser::subclassForLayeredWindow): Changed to a private method.
     23        * MiniBrowser/win/WinMain.cpp:
     24        (wWinMain): Moved MiniBrowse initilization code into MiniBrowser.cpp.
     25
    1262018-05-11  Brady Eidson  <beidson@apple.com>
    227
  • trunk/Tools/MiniBrowser/win/Common.cpp

    r231658 r231707  
    2727 */
    2828
    29 #include "AccessibilityDelegate.h"
    3029#include "DOMDefaultImpl.h"
    31 #include "PrintWebUIDelegate.h"
    32 #include "ResourceLoadDelegate.h"
    33 #include "WebDownloadDelegate.h"
    3430#include "MiniBrowser.h"
    3531#include "MiniBrowserReplace.h"
     
    155151}
    156152
    157 static bool getAppDataFolder(_bstr_t& directory)
     153bool getAppDataFolder(_bstr_t& directory)
    158154{
    159155    wchar_t appDataDirectory[MAX_PATH];
     
    168164
    169165    directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
    170 
    171     return true;
    172 }
    173 
    174 static bool setCacheFolder()
    175 {
    176     IWebCachePtr webCache = gMiniBrowser->webCache();
    177     if (!webCache)
    178         return false;
    179 
    180     _bstr_t appDataFolder;
    181     if (!getAppDataFolder(appDataFolder))
    182         return false;
    183 
    184     appDataFolder += L"\\cache";
    185     webCache->setCacheFolder(appDataFolder);
    186166
    187167    return true;
  • trunk/Tools/MiniBrowser/win/MiniBrowser.cpp

    r231658 r231707  
    3030#include "MiniBrowser.h"
    3131
     32#include "AccessibilityDelegate.h"
     33#include "Common.h"
    3234#include "DOMDefaultImpl.h"
    3335#include "MiniBrowserLibResource.h"
    3436#include "MiniBrowserReplace.h"
     37#include "MiniBrowserWebHost.h"
     38#include "PrintWebUIDelegate.h"
     39#include "ResourceLoadDelegate.h"
     40#include "WebDownloadDelegate.h"
    3541#include <WebKitLegacy/WebKitCOMAPI.h>
    3642#include <wtf/ExportMacros.h>
     
    6470}
    6571
    66 HRESULT MiniBrowser::init()
     72HRESULT MiniBrowser::init(_bstr_t& requestedURL)
    6773{
    6874    updateDeviceScaleFactor();
     
    8591
    8692    hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(m_webCache), reinterpret_cast<void**>(&m_webCache.GetInterfacePtr()));
     93    if (FAILED(hr))
     94        return hr;
     95
     96    if (!seedInitialDefaultPreferences())
     97        return E_FAIL;
     98
     99    if (!setToDefaultPreferences())
     100        return E_FAIL;
     101
     102    if (!setCacheFolder())
     103        return E_FAIL;
     104
     105    auto webHost = new MiniBrowserWebHost(this, m_hURLBarWnd);
     106
     107    hr = setFrameLoadDelegate(webHost);
     108    if (FAILED(hr))
     109        return hr;
     110
     111    hr = setFrameLoadDelegatePrivate(webHost);
     112    if (FAILED(hr))
     113        return hr;
     114
     115    hr = setUIDelegate(new PrintWebUIDelegate());
     116    if (FAILED (hr))
     117        return hr;
     118
     119    hr = setAccessibilityDelegate(new AccessibilityDelegate());
     120    if (FAILED (hr))
     121        return hr;
     122
     123    hr = setResourceLoadDelegate(new ResourceLoadDelegate(this));
     124    if (FAILED(hr))
     125        return hr;
     126
     127    IWebDownloadDelegatePtr downloadDelegate;
     128    downloadDelegate.Attach(new WebDownloadDelegate());
     129    hr = setDownloadDelegate(downloadDelegate);
     130    if (FAILED(hr))
     131        return hr;
     132
     133    RECT clientRect;
     134    ::GetClientRect(m_hMainWnd, &clientRect);
     135    if (usesLayeredWebView())
     136        clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
     137
     138    hr = prepareViews(m_hMainWnd, clientRect, requestedURL.GetBSTR());
     139    if (FAILED(hr))
     140        return hr;
     141
     142    if (usesLayeredWebView())
     143        subclassForLayeredWindow();
    87144
    88145    return hr;
     146}
     147
     148bool MiniBrowser::setCacheFolder()
     149{
     150    _bstr_t appDataFolder;
     151    if (!getAppDataFolder(appDataFolder))
     152        return false;
     153
     154    appDataFolder += L"\\cache";
     155    webCache()->setCacheFolder(appDataFolder);
     156
     157    return true;
    89158}
    90159
  • trunk/Tools/MiniBrowser/win/MiniBrowser.h

    r231658 r231707  
    5050    MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
    5151
    52     HRESULT init();
     52    HRESULT init(_bstr_t& requestedURL);
    5353    HRESULT prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL);
    5454
     
    9999    HGDIOBJ urlBarFont() { return m_hURLBarFont; }
    100100    HWND hwnd() { return m_viewWnd; }
    101     void subclassForLayeredWindow();
    102101
    103102private:
     103    void subclassForLayeredWindow();
    104104    void generateFontForScaleFactor(float);
     105    bool setCacheFolder();
    105106
    106107    std::vector<IWebHistoryItemPtr> m_historyItems;
  • trunk/Tools/MiniBrowser/win/WinMain.cpp

    r231658 r231707  
    3131#include "stdafx.h"
    3232#include "MiniBrowserLibResource.h"
    33 #include "MiniBrowserWebHost.h"
    3433#include "Common.cpp"
    3534
     
    104103    SetFocus(hURLBarWnd);
    105104
    106     RECT clientRect;
    107     ::GetClientRect(hMainWnd, &clientRect);
    108 
    109     if (usesLayeredWebView)
    110         clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
    111 
    112     MiniBrowserWebHost* webHost = nullptr;
    113 
    114     IWebDownloadDelegatePtr downloadDelegate;
    115     downloadDelegate.Attach(new WebDownloadDelegate());
    116 
    117105    gMiniBrowser = new MiniBrowser(hMainWnd, hURLBarWnd, usesLayeredWebView, pageLoadTesting);
    118106    if (!gMiniBrowser)
    119107        goto exit;
    120 
    121     if (!gMiniBrowser->seedInitialDefaultPreferences())
    122         goto exit;
    123 
    124     if (!gMiniBrowser->setToDefaultPreferences())
    125         goto exit;
    126 
    127     HRESULT hr = gMiniBrowser->init();
     108    HRESULT hr = gMiniBrowser->init(requestedURL);
    128109    if (FAILED(hr))
    129110        goto exit;
    130111
    131     if (!setCacheFolder())
    132         goto exit;
    133 
    134     webHost = new MiniBrowserWebHost(gMiniBrowser, hURLBarWnd);
    135 
    136     hr = gMiniBrowser->setFrameLoadDelegate(webHost);
    137     if (FAILED(hr))
    138         goto exit;
    139 
    140     hr = gMiniBrowser->setFrameLoadDelegatePrivate(webHost);
    141     if (FAILED(hr))
    142         goto exit;
    143 
    144     hr = gMiniBrowser->setUIDelegate(new PrintWebUIDelegate());
    145     if (FAILED (hr))
    146         goto exit;
    147 
    148     hr = gMiniBrowser->setAccessibilityDelegate(new AccessibilityDelegate());
    149     if (FAILED (hr))
    150         goto exit;
    151 
    152     hr = gMiniBrowser->setResourceLoadDelegate(new ResourceLoadDelegate(gMiniBrowser));
    153     if (FAILED(hr))
    154         goto exit;
    155 
    156     hr = gMiniBrowser->setDownloadDelegate(downloadDelegate);
    157     if (FAILED(hr))
    158         goto exit;
    159 
    160     hr = gMiniBrowser->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR());
    161     if (FAILED(hr))
    162         goto exit;
    163112    gViewWindow = gMiniBrowser->hwnd();
    164 
    165     if (gMiniBrowser->usesLayeredWebView())
    166         gMiniBrowser->subclassForLayeredWindow();
    167113
    168114    resizeSubViews();
Note: See TracChangeset for help on using the changeset viewer.