OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <CommCtrl.h> | 6 #include <CommCtrl.h> |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 #include <time.h> | 8 #include <time.h> |
9 #include <windowsx.h> | 9 #include <windowsx.h> |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Grab a reference to the main UI window (from the window handle) | 167 // Grab a reference to the main UI window (from the window handle) |
168 MainUIWindow* host = FromWindow(GetParent(dialog)); | 168 MainUIWindow* host = FromWindow(GetParent(dialog)); |
169 DCHECK(host); | 169 DCHECK(host); |
170 | 170 |
171 switch (message_id) { | 171 switch (message_id) { |
172 case WM_INITDIALOG: { | 172 case WM_INITDIALOG: { |
173 // Initialize the window text for DLL name edit box | 173 // Initialize the window text for DLL name edit box |
174 HWND edit_box_dll_name = ::GetDlgItem(dialog, IDC_DLL_NAME); | 174 HWND edit_box_dll_name = ::GetDlgItem(dialog, IDC_DLL_NAME); |
175 wchar_t current_dir[MAX_PATH]; | 175 wchar_t current_dir[MAX_PATH]; |
176 if (GetCurrentDirectory(MAX_PATH, current_dir)) { | 176 if (GetCurrentDirectory(MAX_PATH, current_dir)) { |
177 std::wstring dll_path = std::wstring(current_dir) + | 177 base::string16 dll_path = base::string16(current_dir) + |
178 std::wstring(kDefaultDll_); | 178 base::string16(kDefaultDll_); |
179 ::SetWindowText(edit_box_dll_name, dll_path.c_str()); | 179 ::SetWindowText(edit_box_dll_name, dll_path.c_str()); |
180 } | 180 } |
181 | 181 |
182 // Initialize the window text for Entry Point edit box | 182 // Initialize the window text for Entry Point edit box |
183 HWND edit_box_entry_point = ::GetDlgItem(dialog, IDC_ENTRY_POINT); | 183 HWND edit_box_entry_point = ::GetDlgItem(dialog, IDC_ENTRY_POINT); |
184 ::SetWindowText(edit_box_entry_point, kDefaultEntryPoint_); | 184 ::SetWindowText(edit_box_entry_point, kDefaultEntryPoint_); |
185 | 185 |
186 // Initialize the window text for Log File edit box | 186 // Initialize the window text for Log File edit box |
187 HWND edit_box_log_file = ::GetDlgItem(dialog, IDC_LOG_FILE); | 187 HWND edit_box_log_file = ::GetDlgItem(dialog, IDC_LOG_FILE); |
188 ::SetWindowText(edit_box_log_file, kDefaultLogFile_); | 188 ::SetWindowText(edit_box_log_file, kDefaultLogFile_); |
189 | 189 |
190 return static_cast<INT_PTR>(TRUE); | 190 return static_cast<INT_PTR>(TRUE); |
191 } | 191 } |
192 case WM_COMMAND: | 192 case WM_COMMAND: |
193 // If the user presses the OK button (Launch) | 193 // If the user presses the OK button (Launch) |
194 if (LOWORD(wparam) == IDOK) { | 194 if (LOWORD(wparam) == IDOK) { |
195 if (host->OnLaunchDll(dialog)) { | 195 if (host->OnLaunchDll(dialog)) { |
196 if (host->SpawnTarget()) { | 196 if (host->SpawnTarget()) { |
197 ::EndDialog(dialog, LOWORD(wparam)); | 197 ::EndDialog(dialog, LOWORD(wparam)); |
198 } | 198 } |
199 } | 199 } |
200 return static_cast<INT_PTR>(TRUE); | 200 return static_cast<INT_PTR>(TRUE); |
201 } else if (LOWORD(wparam) == IDCANCEL) { | 201 } else if (LOWORD(wparam) == IDCANCEL) { |
202 // If the user presses the Cancel button | 202 // If the user presses the Cancel button |
203 ::EndDialog(dialog, LOWORD(wparam)); | 203 ::EndDialog(dialog, LOWORD(wparam)); |
204 return static_cast<INT_PTR>(TRUE); | 204 return static_cast<INT_PTR>(TRUE); |
205 } else if (LOWORD(wparam) == IDC_BROWSE_DLL) { | 205 } else if (LOWORD(wparam) == IDC_BROWSE_DLL) { |
206 // If the user presses the Browse button to look for a DLL | 206 // If the user presses the Browse button to look for a DLL |
207 std::wstring dll_path = host->OnShowBrowseForDllDlg(dialog); | 207 base::string16 dll_path = host->OnShowBrowseForDllDlg(dialog); |
208 if (dll_path.length() > 0) { | 208 if (dll_path.length() > 0) { |
209 // Initialize the window text for Log File edit box | 209 // Initialize the window text for Log File edit box |
210 HWND edit_box_dll_path = ::GetDlgItem(dialog, IDC_DLL_NAME); | 210 HWND edit_box_dll_path = ::GetDlgItem(dialog, IDC_DLL_NAME); |
211 ::SetWindowText(edit_box_dll_path, dll_path.c_str()); | 211 ::SetWindowText(edit_box_dll_path, dll_path.c_str()); |
212 } | 212 } |
213 return static_cast<INT_PTR>(TRUE); | 213 return static_cast<INT_PTR>(TRUE); |
214 } else if (LOWORD(wparam) == IDC_BROWSE_LOG) { | 214 } else if (LOWORD(wparam) == IDC_BROWSE_LOG) { |
215 // If the user presses the Browse button to look for a log file | 215 // If the user presses the Browse button to look for a log file |
216 std::wstring log_path = host->OnShowBrowseForLogFileDlg(dialog); | 216 base::string16 log_path = host->OnShowBrowseForLogFileDlg(dialog); |
217 if (log_path.length() > 0) { | 217 if (log_path.length() > 0) { |
218 // Initialize the window text for Log File edit box | 218 // Initialize the window text for Log File edit box |
219 HWND edit_box_log_file = ::GetDlgItem(dialog, IDC_LOG_FILE); | 219 HWND edit_box_log_file = ::GetDlgItem(dialog, IDC_LOG_FILE); |
220 ::SetWindowText(edit_box_log_file, log_path.c_str()); | 220 ::SetWindowText(edit_box_log_file, log_path.c_str()); |
221 } | 221 } |
222 return static_cast<INT_PTR>(TRUE); | 222 return static_cast<INT_PTR>(TRUE); |
223 } | 223 } |
224 | 224 |
225 break; | 225 break; |
226 } | 226 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 if (0 >= entry_point_len) { | 348 if (0 >= entry_point_len) { |
349 ::MessageBox(dialog, | 349 ::MessageBox(dialog, |
350 L"Please specify an entry point for the DLL", | 350 L"Please specify an entry point for the DLL", |
351 L"No entry point specified", | 351 L"No entry point specified", |
352 MB_ICONERROR); | 352 MB_ICONERROR); |
353 return false; | 353 return false; |
354 } | 354 } |
355 | 355 |
356 // store these values in the member variables for use in SpawnTarget | 356 // store these values in the member variables for use in SpawnTarget |
357 log_file_ = std::wstring(L"\"") + log_file + std::wstring(L"\""); | 357 log_file_ = base::string16(L"\"") + log_file + base::string16(L"\""); |
358 dll_path_ = dll_path; | 358 dll_path_ = dll_path; |
359 entry_point_ = entry_point; | 359 entry_point_ = entry_point; |
360 | 360 |
361 return true; | 361 return true; |
362 } | 362 } |
363 | 363 |
364 DWORD WINAPI MainUIWindow::ListenPipeThunk(void *param) { | 364 DWORD WINAPI MainUIWindow::ListenPipeThunk(void *param) { |
365 return reinterpret_cast<MainUIWindow*>(param)->ListenPipe(); | 365 return reinterpret_cast<MainUIWindow*>(param)->ListenPipe(); |
366 } | 366 } |
367 | 367 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 ::ResumeThread(target_.hThread); | 568 ::ResumeThread(target_.hThread); |
569 | 569 |
570 AddDebugMessage(L"Successfully spawned target w/args (%ls)", arguments); | 570 AddDebugMessage(L"Successfully spawned target w/args (%ls)", arguments); |
571 return_value = true; | 571 return_value = true; |
572 } | 572 } |
573 | 573 |
574 delete[] arguments; | 574 delete[] arguments; |
575 return return_value; | 575 return return_value; |
576 } | 576 } |
577 | 577 |
578 std::wstring MainUIWindow::OnShowBrowseForDllDlg(HWND owner) { | 578 base::string16 MainUIWindow::OnShowBrowseForDllDlg(HWND owner) { |
579 wchar_t filename[MAX_PATH]; | 579 wchar_t filename[MAX_PATH]; |
580 wcscpy_s(filename, MAX_PATH, L""); | 580 wcscpy_s(filename, MAX_PATH, L""); |
581 | 581 |
582 OPENFILENAMEW file_info = {0}; | 582 OPENFILENAMEW file_info = {0}; |
583 file_info.lStructSize = sizeof(file_info); | 583 file_info.lStructSize = sizeof(file_info); |
584 file_info.hwndOwner = owner; | 584 file_info.hwndOwner = owner; |
585 file_info.lpstrFile = filename; | 585 file_info.lpstrFile = filename; |
586 file_info.nMaxFile = MAX_PATH; | 586 file_info.nMaxFile = MAX_PATH; |
587 file_info.lpstrFilter = L"DLL files (*.dll)\0*.dll\0All files\0*.*\0\0\0"; | 587 file_info.lpstrFilter = L"DLL files (*.dll)\0*.dll\0All files\0*.*\0\0\0"; |
588 | 588 |
589 file_info.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; | 589 file_info.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; |
590 | 590 |
591 if (GetOpenFileName(&file_info)) { | 591 if (GetOpenFileName(&file_info)) { |
592 return file_info.lpstrFile; | 592 return file_info.lpstrFile; |
593 } | 593 } |
594 | 594 |
595 return L""; | 595 return L""; |
596 } | 596 } |
597 | 597 |
598 std::wstring MainUIWindow::OnShowBrowseForLogFileDlg(HWND owner) { | 598 base::string16 MainUIWindow::OnShowBrowseForLogFileDlg(HWND owner) { |
599 wchar_t filename[MAX_PATH]; | 599 wchar_t filename[MAX_PATH]; |
600 wcscpy_s(filename, MAX_PATH, L""); | 600 wcscpy_s(filename, MAX_PATH, L""); |
601 | 601 |
602 OPENFILENAMEW file_info = {0}; | 602 OPENFILENAMEW file_info = {0}; |
603 file_info.lStructSize = sizeof(file_info); | 603 file_info.lStructSize = sizeof(file_info); |
604 file_info.hwndOwner = owner; | 604 file_info.hwndOwner = owner; |
605 file_info.lpstrFile = filename; | 605 file_info.lpstrFile = filename; |
606 file_info.nMaxFile = MAX_PATH; | 606 file_info.nMaxFile = MAX_PATH; |
607 file_info.lpstrFilter = L"Log file (*.txt)\0*.txt\0All files\0*.*\0\0\0"; | 607 file_info.lpstrFilter = L"Log file (*.txt)\0*.txt\0All files\0*.*\0\0\0"; |
608 | 608 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 item.iItem = ListView_GetItemCount(list_view_); | 659 item.iItem = ListView_GetItemCount(list_view_); |
660 item.iSubItem = 0; | 660 item.iSubItem = 0; |
661 item.mask = LVIF_TEXT | LVIF_PARAM; | 661 item.mask = LVIF_TEXT | LVIF_PARAM; |
662 item.pszText = message_time; | 662 item.pszText = message_time; |
663 item.lParam = 0; | 663 item.lParam = 0; |
664 | 664 |
665 ListView_InsertItem(list_view_, &item); | 665 ListView_InsertItem(list_view_, &item); |
666 | 666 |
667 delete[] message_time; | 667 delete[] message_time; |
668 } | 668 } |
OLD | NEW |