Changeset 232574 in webkit
- Timestamp:
- Jun 6, 2018 11:25:41 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r232573 r232574 1 2018-06-06 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win][MiniBrowser] Remove gMainWindow global variable 4 https://bugs.webkit.org/show_bug.cgi?id=186378 5 6 Reviewed by Ryosuke Niwa. 7 8 I'm going to support multiple MainWindow in Bug 186263. It should 9 not be assumed that MainWindow has only one instance. gMainWindow 10 is used only in DisplayAuthDialog. 11 12 * MiniBrowser/win/Common.cpp: 13 (authDialogProc): Use DWLP_USER to store the dialog data. 14 (displayAuthDialog): Moved and renamed from 15 MainWindow::displayAuthDialog. Use DialogBoxParam instead of 16 DialogBox to pass a data pointer. Do not return S_OK if 17 DialogBoxParam returns -1. Take a HWND argument as the parent 18 window. 19 (DisplayAuthDialog): Deleted. 20 * MiniBrowser/win/Common.h: 21 * MiniBrowser/win/MainWindow.cpp: 22 (authDialogProc): Moved to Common.cpp. 23 (MainWindow::displayAuthDialog): Ditto. 24 * MiniBrowser/win/MainWindow.h: 25 * MiniBrowser/win/ResourceLoadDelegate.cpp: 26 (ResourceLoadDelegate::didReceiveAuthenticationChallenge): 27 * MiniBrowser/win/WinMain.cpp: 28 (wWinMain): Added a local variable mainWindow instead of using 29 gMainWindow. 30 1 31 2018-06-06 Dan Bernstein <mitz@apple.com> 2 32 -
trunk/Tools/MiniBrowser/win/Common.cpp
r232458 r232574 30 30 #include "Common.h" 31 31 32 #include "MiniBrowserLibResource.h" 32 33 #include "MiniBrowserReplace.h" 33 34 #include <dbghelp.h> 34 35 #include <shlobj.h> 36 #include <wtf/StdLibExtras.h> 35 37 36 38 // Global Variables: 37 39 HINSTANCE hInst; 38 MainWindow* gMainWindow = nullptr;39 40 40 41 // Support moving the transparent window … … 119 120 } 120 121 121 HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password) 122 struct AuthDialogData { 123 std::wstring& username; 124 std::wstring& password; 125 }; 126 127 static INT_PTR CALLBACK authDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 122 128 { 123 return gMainWindow->displayAuthDialog(username, password); 129 AuthDialogData& data = *reinterpret_cast<AuthDialogData*>(GetWindowLongPtr(hDlg, DWLP_USER)); 130 switch (message) { 131 case WM_INITDIALOG: 132 SetWindowLongPtr(hDlg, DWLP_USER, lParam); 133 return TRUE; 134 135 case WM_COMMAND: { 136 int wmId = LOWORD(wParam); 137 switch (wmId) { 138 case IDOK: { 139 TCHAR str[256]; 140 int strLen = GetWindowText(GetDlgItem(hDlg, IDC_AUTH_USER), str, WTF_ARRAY_LENGTH(str)-1); 141 str[strLen] = 0; 142 data.username = str; 143 144 strLen = GetWindowText(GetDlgItem(hDlg, IDC_AUTH_PASSWORD), str, WTF_ARRAY_LENGTH(str)-1); 145 str[strLen] = 0; 146 data.password = str; 147 148 EndDialog(hDlg, true); 149 return TRUE; 150 } 151 case IDCANCEL: 152 EndDialog(hDlg, false); 153 return TRUE; 154 } 155 break; 156 } 157 } 158 return FALSE; 159 } 160 161 HRESULT displayAuthDialog(HWND hwnd, std::wstring& username, std::wstring& password) 162 { 163 AuthDialogData data { username, password }; 164 auto result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTH), hwnd, authDialogProc, reinterpret_cast<LPARAM>(&data)); 165 return result > 0 ? S_OK : E_FAIL; 124 166 } 125 167 -
trunk/Tools/MiniBrowser/win/Common.h
r232458 r232574 34 34 void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL); 35 35 void createCrashReport(EXCEPTION_POINTERS*); 36 HRESULT displayAuthDialog(HWND, std::wstring& username, std::wstring& password); 36 37 37 38 extern HINSTANCE hInst; 38 extern MainWindow* gMainWindow;39 39 extern POINT s_windowPosition; 40 40 extern SIZE s_windowSize; -
trunk/Tools/MiniBrowser/win/MainWindow.cpp
r232458 r232574 384 384 } 385 385 386 static INT_PTR CALLBACK authDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)387 {388 switch (message) {389 case WM_INITDIALOG: {390 HWND edit = ::GetDlgItem(hDlg, IDC_AUTH_USER);391 ::SetWindowText(edit, static_cast<LPCTSTR>(L""));392 393 edit = ::GetDlgItem(hDlg, IDC_AUTH_PASSWORD);394 ::SetWindowText(edit, static_cast<LPCTSTR>(L""));395 return (INT_PTR)TRUE;396 }397 398 case WM_COMMAND:399 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {400 INT_PTR result { };401 402 if (LOWORD(wParam) == IDOK) {403 TCHAR user[256];404 int strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_USER), user, 256);405 user[strLen] = 0;406 407 TCHAR pass[256];408 strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_PASSWORD), pass, 256);409 pass[strLen] = 0;410 411 result = reinterpret_cast<INT_PTR>(new std::pair<std::wstring, std::wstring>(user, pass));412 }413 414 ::EndDialog(hDlg, result);415 return (INT_PTR)TRUE;416 }417 break;418 }419 return (INT_PTR)FALSE;420 }421 422 HRESULT MainWindow::displayAuthDialog(std::wstring& username, std::wstring& password)423 {424 auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), hwnd(), authDialogProc);425 if (!result)426 return E_FAIL;427 428 auto pair = reinterpret_cast<std::pair<std::wstring, std::wstring>*>(result);429 username = pair->first;430 password = pair->second;431 delete pair;432 433 return S_OK;434 }435 436 386 void MainWindow::loadURL(BSTR url) 437 387 { -
trunk/Tools/MiniBrowser/win/MainWindow.h
r232458 r232574 40 40 41 41 void loadURL(BSTR url); 42 HRESULT displayAuthDialog(std::wstring& username, std::wstring& password);43 42 44 43 private: -
trunk/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp
r229048 r232574 26 26 #include "ResourceLoadDelegate.h" 27 27 28 #include "Common.h" 28 29 #include "MiniBrowser.h" 29 30 #include "PageLoadTestClient.h" … … 37 38 #include <string> 38 39 #include <wininet.h> 39 40 extern HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password);41 40 42 41 HRESULT ResourceLoadDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject) … … 95 94 96 95 std::wstring username, password; 97 if ( DisplayAuthDialog(username, password) != S_OK)96 if (displayAuthDialog(m_client->hwnd(), username, password) != S_OK) 98 97 return E_FAIL; 99 98 -
trunk/Tools/MiniBrowser/win/WinMain.cpp
r232458 r232574 66 66 ::SetProcessDPIAware(); 67 67 68 gMainWindow = new MainWindow();69 HRESULT hr = gMainWindow->init(hInst, usesLayeredWebView, pageLoadTesting);68 auto mainWindow = new MainWindow(); 69 HRESULT hr = mainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); 70 70 if (FAILED(hr)) 71 71 goto exit; 72 72 73 ShowWindow( gMainWindow->hwnd(), nCmdShow);73 ShowWindow(mainWindow->hwnd(), nCmdShow); 74 74 75 75 hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER)); 76 76 77 77 if (requestedURL.length()) 78 gMainWindow->loadURL(requestedURL.GetBSTR());78 mainWindow->loadURL(requestedURL.GetBSTR()); 79 79 else 80 gMainWindow->browserWindow()->loadHTMLString(_bstr_t(defaultHTML).GetBSTR());80 mainWindow->browserWindow()->loadHTMLString(_bstr_t(defaultHTML).GetBSTR()); 81 81 82 82 #pragma warning(disable:4509)
Note: See TracChangeset
for help on using the changeset viewer.