| Index: webkit/tools/test_shell/test_shell.cc
|
| diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
|
| index ec8b023d67c7dfe7fef87d05a2359cd1a5a1cf5e..1c52bbe49d5d68aaa666751d10676bedbbeef7a0 100644
|
| --- a/webkit/tools/test_shell/test_shell.cc
|
| +++ b/webkit/tools/test_shell/test_shell.cc
|
| @@ -2,19 +2,17 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include <windows.h>
|
| -#include <atlbase.h>
|
| -#include <commdlg.h>
|
| -#include <objbase.h>
|
| -#include <shlwapi.h>
|
| -#include <wininet.h>
|
| -
|
| #include "webkit/tools/test_shell/test_shell.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include <hash_map>
|
| +#else
|
| +#include <ext/hash_map>
|
| +#endif
|
| +
|
| #include "base/command_line.h"
|
| #include "base/debug_on_start.h"
|
| #include "base/file_util.h"
|
| -#include "base/gfx/bitmap_platform_device_win.h"
|
| #include "base/gfx/png_encoder.h"
|
| #include "base/gfx/size.h"
|
| #include "base/icu_util.h"
|
| @@ -25,11 +23,8 @@
|
| #include "base/stats_table.h"
|
| #include "base/string_util.h"
|
| #include "base/trace_event.h"
|
| -#include "base/win_util.h"
|
| #include "googleurl/src/url_util.h"
|
| #include "net/base/mime_util.h"
|
| -#include "net/url_request/url_request_file_job.h"
|
| -#include "net/url_request/url_request_filter.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "webkit/glue/webdatasource.h"
|
| #include "webkit/glue/webframe.h"
|
| @@ -43,7 +38,18 @@
|
| #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
|
| #include "webkit/tools/test_shell/test_navigation_controller.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include "webkit/tools/test_shell/test_shell_win.h"
|
| +#elif defined(OS_LINUX)
|
| +#include "webkit/tools/test_shell/test_shell_gtk.h"
|
| +#endif
|
| +
|
| +#if defined(OS_WIN)
|
| +// XXX These files don't depend on Windows, they just haven't been ported yet.
|
| +#include "net/url_request/url_request_file_job.h"
|
| +#include "net/url_request/url_request_filter.h"
|
| #include "webkit_strings.h"
|
| +#endif
|
|
|
| #include "SkBitmap.h"
|
|
|
| @@ -55,13 +61,6 @@ using std::max;
|
| #define BUTTON_WIDTH 72
|
| #define URLBAR_HEIGHT 24
|
|
|
| -// Global Variables:
|
| -static TCHAR g_windowTitle[MAX_LOADSTRING]; // The title bar text
|
| -static TCHAR g_windowClass[MAX_LOADSTRING]; // The main window class name
|
| -
|
| -// Forward declarations of functions included in this code module:
|
| -static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
| -
|
| // Default timeout for page load when running non-interactive file
|
| // tests, in ms.
|
| const int kDefaultFileTestTimeoutMillisecs = 10 * 1000;
|
| @@ -85,11 +84,11 @@ const int kTestWindowYLocation = -32000;
|
|
|
| // Initialize static member variable
|
| WindowList* TestShell::window_list_;
|
| -HINSTANCE TestShell::instance_handle_;
|
| WebPreferences* TestShell::web_prefs_ = NULL;
|
| bool TestShell::interactive_ = true;
|
| int TestShell::file_test_timeout_ms_ = kDefaultFileTestTimeoutMillisecs;
|
|
|
| +#if defined(OS_WIN) // XXX
|
| // URLRequestTestShellFileJob is used to serve the inspector
|
| class URLRequestTestShellFileJob : public URLRequestFileJob {
|
| public:
|
| @@ -113,6 +112,7 @@ class URLRequestTestShellFileJob : public URLRequestFileJob {
|
|
|
| DISALLOW_EVIL_CONSTRUCTORS(URLRequestTestShellFileJob);
|
| };
|
| +#endif
|
|
|
| TestShell::TestShell()
|
| : m_mainWnd(NULL),
|
| @@ -120,7 +120,6 @@ TestShell::TestShell()
|
| m_webViewHost(NULL),
|
| m_popupHost(NULL),
|
| m_focusedWidgetHost(NULL),
|
| - default_edit_wnd_proc_(0),
|
| delegate_(new TestWebViewDelegate(this)),
|
| test_is_preparing_(false),
|
| test_is_pending_(false),
|
| @@ -131,9 +130,11 @@ TestShell::TestShell()
|
| text_input_controller_.reset(new TextInputController(this));
|
| navigation_controller_.reset(new TestNavigationController(this));
|
|
|
| +#if defined(OS_WIN) // XXX
|
| URLRequestFilter* filter = URLRequestFilter::GetInstance();
|
| filter->AddHostnameHandler("test-shell-resource", "inspector",
|
| &URLRequestTestShellFileJob::InspectorFactory);
|
| +#endif
|
| url_util::AddStandardScheme("test-shell-resource");
|
| }
|
|
|
| @@ -143,11 +144,6 @@ TestShell::~TestShell() {
|
| CallJSGC();
|
| CallJSGC();
|
|
|
| - // When the window is destroyed, tell the Edit field to forget about us,
|
| - // otherwise we will crash.
|
| - win_util::SetWindowProc(m_editWnd, default_edit_wnd_proc_);
|
| - win_util::SetWindowUserData(m_editWnd, NULL);
|
| -
|
| StatsTable *table = StatsTable::current();
|
| if (dump_stats_table_on_exit_) {
|
| // Dump the stats table.
|
| @@ -173,6 +169,7 @@ static void UnitTestAssertHandler(const std::string& str) {
|
|
|
| // static
|
| void TestShell::InitLogging(bool suppress_error_dialogs) {
|
| +#if defined(OS_WIN)
|
| if (!IsDebuggerPresent() && suppress_error_dialogs) {
|
| UINT new_flags = SEM_FAILCRITICALERRORS |
|
| SEM_NOGPFAULTERRORBOX |
|
| @@ -183,15 +180,23 @@ void TestShell::InitLogging(bool suppress_error_dialogs) {
|
|
|
| logging::SetLogAssertHandler(UnitTestAssertHandler);
|
| }
|
| +#endif // defined(OS_WIN)
|
|
|
| // We might have multiple test_shell processes going at once
|
| std::wstring log_filename;
|
| PathService::Get(base::DIR_EXE, &log_filename);
|
| file_util::AppendToPath(&log_filename, L"test_shell.log");
|
| +#if defined(OS_WIN) // XXX
|
| logging::InitLogging(log_filename.c_str(),
|
| logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
|
| logging::LOCK_LOG_FILE,
|
| logging::DELETE_OLD_LOG_FILE);
|
| +#else
|
| + logging::InitLogging(WideToUTF8(log_filename).c_str(),
|
| + logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
|
| + logging::LOCK_LOG_FILE,
|
| + logging::DELETE_OLD_LOG_FILE);
|
| +#endif
|
|
|
| // we want process and thread IDs because we may have multiple processes
|
| logging::SetLogItems(true, true, false, true);
|
| @@ -204,12 +209,9 @@ void TestShell::CleanupLogging() {
|
|
|
| // static
|
| void TestShell::InitializeTestShell(bool interactive) {
|
| - // Start COM stuff.
|
| - HRESULT res = OleInitialize(NULL);
|
| - DCHECK(SUCCEEDED(res));
|
| + TestShellImpl::InitializeTestShell(interactive);
|
|
|
| window_list_ = new WindowList;
|
| - instance_handle_ = ::GetModuleHandle(NULL);
|
| interactive_ = interactive;
|
|
|
| web_prefs_ = new WebPreferences;
|
| @@ -252,53 +254,12 @@ void TestShell::ShutdownTestShell() {
|
| delete window_list_;
|
| SimpleResourceLoaderBridge::Shutdown();
|
| delete TestShell::web_prefs_;
|
| - OleUninitialize();
|
| + TestShellImpl::ShutdownTestShell();
|
| }
|
|
|
| bool TestShell::Initialize(const std::wstring& startingURL) {
|
| - // Perform application initialization:
|
| - m_mainWnd = CreateWindow(g_windowClass, g_windowTitle,
|
| - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
| - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
|
| - NULL, NULL, instance_handle_, NULL);
|
| - win_util::SetWindowUserData(m_mainWnd, this);
|
| -
|
| - HWND hwnd;
|
| - int x = 0;
|
| -
|
| - hwnd = CreateWindow(L"BUTTON", L"Back",
|
| - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
|
| - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| - m_mainWnd, (HMENU) IDC_NAV_BACK, instance_handle_, 0);
|
| - x += BUTTON_WIDTH;
|
| -
|
| - hwnd = CreateWindow(L"BUTTON", L"Forward",
|
| - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
|
| - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| - m_mainWnd, (HMENU) IDC_NAV_FORWARD, instance_handle_, 0);
|
| - x += BUTTON_WIDTH;
|
| -
|
| - hwnd = CreateWindow(L"BUTTON", L"Reload",
|
| - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
|
| - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| - m_mainWnd, (HMENU) IDC_NAV_RELOAD, instance_handle_, 0);
|
| - x += BUTTON_WIDTH;
|
| -
|
| - hwnd = CreateWindow(L"BUTTON", L"Stop",
|
| - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
|
| - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| - m_mainWnd, (HMENU) IDC_NAV_STOP, instance_handle_, 0);
|
| - x += BUTTON_WIDTH;
|
| -
|
| - // this control is positioned by ResizeSubViews
|
| - m_editWnd = CreateWindow(L"EDIT", 0,
|
| - WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
| - ES_AUTOVSCROLL | ES_AUTOHSCROLL,
|
| - x, 0, 0, 0, m_mainWnd, 0, instance_handle_, 0);
|
| -
|
| - default_edit_wnd_proc_ =
|
| - win_util::SetWindowProc(m_editWnd, TestShell::EditWndProc);
|
| - win_util::SetWindowUserData(m_editWnd, this);
|
| + m_mainWnd = NULL; // XXX
|
| + m_impl->Initialize(startingURL);
|
|
|
| // create webview
|
| m_webViewHost.reset(
|
| @@ -310,8 +271,6 @@ bool TestShell::Initialize(const std::wstring& startingURL) {
|
| if (!startingURL.empty())
|
| LoadURL(startingURL.c_str());
|
|
|
| - ShowWindow(webViewWnd(), SW_SHOW);
|
| -
|
| bool bIsSVGTest = startingURL.find(L"W3C-SVG-1.1") != std::wstring::npos;
|
|
|
| if (bIsSVGTest) {
|
| @@ -327,13 +286,17 @@ void TestShell::TestFinished() {
|
| if (!test_is_pending_)
|
| return; // reached when running under test_shell_tests
|
|
|
| +#if defined(OS_WIN)
|
| + // TODO(port): figure out a better way of doing this.
|
| UINT_PTR timer_id = reinterpret_cast<UINT_PTR>(this);
|
| KillTimer(mainWnd(), timer_id);
|
| +#endif
|
|
|
| test_is_pending_ = false;
|
| MessageLoop::current()->Quit();
|
| }
|
|
|
| +#if defined(OS_WIN) // XXX move to windows-specific file?
|
| // Thread main to run for the thread which just tests for timeout.
|
| unsigned int __stdcall WatchDogThread(void *arg)
|
| {
|
| @@ -391,6 +354,7 @@ void TestShell::WaitTestFinished() {
|
| // Wait to join the watchdog thread. (up to 1s, then quit)
|
| WaitForSingleObject(thread_handle, 1000);
|
| }
|
| +#endif // defined(OS_WIN)
|
|
|
| void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
|
| delegate_->Show(webview, disposition);
|
| @@ -399,10 +363,10 @@ void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
|
| void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
|
| if (interactive_) {
|
| if (enable) {
|
| - ::SetFocus(host->window_handle());
|
| + ; // XXX ::SetFocus(host->window_handle());
|
| } else {
|
| - if (GetFocus() == host->window_handle())
|
| - ::SetFocus(NULL);
|
| + ; // XXX if (GetFocus() == host->window_handle())
|
| + ; // XXX ::SetFocus(NULL);
|
| }
|
| } else {
|
| if (enable) {
|
| @@ -470,13 +434,13 @@ WebView* TestShell::CreateWebView(WebView* webview) {
|
| WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
|
| DCHECK(!m_popupHost);
|
| m_popupHost = WebWidgetHost::Create(NULL, delegate_.get());
|
| - ShowWindow(popupWnd(), SW_SHOW);
|
| + // XXX ShowWindow(popupWnd(), SW_SHOW);
|
|
|
| return m_popupHost->webwidget();
|
| }
|
|
|
| void TestShell::ClosePopup() {
|
| - PostMessage(popupWnd(), WM_CLOSE, 0, 0);
|
| + // XXX PostMessage(popupWnd(), WM_CLOSE, 0, 0);
|
| m_popupHost = NULL;
|
| }
|
|
|
| @@ -485,74 +449,24 @@ void TestShell::SizeToDefault() {
|
| }
|
|
|
| void TestShell::SizeTo(int width, int height) {
|
| - RECT rc, rw;
|
| - GetClientRect(m_mainWnd, &rc);
|
| - GetWindowRect(m_mainWnd, &rw);
|
| -
|
| - int client_width = rc.right - rc.left;
|
| - int window_width = rw.right - rw.left;
|
| - window_width = (window_width - client_width) + width;
|
| -
|
| - int client_height = rc.bottom - rc.top;
|
| - int window_height = rw.bottom - rw.top;
|
| - window_height = (window_height - client_height) + height;
|
| -
|
| - // add space for the url bar:
|
| - window_height += URLBAR_HEIGHT;
|
| -
|
| - SetWindowPos(m_mainWnd, NULL, 0, 0, window_width, window_height,
|
| - SWP_NOMOVE | SWP_NOZORDER);
|
| + m_impl->SizeTo(m_mainWnd, width, height);
|
| }
|
|
|
| void TestShell::ResizeSubViews() {
|
| - RECT rc;
|
| - GetClientRect(m_mainWnd, &rc);
|
| -
|
| - int x = BUTTON_WIDTH * 4;
|
| - MoveWindow(m_editWnd, x, 0, rc.right - x, URLBAR_HEIGHT, TRUE);
|
| -
|
| - MoveWindow(webViewWnd(), 0, URLBAR_HEIGHT, rc.right,
|
| - rc.bottom - URLBAR_HEIGHT, TRUE);
|
| + m_impl->ResizeSubViews();
|
| }
|
|
|
| /* static */ std::string TestShell::DumpImage(
|
| WebFrame* web_frame,
|
| const std::wstring& file_name) {
|
| - gfx::BitmapPlatformDeviceWin device(web_frame->CaptureImage(true));
|
| - const SkBitmap& src_bmp = device.accessBitmap(false);
|
| -
|
| - // Encode image.
|
| - std::vector<unsigned char> png;
|
| - SkAutoLockPixels src_bmp_lock(src_bmp);
|
| - PNGEncoder::Encode(
|
| - reinterpret_cast<const unsigned char*>(src_bmp.getPixels()),
|
| - PNGEncoder::FORMAT_BGRA, src_bmp.width(), src_bmp.height(),
|
| - static_cast<int>(src_bmp.rowBytes()), true, &png);
|
| -
|
| - // Write to disk.
|
| - FILE* file = NULL;
|
| - if (_wfopen_s(&file, file_name.c_str(), L"wb") == 0) {
|
| - fwrite(&png[0], 1, png.size(), file);
|
| - fclose(file);
|
| - }
|
| -
|
| - // Compute MD5 sum.
|
| - MD5Context ctx;
|
| - MD5Init(&ctx);
|
| - MD5Update(&ctx, src_bmp.getPixels(), src_bmp.getSize());
|
| -
|
| - MD5Digest digest;
|
| - MD5Final(&digest, &ctx);
|
| - return MD5DigestToBase16(digest);
|
| + return TestShellImpl::DumpImage(web_frame, file_name);
|
| }
|
|
|
| /* static */ void TestShell::DumpBackForwardList(std::wstring* result) {
|
| result->clear();
|
| for (WindowList::iterator iter = TestShell::windowList()->begin();
|
| iter != TestShell::windowList()->end(); iter++) {
|
| - HWND hwnd = *iter;
|
| - TestShell* shell =
|
| - static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
|
| + TestShell* shell = TestShellImpl::GetTestShellFromWindow(*iter);
|
| webkit_glue::DumpBackForwardList(shell->webView(), NULL, result);
|
| }
|
| }
|
| @@ -565,15 +479,14 @@ void TestShell::ResizeSubViews() {
|
| return false;
|
| }
|
|
|
| - HWND hwnd = *(TestShell::windowList()->begin());
|
| TestShell* shell =
|
| - static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
|
| + TestShellImpl::GetTestShellFromWindow(
|
| + *(TestShell::windowList()->begin()));
|
| shell->ResetTestController();
|
|
|
| // ResetTestController may have closed the window we were holding on to.
|
| // Grab the first window again.
|
| - hwnd = *(TestShell::windowList()->begin());
|
| - shell = static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
|
| + shell = TestShellImpl::GetTestShellFromWindow(*(TestShell::windowList()->begin()));
|
| DCHECK(shell);
|
|
|
| // Clear focus between tests.
|
| @@ -588,9 +501,10 @@ void TestShell::ResizeSubViews() {
|
| ResetWebPreferences();
|
| shell->webView()->SetPreferences(*web_prefs_);
|
|
|
| - SetWindowPos(shell->m_mainWnd, NULL,
|
| + // XXX
|
| + /*SetWindowPos(shell->m_mainWnd, NULL,
|
| kTestWindowXLocation, kTestWindowYLocation, 0, 0,
|
| - SWP_NOSIZE | SWP_NOZORDER);
|
| + SWP_NOSIZE | SWP_NOZORDER);*/
|
| shell->ResizeSubViews();
|
|
|
| if (strstr(filename, "loading/") || strstr(filename, "loading\\"))
|
| @@ -662,151 +576,6 @@ void TestShell::ResizeSubViews() {
|
| return true;
|
| }
|
|
|
| -
|
| -/* static */
|
| -ATOM TestShell::RegisterWindowClass()
|
| -{
|
| - LoadString(instance_handle_, IDS_APP_TITLE, g_windowTitle, MAX_LOADSTRING);
|
| - LoadString(instance_handle_, IDC_TESTSHELL, g_windowClass, MAX_LOADSTRING);
|
| -
|
| - WNDCLASSEX wcex = {
|
| - /* cbSize = */ sizeof(WNDCLASSEX),
|
| - /* style = */ CS_HREDRAW | CS_VREDRAW,
|
| - /* lpfnWndProc = */ TestShell::WndProc,
|
| - /* cbClsExtra = */ 0,
|
| - /* cbWndExtra = */ 0,
|
| - /* hInstance = */ instance_handle_,
|
| - /* hIcon = */ LoadIcon(instance_handle_, MAKEINTRESOURCE(IDI_TESTSHELL)),
|
| - /* hCursor = */ LoadCursor(NULL, IDC_ARROW),
|
| - /* hbrBackground = */ 0,
|
| - /* lpszMenuName = */ MAKEINTRESOURCE(IDC_TESTSHELL),
|
| - /* lpszClassName = */ g_windowClass,
|
| - /* hIconSm = */ LoadIcon(instance_handle_, MAKEINTRESOURCE(IDI_SMALL)),
|
| - };
|
| - return RegisterClassEx(&wcex);
|
| -}
|
| -
|
| -LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
| -{
|
| - TestShell* shell = static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
|
| -
|
| - switch (message) {
|
| - case WM_COMMAND:
|
| - {
|
| - int wmId = LOWORD(wParam);
|
| - int wmEvent = HIWORD(wParam);
|
| -
|
| - switch (wmId) {
|
| - case IDM_ABOUT:
|
| - DialogBox(shell->instance_handle_, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd,
|
| - About);
|
| - break;
|
| - case IDM_EXIT:
|
| - DestroyWindow(hwnd);
|
| - break;
|
| - case IDC_NAV_BACK:
|
| - shell->GoBackOrForward(-1);
|
| - break;
|
| - case IDC_NAV_FORWARD:
|
| - shell->GoBackOrForward(1);
|
| - break;
|
| - case IDC_NAV_RELOAD:
|
| - case IDC_NAV_STOP:
|
| - {
|
| - if (wmId == IDC_NAV_RELOAD) {
|
| - shell->Reload();
|
| - } else {
|
| - shell->webView()->StopLoading();
|
| - }
|
| - }
|
| - break;
|
| - case IDM_DUMP_BODY_TEXT:
|
| - shell->DumpDocumentText();
|
| - break;
|
| - case IDM_DUMP_RENDER_TREE:
|
| - shell->DumpRenderTree();
|
| - break;
|
| - case IDM_SHOW_WEB_INSPECTOR:
|
| - shell->webView()->InspectElement(0, 0);
|
| - break;
|
| - }
|
| - }
|
| - break;
|
| -
|
| - case WM_DESTROY:
|
| - {
|
| - // Dump all in use memory just before shutdown if in use memory
|
| - // debugging has been enabled.
|
| - base::MemoryDebug::DumpAllMemoryInUse();
|
| -
|
| - WindowList::iterator entry =
|
| - std::find(TestShell::windowList()->begin(),
|
| - TestShell::windowList()->end(), hwnd);
|
| - if (entry != TestShell::windowList()->end())
|
| - TestShell::windowList()->erase(entry);
|
| -
|
| - if (TestShell::windowList()->empty() || shell->is_modal()) {
|
| - MessageLoop::current()->PostTask(
|
| - FROM_HERE, new MessageLoop::QuitTask());
|
| - }
|
| - delete shell;
|
| - }
|
| - return 0;
|
| -
|
| - case WM_SIZE:
|
| - if (shell->webView())
|
| - shell->ResizeSubViews();
|
| - return 0;
|
| - }
|
| -
|
| - return DefWindowProc(hwnd, message, wParam, lParam);
|
| -}
|
| -
|
| -
|
| -#define MAX_URL_LENGTH 1024
|
| -
|
| -LRESULT CALLBACK TestShell::EditWndProc(HWND hwnd, UINT message,
|
| - WPARAM wParam, LPARAM lParam)
|
| -{
|
| - TestShell* shell =
|
| - static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
|
| -
|
| - switch (message) {
|
| - case WM_CHAR:
|
| - if (wParam == 13) { // Enter Key
|
| - wchar_t strPtr[MAX_URL_LENGTH];
|
| - *((LPWORD)strPtr) = MAX_URL_LENGTH;
|
| - LRESULT strLen = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
| - if (strLen > 0)
|
| - shell->LoadURL(strPtr);
|
| -
|
| - return 0;
|
| - }
|
| - }
|
| -
|
| - return (LRESULT) CallWindowProc(shell->default_edit_wnd_proc_, hwnd,
|
| - 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;
|
| -}
|
| -
|
| void TestShell::LoadURL(const wchar_t* url)
|
| {
|
| LoadURLForFrame(url, NULL);
|
| @@ -827,19 +596,22 @@ void TestShell::LoadURLForFrame(const wchar_t* url,
|
| }
|
|
|
| std::wstring urlString(url);
|
| + // XXX
|
| + /*
|
| if (!urlString.empty() && (PathFileExists(url) || PathIsUNC(url))) {
|
| TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
|
| DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
|
| if (SUCCEEDED(UrlCreateFromPath(url, fileURL, &fileURLLength, 0)))
|
| urlString.assign(fileURL);
|
| }
|
| + */
|
|
|
| std::wstring frame_string;
|
| if (frame_name)
|
| frame_string = frame_name;
|
|
|
| navigation_controller_->LoadEntry(new TestNavigationEntry(
|
| - -1, GURL(urlString), std::wstring(), frame_string));
|
| + -1, GURL(WideToUTF8(urlString)), std::wstring(), frame_string));
|
| }
|
|
|
| bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) {
|
| @@ -891,26 +663,14 @@ void TestShell::GoBackOrForward(int offset) {
|
| bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
|
| std::wstring* result)
|
| {
|
| - wchar_t path_buf[MAX_PATH] = L"data.txt";
|
| -
|
| - OPENFILENAME info = {0};
|
| - info.lStructSize = sizeof(info);
|
| - info.hwndOwner = m_mainWnd;
|
| - info.hInstance = instance_handle_;
|
| - info.lpstrFilter = L"*.txt";
|
| - info.lpstrFile = path_buf;
|
| - info.nMaxFile = arraysize(path_buf);
|
| - info.lpstrTitle = prompt_title;
|
| - if (!GetSaveFileName(&info))
|
| - return false;
|
| -
|
| - result->assign(info.lpstrFile);
|
| - return true;
|
| + return m_impl->PromptForSaveFile(prompt_title, result);
|
| }
|
|
|
| static void WriteTextToFile(const std::wstring& data,
|
| const std::wstring& file_path)
|
| {
|
| + // XXX
|
| + /*
|
| FILE* fp;
|
| errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt");
|
| if (err)
|
| @@ -918,11 +678,15 @@ static void WriteTextToFile(const std::wstring& data,
|
| std::string data_utf8 = WideToUTF8(data);
|
| fwrite(data_utf8.c_str(), 1, data_utf8.size(), fp);
|
| fclose(fp);
|
| + */
|
| }
|
|
|
| std::wstring TestShell::GetDocumentText()
|
| {
|
| + /* XXX
|
| return webkit_glue::DumpDocumentText(webView()->GetMainFrame());
|
| + */
|
| + return L"";
|
| }
|
|
|
| void TestShell::DumpDocumentText()
|
| @@ -931,8 +695,10 @@ void TestShell::DumpDocumentText()
|
| if (!PromptForSaveFile(L"Dump document text", &file_path))
|
| return;
|
|
|
| + /* XXX
|
| WriteTextToFile(webkit_glue::DumpDocumentText(webView()->GetMainFrame()),
|
| file_path);
|
| + */
|
| }
|
|
|
| void TestShell::DumpRenderTree()
|
| @@ -941,12 +707,14 @@ void TestShell::DumpRenderTree()
|
| if (!PromptForSaveFile(L"Dump render tree", &file_path))
|
| return;
|
|
|
| + /* XXX
|
| WriteTextToFile(webkit_glue::DumpRenderer(webView()->GetMainFrame()),
|
| file_path);
|
| + */
|
| }
|
|
|
| void TestShell::Reload() {
|
| - navigation_controller_->Reload();
|
| + // XXX navigation_controller_->Reload();
|
| }
|
|
|
| /* static */
|
| @@ -991,32 +759,32 @@ void AppendToLog(const char* file, int line, const char* msg) {
|
| }
|
|
|
| bool GetMimeTypeFromExtension(std::wstring &ext, std::string *mime_type) {
|
| +#if defined(OS_WIN)
|
| return net::GetMimeTypeFromExtension(ext, mime_type);
|
| +#else
|
| + NOTIMPLEMENTED();
|
| + return false;
|
| +#endif
|
| }
|
|
|
| bool GetMimeTypeFromFile(const std::wstring &file_path,
|
| std::string *mime_type) {
|
| +#if defined(OS_WIN)
|
| return net::GetMimeTypeFromFile(file_path, mime_type);
|
| +#else
|
| + NOTIMPLEMENTED();
|
| + return false;
|
| +#endif
|
| }
|
|
|
| bool GetPreferredExtensionForMimeType(const std::string& mime_type,
|
| std::wstring* ext) {
|
| +#if defined(OS_WIN)
|
| return net::GetPreferredExtensionForMimeType(mime_type, ext);
|
| -}
|
| -
|
| -IMLangFontLink2* GetLangFontLink() {
|
| - return webkit_glue::GetLangFontLinkHelper();
|
| -}
|
| -
|
| -std::wstring GetLocalizedString(int message_id) {
|
| - const ATLSTRINGRESOURCEIMAGE* image =
|
| - AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
|
| - message_id);
|
| - if (!image) {
|
| - NOTREACHED();
|
| - return L"No string for this identifier!";
|
| - }
|
| - return std::wstring(image->achString, image->nLength);
|
| +#else
|
| + NOTIMPLEMENTED();
|
| + return false;
|
| +#endif
|
| }
|
|
|
| std::string GetDataResource(int resource_id) {
|
| @@ -1048,10 +816,6 @@ std::string GetDataResource(int resource_id) {
|
| }
|
| }
|
|
|
| -HCURSOR LoadCursor(int cursor_id) {
|
| - return NULL;
|
| -}
|
| -
|
| bool GetApplicationDirectory(std::wstring *path) {
|
| return PathService::Get(base::DIR_EXE, path);
|
| }
|
| @@ -1077,25 +841,18 @@ bool SpellCheckWord(const wchar_t* word, int word_len,
|
| }
|
|
|
| bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
|
| +#if defined(OS_WIN)
|
| return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins);
|
| +#else
|
| + NOTIMPLEMENTED();
|
| + return false;
|
| +#endif
|
| }
|
|
|
| -bool webkit_glue::IsPluginRunningInRendererProcess() {
|
| - return true;
|
| -}
|
| -
|
| -bool EnsureFontLoaded(HFONT font) {
|
| +bool IsPluginRunningInRendererProcess() {
|
| return true;
|
| }
|
|
|
| -MONITORINFOEX GetMonitorInfoForWindow(HWND window) {
|
| - return webkit_glue::GetMonitorInfoForWindowHelper(window);
|
| -}
|
| -
|
| -bool DownloadUrl(const std::string& url, HWND caller_window) {
|
| - return false;
|
| -}
|
| -
|
| bool GetPluginFinderURL(std::string* plugin_finder_url) {
|
| return false;
|
| }
|
| @@ -1109,4 +866,3 @@ std::wstring GetWebKitLocale() {
|
| }
|
|
|
| } // namespace webkit_glue
|
| -
|
|
|