| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <atlbase.h> | 6 #include <atlbase.h> |
| 7 #include <commdlg.h> | 7 #include <commdlg.h> |
| 8 #include <objbase.h> | 8 #include <objbase.h> |
| 9 #include <shlwapi.h> | 9 #include <shlwapi.h> |
| 10 #include <wininet.h> | 10 #include <wininet.h> |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 info.lpstrFile = path_buf; | 696 info.lpstrFile = path_buf; |
| 697 info.nMaxFile = arraysize(path_buf); | 697 info.nMaxFile = arraysize(path_buf); |
| 698 info.lpstrTitle = prompt_title; | 698 info.lpstrTitle = prompt_title; |
| 699 if (!GetSaveFileName(&info)) | 699 if (!GetSaveFileName(&info)) |
| 700 return false; | 700 return false; |
| 701 | 701 |
| 702 result->assign(info.lpstrFile); | 702 result->assign(info.lpstrFile); |
| 703 return true; | 703 return true; |
| 704 } | 704 } |
| 705 | 705 |
| 706 // TODO(tc): Use methods in base or net/base for this. | |
| 707 static void WriteTextToFile(const std::wstring& data, | |
| 708 const std::wstring& file_path) { | |
| 709 FILE* fp; | |
| 710 errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt"); | |
| 711 if (err) | |
| 712 return; | |
| 713 std::string data_utf8 = WideToUTF8(data); | |
| 714 fwrite(data_utf8.c_str(), 1, data_utf8.size(), fp); | |
| 715 fclose(fp); | |
| 716 } | |
| 717 | |
| 718 void TestShell::DumpDocumentText() { | |
| 719 std::wstring file_path; | |
| 720 if (!PromptForSaveFile(L"Dump document text", &file_path)) | |
| 721 return; | |
| 722 | |
| 723 WriteTextToFile(webkit_glue::DumpDocumentText(webView()->GetMainFrame()), | |
| 724 file_path); | |
| 725 } | |
| 726 | |
| 727 void TestShell::DumpRenderTree() { | |
| 728 std::wstring file_path; | |
| 729 if (!PromptForSaveFile(L"Dump render tree", &file_path)) | |
| 730 return; | |
| 731 | |
| 732 WriteTextToFile(webkit_glue::DumpRenderer(webView()->GetMainFrame()), | |
| 733 file_path); | |
| 734 } | |
| 735 | |
| 736 // static | 706 // static |
| 737 void TestShell::ShowStartupDebuggingDialog() { | 707 void TestShell::ShowStartupDebuggingDialog() { |
| 738 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); | 708 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); |
| 739 } | 709 } |
| 740 | 710 |
| 741 ///////////////////////////////////////////////////////////////////////////// | 711 ///////////////////////////////////////////////////////////////////////////// |
| 742 // WebKit glue functions | 712 // WebKit glue functions |
| 743 | 713 |
| 744 namespace webkit_glue { | 714 namespace webkit_glue { |
| 745 | 715 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 764 | 734 |
| 765 bool EnsureFontLoaded(HFONT font) { | 735 bool EnsureFontLoaded(HFONT font) { |
| 766 return true; | 736 return true; |
| 767 } | 737 } |
| 768 | 738 |
| 769 bool DownloadUrl(const std::string& url, HWND caller_window) { | 739 bool DownloadUrl(const std::string& url, HWND caller_window) { |
| 770 return false; | 740 return false; |
| 771 } | 741 } |
| 772 | 742 |
| 773 } // namespace webkit_glue | 743 } // namespace webkit_glue |
| OLD | NEW |