WebKit Bugzilla
Attachment 341553 Details for
Bug 186079
: [Win][MiniBrowser] Move MainWindow related code from Common.cpp to MainWindow.cpp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186079-20180530123812.patch (text/plain), 25.20 KB, created by
Fujii Hironori
on 2018-05-29 20:38:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-05-29 20:38:13 PDT
Size:
25.20 KB
patch
obsolete
>Subversion Revision: 232283 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 10e9cfbe52c401c9e4b26c80817d4be75b7dac61..5e57a2ef71f1a99a4cf16a4223ff09c242a3cf8a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,51 @@ >+2018-05-29 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Move MainWindow related code from Common.cpp to MainWindow.cpp >+ https://bugs.webkit.org/show_bug.cgi?id=186079 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is a sub task of Bug 184770. >+ >+ This change is partial. I'm going to remove global variables >+ gMainWindow and gMiniBrowser and convert more functions to >+ MainWindow's methods in follow-up patches. >+ >+ * MiniBrowser/win/CMakeLists.txt: Added Common.cpp >+ * MiniBrowser/win/Common.cpp: >+ (menuItemIsChecked): Moved to MainWindow.cpp. >+ (turnOffOtherUserAgents): Ditto. >+ (EditProc): Ditto. >+ (BackButtonProc): Ditto. >+ (ForwardButtonProc): Ditto. >+ (About): Ditto. >+ (Caches): Ditto. >+ (CustomUserAgent): Ditto. >+ (AuthDialogProc): Ditto. >+ (DisplayAuthDialog): Converted to MainWindow's method. >+ (ToggleMenuItem): Ditto. >+ (loadURL): Ditto. >+ * MiniBrowser/win/Common.h: >+ * MiniBrowser/win/MainWindow.cpp: >+ (MainWindow::init): Call SetFocus at the end of the construction. >+ (MainWindow::WndProc): >+ (menuItemIsChecked): Moved from Common.cpp. >+ (turnOffOtherUserAgents): Ditto. >+ (EditProc): Ditto. >+ (BackButtonProc): Ditto. >+ (ForwardButtonProc): Ditto. >+ (About): Ditto. >+ (Caches): Ditto. >+ (CustomUserAgent): Ditto. >+ (authDialogProc): Ditto. >+ (MainWindow::displayAuthDialog): Converted from a function of Common.cpp. >+ (MainWindow::toggleMenuItem): Ditto. >+ (MainWindow::loadURL): Ditto. >+ * MiniBrowser/win/MainWindow.h: Added method declarations. >+ * MiniBrowser/win/MiniBrowser.h: Added pragma once. >+ * MiniBrowser/win/WinMain.cpp: >+ (wWinMain): Include Common.h instead of Common.cpp. >+ > 2018-05-29 Youenn Fablet <youenn@apple.com> > > Add a consistency check between URL and CFURL >diff --git a/Tools/MiniBrowser/win/CMakeLists.txt b/Tools/MiniBrowser/win/CMakeLists.txt >index 70e6d7ce56b3e88c1a0b575e13a7a34ec3d1fae0..9a4784d1695c40df62c9b68ee8453e3ee176e682 100644 >--- a/Tools/MiniBrowser/win/CMakeLists.txt >+++ b/Tools/MiniBrowser/win/CMakeLists.txt >@@ -7,6 +7,7 @@ set(MiniBrowser_INCLUDE_DIRECTORIES > > set(MiniBrowser_SOURCES > AccessibilityDelegate.cpp >+ Common.cpp > DOMDefaultImpl.cpp > MainWindow.cpp > PageLoadTestClient.cpp >diff --git a/Tools/MiniBrowser/win/Common.cpp b/Tools/MiniBrowser/win/Common.cpp >index 2b825bcd64855446960618c55e511968adc02f66..b11fefa1d35c761011e51803dd527600efee1045 100644 >--- a/Tools/MiniBrowser/win/Common.cpp >+++ b/Tools/MiniBrowser/win/Common.cpp >@@ -26,41 +26,15 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#include "DOMDefaultImpl.h" >-#include "MainWindow.h" >-#include "MiniBrowser.h" >-#include "MiniBrowserReplace.h" >-#include <WebKitLegacy/WebKitCOMAPI.h> >- >-#if USE(CF) >-#include <CoreFoundation/CFRunLoop.h> >-#endif >+#include "stdafx.h" >+#include "Common.h" > >-#include <cassert> >-#include <comip.h> >-#include <commctrl.h> >-#include <commdlg.h> >-#include <comutil.h> >+#include "MiniBrowserReplace.h" > #include <dbghelp.h> >-#include <memory> >-#include <objbase.h> >-#include <shellapi.h> > #include <shlobj.h> >-#include <shlwapi.h> >-#include <string> >-#include <vector> >-#include <wininet.h> >- >-#ifndef WM_DPICHANGED >-#define WM_DPICHANGED 0x02E0 >-#endif > > // Global Variables: > HINSTANCE hInst; >-HWND hCacheWnd; >-WNDPROC DefEditProc = nullptr; >-WNDPROC DefButtonProc = nullptr; >- > MainWindow* gMainWindow = nullptr; > MiniBrowser* gMiniBrowser = nullptr; > >@@ -68,16 +42,11 @@ MiniBrowser* gMiniBrowser = nullptr; > POINT s_windowPosition = { 100, 100 }; > SIZE s_windowSize = { 500, 200 }; > >-// Forward declarations of functions included in this code module: >-INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); >- >-static void loadURL(BSTR urlBStr); >- > namespace WebCore { > float deviceScaleFactorForWindow(HWND); > } > >-static void computeFullDesktopFrame() >+void computeFullDesktopFrame() > { > RECT desktop; > if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0)) >@@ -150,256 +119,12 @@ void createCrashReport(EXCEPTION_POINTERS* exceptionPointers) > } > } > >-static bool menuItemIsChecked(const MENUITEMINFO& info) >-{ >- return info.fState & MFS_CHECKED; >-} >- >-static void turnOffOtherUserAgents(HMENU menu) >-{ >- MENUITEMINFO info; >- ::memset(&info, 0x00, sizeof(info)); >- info.cbSize = sizeof(info); >- info.fMask = MIIM_STATE; >- >- // Must unset the other menu items: >- for (UINT menuToClear = IDM_UA_DEFAULT; menuToClear <= IDM_UA_OTHER; ++menuToClear) { >- if (!::GetMenuItemInfo(menu, menuToClear, FALSE, &info)) >- continue; >- if (!menuItemIsChecked(info)) >- continue; >- >- info.fState = MFS_UNCHECKED; >- ::SetMenuItemInfo(menu, menuToClear, FALSE, &info); >- } >-} >- >-bool ToggleMenuItem(HWND hWnd, UINT menuID) >-{ >- if (!gMiniBrowser) >- return false; >- >- HMENU menu = ::GetMenu(hWnd); >- >- switch (menuID) { >- case IDM_UA_DEFAULT: >- case IDM_UA_SAFARI_8_0: >- case IDM_UA_SAFARI_IOS_8_IPHONE: >- case IDM_UA_SAFARI_IOS_8_IPAD: >- case IDM_UA_IE_11: >- case IDM_UA_CHROME_MAC: >- case IDM_UA_CHROME_WIN: >- case IDM_UA_FIREFOX_MAC: >- case IDM_UA_FIREFOX_WIN: >- gMiniBrowser->setUserAgent(menuID); >- turnOffOtherUserAgents(menu); >- break; >- case IDM_UA_OTHER: >- // The actual user agent string will be set by the custom user agent dialog >- turnOffOtherUserAgents(menu); >- break; >- } >- >- MENUITEMINFO info = { }; >- info.cbSize = sizeof(info); >- info.fMask = MIIM_STATE; >- >- if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) >- return false; >- >- BOOL newState = !menuItemIsChecked(info); >- info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; >- ::SetMenuItemInfo(menu, menuID, FALSE, &info); >- >- gMiniBrowser->setPreference(menuID, newState); >- >- return true; >-} >- >-LRESULT CALLBACK EditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_CHAR: >- if (wParam == 13) { // Enter Key >- wchar_t strPtr[INTERNET_MAX_URL_LENGTH]; >- *((LPWORD)strPtr) = INTERNET_MAX_URL_LENGTH; >- int strLen = SendMessage(hDlg, EM_GETLINE, 0, (LPARAM)strPtr); >- >- strPtr[strLen] = 0; >- _bstr_t bstr(strPtr); >- loadURL(bstr.GetBSTR()); >- >- return 0; >- } >- default: >- return CallWindowProc(DefEditProc, hDlg, message, wParam, lParam); >- } >-} >- >-LRESULT CALLBACK BackButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_LBUTTONUP: >- gMiniBrowser->goBack(); >- default: >- return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam); >- } >-} >- >-LRESULT CALLBACK ForwardButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_LBUTTONUP: >- gMiniBrowser->goForward(); >- default: >- return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam); >- } >-} >- >-// Message handler for about box. >-INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- UNREFERENCED_PARAMETER(lParam); >- switch (message) { >- case WM_INITDIALOG: >- return (INT_PTR)TRUE; >- >- case WM_COMMAND: >- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >- EndDialog(hDlg, LOWORD(wParam)); >- return (INT_PTR)TRUE; >- } >- break; >- } >- return (INT_PTR)FALSE; >-} >- >-INT_PTR CALLBACK Caches(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- UNREFERENCED_PARAMETER(lParam); >- switch (message) { >- case WM_INITDIALOG: >- ::SetTimer(hDlg, IDT_UPDATE_STATS, 1000, nullptr); >- return (INT_PTR)TRUE; >- >- case WM_COMMAND: >- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >- ::KillTimer(hDlg, IDT_UPDATE_STATS); >- ::DestroyWindow(hDlg); >- hCacheWnd = 0; >- return (INT_PTR)TRUE; >- } >- break; >- >- case IDT_UPDATE_STATS: >- ::InvalidateRect(hDlg, nullptr, FALSE); >- return (INT_PTR)TRUE; >- >- case WM_PAINT: >- gMiniBrowser->updateStatistics(hDlg); >- break; >- } >- >- return (INT_PTR)FALSE; >-} >- >-INT_PTR CALLBACK CustomUserAgent(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- UNREFERENCED_PARAMETER(lParam); >- switch (message) { >- case WM_INITDIALOG: { >- HWND edit = ::GetDlgItem(hDlg, IDC_USER_AGENT_INPUT); >- _bstr_t userAgent; >- if (gMiniBrowser) >- userAgent = gMiniBrowser->userAgent(); >- >- ::SetWindowText(edit, static_cast<LPCTSTR>(userAgent)); >- return (INT_PTR)TRUE; >- } >- >- case WM_COMMAND: >- if (LOWORD(wParam) == IDOK) { >- HWND edit = ::GetDlgItem(hDlg, IDC_USER_AGENT_INPUT); >- >- TCHAR buffer[1024]; >- int strLen = ::GetWindowText(edit, buffer, 1024); >- buffer[strLen] = 0; >- >- _bstr_t bstr(buffer); >- if (bstr.length()) { >- gMiniBrowser->setUserAgent(bstr); >- ::PostMessage(gMainWindow->hwnd(), static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_UA_OTHER, 1), 0); >- } >- } >- >- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >- ::EndDialog(hDlg, LOWORD(wParam)); >- return (INT_PTR)TRUE; >- } >- break; >- } >- return (INT_PTR)FALSE; >-} >- > HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password) > { >- auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), gMainWindow->hwnd(), AuthDialogProc); >- if (!result) >- return E_FAIL; >- >- auto pair = reinterpret_cast<std::pair<std::wstring, std::wstring>*>(result); >- username = pair->first; >- password = pair->second; >- delete pair; >- >- return S_OK; >-} >- >-INT_PTR CALLBACK AuthDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_INITDIALOG: { >- HWND edit = ::GetDlgItem(hDlg, IDC_AUTH_USER); >- ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >- >- edit = ::GetDlgItem(hDlg, IDC_AUTH_PASSWORD); >- ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >- return (INT_PTR)TRUE; >- } >- >- case WM_COMMAND: >- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >- INT_PTR result { }; >- >- if (LOWORD(wParam) == IDOK) { >- TCHAR user[256]; >- int strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_USER), user, 256); >- user[strLen] = 0; >- >- TCHAR pass[256]; >- strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_PASSWORD), pass, 256); >- pass[strLen] = 0; >- >- result = reinterpret_cast<INT_PTR>(new std::pair<std::wstring, std::wstring>(user, pass)); >- } >- >- ::EndDialog(hDlg, result); >- return (INT_PTR)TRUE; >- } >- break; >- } >- return (INT_PTR)FALSE; >-} >- >-static void loadURL(BSTR passedURL) >-{ >- if (FAILED(gMiniBrowser->loadURL(passedURL))) >- return; >- >- SetFocus(gMiniBrowser->hwnd()); >+ return gMainWindow->displayAuthDialog(username, password); > } > >-static void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL) >+void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL) > { > usesLayeredWebView = false; > useFullDesktop = false; >diff --git a/Tools/MiniBrowser/win/Common.h b/Tools/MiniBrowser/win/Common.h >index 61a935721290424c81cdeb59eef2f8f3db889519..c0c4796972e01149867a0d7b52689512ed9fa850 100644 >--- a/Tools/MiniBrowser/win/Common.h >+++ b/Tools/MiniBrowser/win/Common.h >@@ -25,7 +25,17 @@ > > #pragma once > >+#include "stdafx.h" >+#include "MainWindow.h" >+#include "MiniBrowser.h" >+ >+void computeFullDesktopFrame(); > bool getAppDataFolder(_bstr_t& directory); >+void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL); >+void createCrashReport(EXCEPTION_POINTERS*); > >+extern HINSTANCE hInst; >+extern MainWindow* gMainWindow; >+extern MiniBrowser* gMiniBrowser; > extern POINT s_windowPosition; > extern SIZE s_windowSize; >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >index a8de0c66ba65091a37c942d01df7486ef68ecc73..1f5f7ad4606b330f6bee91c55810bcfd1e20aaa5 100644 >--- a/Tools/MiniBrowser/win/MainWindow.cpp >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -25,6 +25,8 @@ > > #include "stdafx.h" > #include "MainWindow.h" >+ >+#include "Common.h" > #include "MiniBrowser.h" > #include "MiniBrowserLibResource.h" > >@@ -34,22 +36,17 @@ float deviceScaleFactorForWindow(HWND); > > static constexpr int controlButtonWidth = 24; > >-extern MainWindow* gMainWindow; >-extern MiniBrowser* gMiniBrowser; >-extern WNDPROC DefEditProc; >-extern WNDPROC DefButtonProc; >-extern HINSTANCE hInst; >-extern HWND hCacheWnd; >- >-LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK BackButtonProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK ForwardButtonProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK ReloadButtonProc(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK CustomUserAgent(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); >-bool ToggleMenuItem(HWND hWnd, UINT menuID); >+static HWND hCacheWnd; >+static WNDPROC DefEditProc = nullptr; >+static WNDPROC DefButtonProc = nullptr; >+ >+static LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM); >+static LRESULT CALLBACK BackButtonProc(HWND, UINT, WPARAM, LPARAM); >+static LRESULT CALLBACK ForwardButtonProc(HWND, UINT, WPARAM, LPARAM); >+static LRESULT CALLBACK ReloadButtonProc(HWND, UINT, WPARAM, LPARAM); >+static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); >+static INT_PTR CALLBACK CustomUserAgent(HWND, UINT, WPARAM, LPARAM); >+static INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); > > std::wstring MainWindow::s_windowClass; > >@@ -110,8 +107,6 @@ bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoa > SetWindowLongPtr(m_hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc)); > SetWindowLongPtr(m_hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc)); > >- SetFocus(m_hURLBarWnd); >- > m_browserWindow = std::make_unique<MiniBrowser>(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); > if (!m_browserWindow) > return false; >@@ -120,6 +115,7 @@ bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoa > return false; > > resizeSubViews(); >+ SetFocus(m_hURLBarWnd); > return true; > } > >@@ -184,7 +180,7 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > break; > case IDM_UA_OTHER: > if (wmEvent) >- ToggleMenuItem(hWnd, wmId); >+ gMainWindow->toggleMenuItem(wmId); > else > DialogBox(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, CustomUserAgent); > break; >@@ -205,7 +201,7 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > gMiniBrowser->showLayerTree(); > break; > default: >- if (!ToggleMenuItem(hWnd, wmId)) >+ if (!gMainWindow->toggleMenuItem(wmId)) > return DefWindowProc(hWnd, message, wParam, lParam); > } > } >@@ -232,3 +228,250 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > > return 0; > } >+ >+static bool menuItemIsChecked(const MENUITEMINFO& info) >+{ >+ return info.fState & MFS_CHECKED; >+} >+ >+static void turnOffOtherUserAgents(HMENU menu) >+{ >+ MENUITEMINFO info; >+ ::memset(&info, 0x00, sizeof(info)); >+ info.cbSize = sizeof(info); >+ info.fMask = MIIM_STATE; >+ >+ // Must unset the other menu items: >+ for (UINT menuToClear = IDM_UA_DEFAULT; menuToClear <= IDM_UA_OTHER; ++menuToClear) { >+ if (!::GetMenuItemInfo(menu, menuToClear, FALSE, &info)) >+ continue; >+ if (!menuItemIsChecked(info)) >+ continue; >+ >+ info.fState = MFS_UNCHECKED; >+ ::SetMenuItemInfo(menu, menuToClear, FALSE, &info); >+ } >+} >+ >+bool MainWindow::toggleMenuItem(UINT menuID) >+{ >+ HMENU menu = ::GetMenu(hwnd()); >+ >+ switch (menuID) { >+ case IDM_UA_DEFAULT: >+ case IDM_UA_SAFARI_8_0: >+ case IDM_UA_SAFARI_IOS_8_IPHONE: >+ case IDM_UA_SAFARI_IOS_8_IPAD: >+ case IDM_UA_IE_11: >+ case IDM_UA_CHROME_MAC: >+ case IDM_UA_CHROME_WIN: >+ case IDM_UA_FIREFOX_MAC: >+ case IDM_UA_FIREFOX_WIN: >+ m_browserWindow->setUserAgent(menuID); >+ turnOffOtherUserAgents(menu); >+ break; >+ case IDM_UA_OTHER: >+ // The actual user agent string will be set by the custom user agent dialog >+ turnOffOtherUserAgents(menu); >+ break; >+ } >+ >+ MENUITEMINFO info = { }; >+ info.cbSize = sizeof(info); >+ info.fMask = MIIM_STATE; >+ >+ if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) >+ return false; >+ >+ BOOL newState = !menuItemIsChecked(info); >+ info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; >+ ::SetMenuItemInfo(menu, menuID, FALSE, &info); >+ >+ m_browserWindow->setPreference(menuID, newState); >+ >+ return true; >+} >+ >+LRESULT CALLBACK EditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_CHAR: >+ if (wParam == 13) { >+ // Enter Key >+ wchar_t strPtr[INTERNET_MAX_URL_LENGTH]; >+ *((LPWORD)strPtr) = INTERNET_MAX_URL_LENGTH; >+ int strLen = SendMessage(hDlg, EM_GETLINE, 0, (LPARAM)strPtr); >+ >+ strPtr[strLen] = 0; >+ _bstr_t bstr(strPtr); >+ gMainWindow->loadURL(bstr.GetBSTR()); >+ >+ return 0; >+ } >+ default: >+ return CallWindowProc(DefEditProc, hDlg, message, wParam, lParam); >+ } >+} >+ >+LRESULT CALLBACK BackButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_LBUTTONUP: >+ gMiniBrowser->goBack(); >+ default: >+ return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam); >+ } >+} >+ >+LRESULT CALLBACK ForwardButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_LBUTTONUP: >+ gMiniBrowser->goForward(); >+ default: >+ return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam); >+ } >+} >+ >+// Message handler for about box. >+INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ UNREFERENCED_PARAMETER(lParam); >+ switch (message) { >+ case WM_INITDIALOG: >+ return (INT_PTR)TRUE; >+ >+ case WM_COMMAND: >+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >+ EndDialog(hDlg, LOWORD(wParam)); >+ return (INT_PTR)TRUE; >+ } >+ break; >+ } >+ return (INT_PTR)FALSE; >+} >+ >+INT_PTR CALLBACK Caches(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ UNREFERENCED_PARAMETER(lParam); >+ switch (message) { >+ case WM_INITDIALOG: >+ ::SetTimer(hDlg, IDT_UPDATE_STATS, 1000, nullptr); >+ return (INT_PTR)TRUE; >+ >+ case WM_COMMAND: >+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >+ ::KillTimer(hDlg, IDT_UPDATE_STATS); >+ ::DestroyWindow(hDlg); >+ hCacheWnd = 0; >+ return (INT_PTR)TRUE; >+ } >+ break; >+ >+ case IDT_UPDATE_STATS: >+ ::InvalidateRect(hDlg, nullptr, FALSE); >+ return (INT_PTR)TRUE; >+ >+ case WM_PAINT: >+ gMiniBrowser->updateStatistics(hDlg); >+ break; >+ } >+ >+ return (INT_PTR)FALSE; >+} >+ >+INT_PTR CALLBACK CustomUserAgent(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ UNREFERENCED_PARAMETER(lParam); >+ switch (message) { >+ case WM_INITDIALOG: { >+ HWND edit = ::GetDlgItem(hDlg, IDC_USER_AGENT_INPUT); >+ _bstr_t userAgent; >+ if (gMiniBrowser) >+ userAgent = gMiniBrowser->userAgent(); >+ >+ ::SetWindowText(edit, static_cast<LPCTSTR>(userAgent)); >+ return (INT_PTR)TRUE; >+ } >+ >+ case WM_COMMAND: >+ if (LOWORD(wParam) == IDOK) { >+ HWND edit = ::GetDlgItem(hDlg, IDC_USER_AGENT_INPUT); >+ >+ TCHAR buffer[1024]; >+ int strLen = ::GetWindowText(edit, buffer, 1024); >+ buffer[strLen] = 0; >+ >+ _bstr_t bstr(buffer); >+ if (bstr.length()) { >+ gMiniBrowser->setUserAgent(bstr); >+ ::PostMessage(gMainWindow->hwnd(), static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_UA_OTHER, 1), 0); >+ } >+ } >+ >+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >+ ::EndDialog(hDlg, LOWORD(wParam)); >+ return (INT_PTR)TRUE; >+ } >+ break; >+ } >+ return (INT_PTR)FALSE; >+} >+ >+static INT_PTR CALLBACK authDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_INITDIALOG: { >+ HWND edit = ::GetDlgItem(hDlg, IDC_AUTH_USER); >+ ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >+ >+ edit = ::GetDlgItem(hDlg, IDC_AUTH_PASSWORD); >+ ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >+ return (INT_PTR)TRUE; >+ } >+ >+ case WM_COMMAND: >+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >+ INT_PTR result { }; >+ >+ if (LOWORD(wParam) == IDOK) { >+ TCHAR user[256]; >+ int strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_USER), user, 256); >+ user[strLen] = 0; >+ >+ TCHAR pass[256]; >+ strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_PASSWORD), pass, 256); >+ pass[strLen] = 0; >+ >+ result = reinterpret_cast<INT_PTR>(new std::pair<std::wstring, std::wstring>(user, pass)); >+ } >+ >+ ::EndDialog(hDlg, result); >+ return (INT_PTR)TRUE; >+ } >+ break; >+ } >+ return (INT_PTR)FALSE; >+} >+ >+HRESULT MainWindow::displayAuthDialog(std::wstring& username, std::wstring& password) >+{ >+ auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), hwnd(), authDialogProc); >+ if (!result) >+ return E_FAIL; >+ >+ auto pair = reinterpret_cast<std::pair<std::wstring, std::wstring>*>(result); >+ username = pair->first; >+ password = pair->second; >+ delete pair; >+ >+ return S_OK; >+} >+ >+void MainWindow::loadURL(BSTR url) >+{ >+ if (FAILED(m_browserWindow->loadURL(url))) >+ return; >+ >+ SetFocus(m_browserWindow->hwnd()); >+} >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >index 2423da7505f303fcd19d7c1ab811ca24327ef001..2900bd2852443d38070a463787a5aa06abaf952d 100644 >--- a/Tools/MiniBrowser/win/MainWindow.h >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -37,12 +37,17 @@ public: > void resizeSubViews(); > HWND hwnd() const { return m_hMainWnd; } > MiniBrowser* browserWindow() const { return m_browserWindow.get(); } >+ >+ void loadURL(BSTR url); >+ HRESULT displayAuthDialog(std::wstring& username, std::wstring& password); > > private: > static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); > static void registerClass(HINSTANCE hInstance); > static std::wstring s_windowClass; > >+ bool toggleMenuItem(UINT menuID); >+ > HWND m_hMainWnd { nullptr }; > HWND m_hURLBarWnd { nullptr }; > HWND m_hBackButtonWnd { nullptr }; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >index f5969191c3b1e0fb1895a0c7915e306840c4a4ac..e86ad6b3554a0552c8498e5a02719475b145a128 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ b/Tools/MiniBrowser/win/MiniBrowser.h >@@ -23,6 +23,7 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >+#pragma once > #include "PageLoadTestClient.h" > #include <WebKitLegacy/WebKit.h> > #include <comip.h> >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index cd971f0aa17af67c227fb15b92b9d70f1dd65d1e..e8b58d2d4e6ad49c781c10566f3791a169c836b1 100644 >--- a/Tools/MiniBrowser/win/WinMain.cpp >+++ b/Tools/MiniBrowser/win/WinMain.cpp >@@ -29,8 +29,10 @@ > #pragma warning(disable: 4091) > > #include "stdafx.h" >+#include "Common.h" > #include "MiniBrowserLibResource.h" >-#include "Common.cpp" >+#include "MiniBrowserReplace.h" >+#include <WebKitLegacy/WebKitCOMAPI.h> > > int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow) > { >@@ -74,7 +76,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER)); > > if (requestedURL.length()) >- loadURL(requestedURL.GetBSTR()); >+ gMainWindow->loadURL(requestedURL.GetBSTR()); > else > gMiniBrowser->loadHTMLString(_bstr_t(defaultHTML).GetBSTR()); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
achristensen
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186079
: 341553