Rolling out r170340 and r170339.
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 05:45:54 +0000 (05:45 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 05:45:54 +0000 (05:45 +0000)
Changeset r170339 broke the Apple Windows Debug and Release builds.

Reverted changesets:

"[Win] Build fix after r134209"
http://trac.webkit.org/changeset/170340

"[Win] Clean up and refactor WinLauncher"
https://bugs.webkit.org/show_bug.cgi?id=134209
http://trac.webkit.org/changeset/170339

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170346 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Tools/ChangeLog
Tools/WinLauncher/Common.cpp [deleted file]
Tools/WinLauncher/DOMDefaultImpl.cpp [deleted file]
Tools/WinLauncher/DOMDefaultImpl.h
Tools/WinLauncher/WinLauncher.cpp
Tools/WinLauncher/WinLauncher.h [new file with mode: 0644]
Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj
Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters
Tools/WinLauncher/WinLauncherReplace.h
Tools/WinLauncher/WinLauncherWebHost.cpp [deleted file]
Tools/WinLauncher/WinLauncherWebHost.h [deleted file]
Tools/WinLauncher/WinMain.cpp [deleted file]

index 06045ea..84fefe2 100644 (file)
@@ -1,3 +1,18 @@
+2014-06-23  Daniel Bates  <dabates@apple.com>
+
+        Rolling out r170340 and r170339.
+
+        Changeset r170339 broke the Apple Windows Debug and Release builds.
+
+        Reverted changesets:
+
+        "[Win] Build fix after r134209"
+        http://trac.webkit.org/changeset/170340
+
+        "[Win] Clean up and refactor WinLauncher"
+        https://bugs.webkit.org/show_bug.cgi?id=134209
+        http://trac.webkit.org/changeset/170339
+
 2014-06-23  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Build fix after r134209
diff --git a/Tools/WinLauncher/Common.cpp b/Tools/WinLauncher/Common.cpp
deleted file mode 100644 (file)
index 98571a2..0000000
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Copyright (C) 2006, 2008, 2013, 2014 Apple Inc.  All rights reserved.
- * Copyright (C) 2009, 2011 Brent Fulgham.  All rights reserved.
- * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
- * Copyright (C) 2013 Alex Christensen. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "AccessibilityDelegate.h"
-#include "DOMDefaultImpl.h"
-#include "PrintWebUIDelegate.h"
-#include "WinLauncher.h"
-#include "WinLauncherReplace.h"
-#include <WebKit/WebKitCOMAPI.h>
-#include <wtf/ExportMacros.h>
-#include <wtf/Platform.h>
-
-#if USE(CF)
-#include <CoreFoundation/CFRunLoop.h>
-#endif
-
-#include <cassert>
-#include <comip.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#include <comutil.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>
-
-#define MAX_LOADSTRING 100
-#define URLBAR_HEIGHT  24
-#define CONTROLBUTTON_WIDTH 24
-
-static const int maxHistorySize = 10;
-
-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
-typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
-typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr;
-
-// Global Variables:
-HINSTANCE hInst;
-HWND hMainWnd;
-HWND hURLBarWnd;
-HWND hBackButtonWnd;
-HWND hForwardButtonWnd;
-WNDPROC DefEditProc = nullptr;
-WNDPROC DefButtonProc = nullptr;
-WNDPROC DefWebKitProc = nullptr;
-HWND gViewWindow = 0;
-WinLauncher* gWinLauncher = nullptr;
-TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
-TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
-
-// Support moving the transparent window
-POINT s_windowPosition = { 100, 100 };
-SIZE s_windowSize = { 800, 400 };
-
-// Forward declarations of functions included in this code module:
-ATOM MyRegisterClass(HINSTANCE hInstance);
-LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
-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);
-
-static void loadURL(BSTR urlBStr);
-
-static void resizeSubViews()
-{
-    if (gWinLauncher->usesLayeredWebView() || !gViewWindow)
-        return;
-
-    RECT rcClient;
-    GetClientRect(hMainWnd, &rcClient);
-    MoveWindow(hBackButtonWnd, 0, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
-    MoveWindow(hForwardButtonWnd, CONTROLBUTTON_WIDTH, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
-    MoveWindow(hURLBarWnd, CONTROLBUTTON_WIDTH * 2, 0, rcClient.right, URLBAR_HEIGHT, TRUE);
-    MoveWindow(gViewWindow, 0, URLBAR_HEIGHT, rcClient.right, rcClient.bottom - URLBAR_HEIGHT, TRUE);
-}
-
-static void subclassForLayeredWindow()
-{
-    hMainWnd = gViewWindow;
-#if defined _M_AMD64 || defined _WIN64
-    DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hMainWnd, GWLP_WNDPROC));
-    ::SetWindowLongPtr(hMainWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc));
-#else
-    DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(hMainWnd, GWL_WNDPROC));
-    ::SetWindowLong(hMainWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc));
-#endif
-}
-
-static void computeFullDesktopFrame()
-{
-    RECT desktop;
-    if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0))
-        return;
-
-    s_windowPosition.x = 0;
-    s_windowPosition.y = 0;
-    s_windowSize.cx = desktop.right - desktop.left;
-    s_windowSize.cy = desktop.bottom - desktop.top;
-}
-
-BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, LPVOID)
-{
-    if (reason == DLL_PROCESS_ATTACH)
-        hInst = dllInstance;
-
-    return TRUE;
-}
-
-static bool getAppDataFolder(_bstr_t& directory)
-{
-    wchar_t appDataDirectory[MAX_PATH];
-    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
-        return false;
-
-    wchar_t executablePath[MAX_PATH];
-    ::GetModuleFileNameW(0, executablePath, MAX_PATH);
-    ::PathRemoveExtensionW(executablePath);
-
-    directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
-
-    return true;
-}
-
-static bool setCacheFolder()
-{
-    IWebCachePtr webCache;
-
-    HRESULT hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(webCache), reinterpret_cast<void**>(&webCache.GetInterfacePtr()));
-    if (FAILED(hr))
-        return false;
-
-    _bstr_t appDataFolder;
-    if (!getAppDataFolder(appDataFolder))
-        return false;
-
-    appDataFolder += L"\\cache";
-    webCache->setCacheFolder(appDataFolder);
-
-    return true;
-}
-
-void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
-{
-    _bstr_t directory;
-
-    if (!getAppDataFolder(directory))
-        return;
-
-    if (::SHCreateDirectoryEx(0, directory, 0) != ERROR_SUCCESS
-        && ::GetLastError() != ERROR_FILE_EXISTS
-        && ::GetLastError() != ERROR_ALREADY_EXISTS)
-        return;
-
-    std::wstring fileName = directory + L"\\CrashReport.dmp";
-    HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-
-    if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
-
-        MINIDUMP_EXCEPTION_INFORMATION mdei;
-        mdei.ThreadId = ::GetCurrentThreadId();
-        mdei.ExceptionPointers  = exceptionPointers;
-        mdei.ClientPointers = 0;
-
-#ifdef _DEBUG
-        MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
-#else
-        MINIDUMP_TYPE dumpType = MiniDumpNormal;
-#endif
-
-        ::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
-        ::CloseHandle(miniDumpFile);
-        processCrashReport(fileName.c_str());
-    }
-}
-
-static BOOL CALLBACK AbortProc(HDC hDC, int Error)
-{
-    MSG msg;
-    while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
-        ::TranslateMessage(&msg);
-        ::DispatchMessage(&msg);
-    }
-
-    return TRUE;
-}
-
-static HDC getPrinterDC()
-{
-    PRINTDLG pdlg;
-    memset(&pdlg, 0, sizeof(PRINTDLG));
-    pdlg.lStructSize = sizeof(PRINTDLG);
-    pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC;
-
-    ::PrintDlg(&pdlg);
-
-    return pdlg.hDC;
-}
-
-static void initDocStruct(DOCINFO* di, TCHAR* docname)
-{
-    memset(di, 0, sizeof(DOCINFO));
-    di->cbSize = sizeof(DOCINFO);
-    di->lpszDocName = docname;
-}
-
-typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
-
-void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-    HDC printDC = getPrinterDC();
-    if (!printDC) {
-        ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK);
-        return;
-    }
-
-    if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) {
-        ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK);
-        return;
-    }
-
-    IWebFramePtr frame = gWinLauncher->mainFrame();
-    if (!frame)
-        return;
-
-    IWebFramePrivatePtr framePrivate;
-    if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr())))
-        return;
-
-    framePrivate->setInPrintingMode(TRUE, printDC);
-
-    UINT pageCount = 0;
-    framePrivate->getPrintedPageCount(printDC, &pageCount);
-
-    DOCINFO di;
-    initDocStruct(&di, L"WebKit Doc");
-    ::StartDoc(printDC, &di);
-
-    // FIXME: Need CoreGraphics implementation
-    void* graphicsContext = 0;
-    for (size_t page = 1; page <= pageCount; ++page) {
-        ::StartPage(printDC);
-        framePrivate->spoolPages(printDC, page, page, graphicsContext);
-        ::EndPage(printDC);
-    }
-
-    framePrivate->setInPrintingMode(FALSE, printDC);
-
-    ::EndDoc(printDC);
-    ::DeleteDC(printDC);
-}
-
-static void ToggleMenuItem(HWND hWnd, UINT menuID)
-{
-    HMENU menu = ::GetMenu(hWnd);
-
-    MENUITEMINFO info;
-    ::memset(&info, 0x00, sizeof(info));
-    info.cbSize = sizeof(info);
-    info.fMask = MIIM_STATE;
-
-    if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))
-        return;
-
-    BOOL newState = !(info.fState & MFS_CHECKED);
-
-    if (!gWinLauncher->standardPreferences() || !gWinLauncher->privatePreferences())
-        return;
-
-    switch (menuID) {
-    case IDM_AVFOUNDATION:
-        gWinLauncher->standardPreferences()->setAVFoundationEnabled(newState);
-        break;
-    case IDM_ACC_COMPOSITING:
-        gWinLauncher->privatePreferences()->setAcceleratedCompositingEnabled(newState);
-        break;
-    case IDM_WK_FULLSCREEN:
-        gWinLauncher->privatePreferences()->setFullScreenEnabled(newState);
-        break;
-    case IDM_COMPOSITING_BORDERS:
-        gWinLauncher->privatePreferences()->setShowDebugBorders(newState);
-        gWinLauncher->privatePreferences()->setShowRepaintCounter(newState);
-        break;
-    case IDM_DISABLE_IMAGES:
-        gWinLauncher->standardPreferences()->setLoadsImagesAutomatically(!newState);
-        break;
-    case IDM_DISABLE_STYLES:
-        gWinLauncher->privatePreferences()->setAuthorAndUserStylesEnabled(!newState);
-        break;
-    case IDM_DISABLE_JAVASCRIPT:
-        gWinLauncher->standardPreferences()->setJavaScriptEnabled(!newState);
-        break;
-    case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
-        gWinLauncher->privatePreferences()->setAllowUniversalAccessFromFileURLs(newState);
-        gWinLauncher->privatePreferences()->setAllowFileAccessFromFileURLs(newState);
-        break;
-    }
-
-    info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
-
-    ::SetMenuItemInfo(menu, menuID, FALSE, &info);
-}
-
-static const int dragBarHeight = 30;
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-    WNDPROC parentProc = (gWinLauncher) ? (gWinLauncher->usesLayeredWebView() ? DefWebKitProc : DefWindowProc) : DefWindowProc;
-
-    switch (message) {
-    case WM_NCHITTEST:
-        if (gWinLauncher && gWinLauncher->usesLayeredWebView()) {
-            RECT window;
-            ::GetWindowRect(hWnd, &window);
-            // For testing our transparent window, we need a region to use as a handle for
-            // dragging. The right way to do this would be to query the web view to see what's
-            // under the mouse. However, for testing purposes we just use an arbitrary
-            // 30 pixel band at the top of the view as an arbitrary gripping location.
-            //
-            // When we are within this bad, return HT_CAPTION to tell Windows we want to
-            // treat this region as if it were the title bar on a normal window.
-            int y = HIWORD(lParam);
-
-            if ((y > window.top) && (y < window.top + dragBarHeight))
-                return HTCAPTION;
-        }
-        return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
-    case WM_COMMAND: {
-        int wmId = LOWORD(wParam);
-        int wmEvent = HIWORD(wParam);
-        if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) {
-            if (gWinLauncher)
-                gWinLauncher->navigateToHistory(hWnd, wmId);
-            break;
-        }
-        // Parse the menu selections:
-        switch (wmId) {
-        case IDM_ABOUT:
-            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
-            break;
-        case IDM_EXIT:
-            DestroyWindow(hWnd);
-            break;
-        case IDM_PRINT:
-            PrintView(hWnd, message, wParam, lParam);
-            break;
-        case IDM_WEB_INSPECTOR:
-            if (gWinLauncher)
-                gWinLauncher->launchInspector();
-            break;
-        case IDM_HISTORY_BACKWARD:
-        case IDM_HISTORY_FORWARD:
-            if (gWinLauncher)
-                gWinLauncher->navigateForwardOrBackward(hWnd, wmId);
-            break;
-        case IDM_AVFOUNDATION:
-        case IDM_ACC_COMPOSITING:
-        case IDM_WK_FULLSCREEN:
-        case IDM_COMPOSITING_BORDERS:
-        case IDM_DISABLE_IMAGES:
-        case IDM_DISABLE_STYLES:
-        case IDM_DISABLE_JAVASCRIPT:
-        case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
-            ToggleMenuItem(hWnd, wmId);
-            break;
-        default:
-            return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
-        }
-        }
-        break;
-    case WM_DESTROY:
-#if USE(CF)
-        CFRunLoopStop(CFRunLoopGetMain());
-#endif
-        PostQuitMessage(0);
-        break;
-    case WM_SIZE:
-        if (!gWinLauncher || !gWinLauncher->hasWebView() || gWinLauncher->usesLayeredWebView())
-            return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
-
-        resizeSubViews();
-        break;
-    default:
-        return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
-    }
-
-    return 0;
-}
-
-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:
-        gWinLauncher->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:
-        gWinLauncher->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;
-}
-
-static void loadURL(BSTR passedURL)
-{
-    if (FAILED(gWinLauncher->loadURL(passedURL)))
-        return;
-
-    SetFocus(gViewWindow);
-}
-
-extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
-{
-    return wWinMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
-}
diff --git a/Tools/WinLauncher/DOMDefaultImpl.cpp b/Tools/WinLauncher/DOMDefaultImpl.cpp
deleted file mode 100644 (file)
index 31e1cee..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All Rights Reserved.
- * Copyright (C) 2011 Anthony Johnson. All Rights Reserved.
- * Copyright (C) 2011 Brent Fulgham. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "stdafx.h"
-#include "DOMDefaultImpl.h"
-
-// IUnknown -------------------------------------------------------------------
-HRESULT WebScriptObject::QueryInterface(REFIID riid, void** ppvObject)
-{
-    *ppvObject = 0;
-    if (IsEqualGUID(riid, IID_IUnknown))
-        *ppvObject = static_cast<IWebScriptObject*>(this);
-    else if (IsEqualGUID(riid, IID_IWebScriptObject))
-        *ppvObject = static_cast<IWebScriptObject*>(this);
-    else
-        return E_NOINTERFACE;
-
-    AddRef();
-    return S_OK;
-}
-
-ULONG WebScriptObject::AddRef(void)
-{
-    return ++m_refCount;
-}
-
-ULONG WebScriptObject::Release(void)
-{
-    ULONG newRef = --m_refCount;
-    if (!newRef)
-        delete(this);
-
-    return newRef;
-}
-
-// DOMObject -------------------------------------------------------------------
-HRESULT DOMObject::QueryInterface(REFIID riid, void** ppvObject)
-{
-    *ppvObject = 0;
-    if (IsEqualGUID(riid, IID_IDOMObject))
-        *ppvObject = static_cast<IDOMObject*>(this);
-    else
-        return WebScriptObject::QueryInterface(riid, ppvObject);
-
-    WebScriptObject::AddRef();
-    return S_OK;
-}
-
-
-// DOMEventListener -------------------------------------------------------------------
-HRESULT DOMEventListener::QueryInterface(const IID &riid, void** ppvObject)
-{
-    *ppvObject = 0;
-    if (IsEqualGUID(riid, IID_IDOMEventListener))
-        *ppvObject = static_cast<IDOMEventListener*>(this);
-    else
-        return DOMObject::QueryInterface(riid, ppvObject);
-
-    AddRef();
-    return S_OK;
-}
-
-ULONG DOMEventListener::AddRef(void)
-{
-    return WebScriptObject::AddRef();
-}
-
-ULONG DOMEventListener::Release(void)
-{
-    return WebScriptObject::Release();
-}
index e564b6a..a8f5ed5 100644 (file)
@@ -87,4 +87,70 @@ public:
     virtual HRESULT STDMETHODCALLTYPE handleEvent(IDOMEvent*) { return E_NOTIMPL; }
 };
 
+// IUnknown -------------------------------------------------------------------
+HRESULT WebScriptObject::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebScriptObject*>(this);
+    else if (IsEqualGUID(riid, IID_IWebScriptObject))
+        *ppvObject = static_cast<IWebScriptObject*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG WebScriptObject::AddRef(void)
+{
+    return ++m_refCount;
+}
+
+ULONG WebScriptObject::Release(void)
+{
+    ULONG newRef = --m_refCount;
+    if (!newRef)
+        delete(this);
+
+    return newRef;
+}
+
+// DOMObject -------------------------------------------------------------------
+HRESULT DOMObject::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IDOMObject))
+        *ppvObject = static_cast<IDOMObject*>(this);
+    else
+        return WebScriptObject::QueryInterface(riid, ppvObject);
+
+    WebScriptObject::AddRef();
+    return S_OK;
+}
+
+
+// DOMEventListener -------------------------------------------------------------------
+HRESULT DOMEventListener::QueryInterface(const IID &riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IDOMEventListener))
+        *ppvObject = static_cast<IDOMEventListener*>(this);
+    else
+        return DOMObject::QueryInterface(riid, ppvObject);
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG DOMEventListener::AddRef(void)
+{
+    return WebScriptObject::AddRef();
+}
+
+ULONG DOMEventListener::Release(void)
+{
+    return WebScriptObject::Release();
+}
+
 #endif
index 963b717..f802a1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008, 2013, 2014 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2008, 2013 Apple Inc.  All rights reserved.
  * Copyright (C) 2009, 2011 Brent Fulgham.  All rights reserved.
  * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
  * Copyright (C) 2013 Alex Christensen. All rights reserved.
@@ -29,7 +29,9 @@
 #include "stdafx.h"
 #include "WinLauncher.h"
 
+#include "AccessibilityDelegate.h"
 #include "DOMDefaultImpl.h"
+#include "PrintWebUIDelegate.h"
 #include "WinLauncherLibResource.h"
 #include "WinLauncherReplace.h"
 #include <WebKit/WebKitCOMAPI.h>
 #include <CoreFoundation/CFRunLoop.h>
 #endif
 
+#if USE(GLIB)
+#include <glib.h>
+#endif
+
 #include <algorithm>
-#include <cassert>
+#include <assert.h>
+#include <comip.h>
+#include <commctrl.h>
+#include <commdlg.h>
+#include <comutil.h>
+#include <dbghelp.h>
 #include <functional>
-#include <memory>
+#include <objbase.h>
+#include <shellapi.h>
+#include <shlobj.h>
+#include <shlwapi.h>
 #include <string>
 #include <vector>
+#include <wininet.h>
+
+#define MAX_LOADSTRING 100
+#define URLBAR_HEIGHT  24
+#define CONTROLBUTTON_WIDTH 24
 
 static const int maxHistorySize = 10;
 
+typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
+typedef _com_ptr_t<_com_IIID<IWebHistory, &__uuidof(IWebHistory)>> IWebHistoryPtr;
+typedef _com_ptr_t<_com_IIID<IWebHistoryItem, &__uuidof(IWebHistoryItem)>> IWebHistoryItemPtr;
+typedef _com_ptr_t<_com_IIID<IWebInspector, &__uuidof(IWebInspector)>> IWebInspectorPtr;
 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
+typedef _com_ptr_t<_com_IIID<IWebPreferences, &__uuidof(IWebPreferences)>> IWebPreferencesPtr;
+typedef _com_ptr_t<_com_IIID<IWebPreferencesPrivate, &__uuidof(IWebPreferencesPrivate)>> IWebPreferencesPrivatePtr;
+typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr;
+typedef _com_ptr_t<_com_IIID<IWebViewPrivate, &__uuidof(IWebViewPrivate)>> IWebViewPrivatePtr;
 typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr;
 
-WinLauncher::WinLauncher(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView)
-    : m_hMainWnd(mainWnd)
-    , m_hURLBarWnd(urlBarWnd)
-    , m_useLayeredWebView(useLayeredWebView)
+// Global Variables:
+HINSTANCE hInst;                                // current instance
+HWND hMainWnd;
+HWND hURLBarWnd;
+HWND hBackButtonWnd;
+HWND hForwardButtonWnd;
+WNDPROC DefEditProc = 0;
+WNDPROC DefButtonProc = 0;
+WNDPROC DefWebKitProc = 0;
+IWebInspectorPtr gInspector;
+IWebViewPtr gWebView;
+IWebViewPrivatePtr gWebViewPrivate;
+IWebPreferencesPtr gStandardPreferences;
+IWebPreferencesPrivatePtr gPrefsPrivate;
+HWND gViewWindow = 0;
+WinLauncherWebHost* gWebHost = 0;
+PrintWebUIDelegate* gPrintDelegate = 0;
+AccessibilityDelegate* gAccessibilityDelegate = 0;
+IWebHistoryPtr gWebHistory;
+std::vector<IWebHistoryItemPtr> gHistoryItems;
+TCHAR szTitle[MAX_LOADSTRING];                    // The title bar text
+TCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
+
+// Support moving the transparent window
+POINT s_windowPosition = { 100, 100 };
+SIZE s_windowSize = { 800, 400 };
+bool s_usesLayeredWebView = false;
+bool s_fullDesktop = false;
+
+// Forward declarations of functions included in this code module:
+ATOM                MyRegisterClass(HINSTANCE hInstance);
+LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
+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);
+
+static void loadURL(BSTR urlBStr);
+
+static bool usesLayeredWebView()
 {
+    return s_usesLayeredWebView;
 }
 
-HRESULT WinLauncher::init()
+static bool shouldUseFullDesktop()
 {
-    HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&m_webView.GetInterfacePtr()));
-    if (FAILED(hr))
-        return hr;
+    return s_fullDesktop;
+}
 
-    hr = m_webView->QueryInterface(IID_IWebViewPrivate, reinterpret_cast<void**>(&m_webViewPrivate.GetInterfacePtr()));
-    if (FAILED(hr))
-        return hr;
+class SimpleEventListener : public DOMEventListener {
+public:
+    SimpleEventListener(LPWSTR type)
+    {
+        wcsncpy_s(m_eventType, 100, type, 100);
+        m_eventType[99] = 0;
+    }
 
-    hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(m_webHistory), reinterpret_cast<void**>(&m_webHistory.GetInterfacePtr()));
+    virtual HRESULT STDMETHODCALLTYPE handleEvent(IDOMEvent* evt)
+    {
+        wchar_t message[255];
+        wcscpy_s(message, 255, m_eventType);
+        wcscat_s(message, 255, L" event fired!");
+        ::MessageBox(0, message, L"Event Handler", MB_OK);
+        return S_OK;
+    }
 
-    return hr;
-}
+private:
+    wchar_t m_eventType[100];
+};
 
-HRESULT WinLauncher::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL, HWND& viewHwnd)
-{
-    if (!m_webView)
-        return E_FAIL;
+typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr;
 
-    HRESULT hr = m_webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(mainWnd));
+HRESULT WinLauncherWebHost::updateAddressBar(IWebView* webView)
+{
+    IWebFramePtr mainFrame;
+    HRESULT hr = webView->mainFrame(&mainFrame.GetInterfacePtr());
     if (FAILED(hr))
-        return hr;
+        return 0;
 
-    hr = m_webView->initWithFrame(clientRect, 0, 0);
-    if (FAILED(hr))
-        return hr;
+    IWebDataSourcePtr dataSource;
+    hr = mainFrame->dataSource(&dataSource.GetInterfacePtr());
+    if (FAILED(hr) || !dataSource)
+        hr = mainFrame->provisionalDataSource(&dataSource.GetInterfacePtr());
+    if (FAILED(hr) || !dataSource)
+        return 0;
 
-    if (!requestedURL) {
-        IWebFramePtr frame;
-        hr = m_webView->mainFrame(&frame.GetInterfacePtr());
-        if (FAILED(hr))
-            return hr;
-
-        frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
-    }
-
-    hr = m_webViewPrivate->setTransparent(m_useLayeredWebView);
-    if (FAILED(hr))
-        return hr;
+    IWebMutableURLRequestPtr request;
+    hr = dataSource->request(&request.GetInterfacePtr());
+    if (FAILED(hr) || !request)
+        return 0;
 
-    hr = m_webViewPrivate->setUsesLayeredWindow(m_useLayeredWebView);
+    _bstr_t frameURL;
+    hr = request->mainDocumentURL(frameURL.GetAddress());
     if (FAILED(hr))
-        return hr;
+        return 0;
 
-    hr = m_webViewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewHwnd));
+    ::SendMessage(hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(frameURL.GetBSTR()));
 
-    return hr;
+    return 0;
 }
 
-HRESULT WinLauncher::setFrameLoadDelegate(IWebFrameLoadDelegate* frameLoadDelegate)
+HRESULT WinLauncherWebHost::didFailProvisionalLoadWithError(IWebView*, IWebError *error, IWebFrame*)
 {
-    m_frameLoadDelegate = frameLoadDelegate;
-    return m_webView->setFrameLoadDelegate(frameLoadDelegate);
-}
+    _bstr_t errorDescription;
+    HRESULT hr = error->localizedDescription(errorDescription.GetAddress());
+    if (FAILED(hr))
+        errorDescription = L"Failed to load page and to localize error description.";
 
-HRESULT WinLauncher::setUIDelegate(IWebUIDelegate* uiDelegate)
-{
-    m_uiDelegate = uiDelegate;
-    return m_webView->setUIDelegate(uiDelegate);
-}
+    if (_wcsicmp(errorDescription, L"Cancelled"))
+        ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
 
-HRESULT WinLauncher::setAccessibilityDelegate(IAccessibilityDelegate* accessibilityDelegate)
-{
-    m_accessibilityDelegate = accessibilityDelegate;
-    return m_webView->setAccessibilityDelegate(accessibilityDelegate);
+    return S_OK;
 }
 
-IWebFramePtr WinLauncher::mainFrame()
+HRESULT STDMETHODCALLTYPE WinLauncherWebHost::QueryInterface(REFIID riid, void** ppvObject)
 {
-    IWebFramePtr framePtr;
-    m_webView->mainFrame(&framePtr.GetInterfacePtr());
-    return framePtr;
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebFrameLoadDelegate*>(this);
+    else if (IsEqualGUID(riid, IID_IWebFrameLoadDelegate))
+        *ppvObject = static_cast<IWebFrameLoadDelegate*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
 }
 
-bool WinLauncher::seedInitialDefaultPreferences()
+ULONG STDMETHODCALLTYPE WinLauncherWebHost::AddRef(void)
 {
-    IWebPreferencesPtr tmpPreferences;
-    if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences.GetInterfacePtr()))))
-        return false;
-
-    if (FAILED(tmpPreferences->standardPreferences(&m_standardPreferences.GetInterfacePtr())))
-        return false;
-
-    return true;
+    return ++m_refCount;
 }
 
-bool WinLauncher::setToDefaultPreferences()
+ULONG STDMETHODCALLTYPE WinLauncherWebHost::Release(void)
 {
-    HRESULT hr = m_standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&m_prefsPrivate.GetInterfacePtr()));
-    if (!SUCCEEDED(hr))
-        return false;
-
-#if USE(CG)
-    m_standardPreferences->setAVFoundationEnabled(TRUE);
-    m_prefsPrivate->setAcceleratedCompositingEnabled(TRUE);
-#endif
-
-    m_prefsPrivate->setFullScreenEnabled(TRUE);
-    m_prefsPrivate->setShowDebugBorders(FALSE);
-    m_prefsPrivate->setShowRepaintCounter(FALSE);
-
-    m_standardPreferences->setLoadsImagesAutomatically(TRUE);
-    m_prefsPrivate->setAuthorAndUserStylesEnabled(TRUE);
-    m_standardPreferences->setJavaScriptEnabled(TRUE);
-    m_prefsPrivate->setAllowUniversalAccessFromFileURLs(FALSE);
-    m_prefsPrivate->setAllowFileAccessFromFileURLs(TRUE);
-
-    m_prefsPrivate->setDeveloperExtrasEnabled(TRUE);
+    ULONG newRef = --m_refCount;
+    if (!newRef)
+        delete(this);
 
-    return true;
+    return newRef;
 }
 
 static void updateMenuItemForHistoryItem(HMENU menu, IWebHistoryItem& historyItem, int currentHistoryItem)
 {
     UINT menuID = IDM_HISTORY_LINK0 + currentHistoryItem;
 
-    MENUITEMINFO menuItemInfo = { 0 };
+    MENUITEMINFO menuItemInfo = {0};
     menuItemInfo.cbSize = sizeof(MENUITEMINFO);
     menuItemInfo.fMask = MIIM_TYPE;
     menuItemInfo.fType = MFT_STRING;
@@ -189,9 +239,9 @@ static void updateMenuItemForHistoryItem(HMENU menu, IWebHistoryItem& historyIte
     ::EnableMenuItem(menu, menuID, MF_BYCOMMAND | MF_ENABLED);
 }
 
-void WinLauncher::showLastVisitedSites(IWebView& webView)
+static void showLastVisitedSites(IWebView& webView)
 {
-    HMENU menu = ::GetMenu(m_hMainWnd);
+    HMENU menu = ::GetMenu(hMainWnd);
 
     _com_ptr_t<_com_IIID<IWebBackForwardList, &__uuidof(IWebBackForwardList)>> backForwardList;
     HRESULT hr = webView.backForwardList(&backForwardList.GetInterfacePtr());
@@ -224,12 +274,12 @@ void WinLauncher::showLastVisitedSites(IWebView& webView)
     if (FAILED(hr))
         return;
 
-    hr = m_webHistory->addItems(1, &currentItem.GetInterfacePtr());
+    hr = gWebHistory->addItems(1, &currentItem.GetInterfacePtr());
     if (FAILED(hr))
         return;
 
     _com_ptr_t<_com_IIID<IWebHistoryPrivate, &__uuidof(IWebHistoryPrivate)>> webHistory;
-    hr = m_webHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr()));
+    hr = gWebHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr()));
     if (FAILED(hr))
         return;
 
@@ -238,7 +288,7 @@ void WinLauncher::showLastVisitedSites(IWebView& webView)
     if (FAILED(hr))
         return;
 
-    m_historyItems.resize(totalListCount);
+    gHistoryItems.resize(totalListCount);
 
     std::vector<IWebHistoryItem*> historyToLoad(totalListCount);
     hr = webHistory->allItems(&totalListCount, historyToLoad.data());
@@ -246,8 +296,8 @@ void WinLauncher::showLastVisitedSites(IWebView& webView)
         return;
 
     size_t i = 0;
-    for (auto& cur : historyToLoad) {
-        m_historyItems[i].Attach(cur);
+    for (auto cur = historyToLoad.begin(); cur != historyToLoad.end(); ++cur) {
+        gHistoryItems[i].Attach(*cur);
         ++i;
     }
 
@@ -257,7 +307,7 @@ void WinLauncher::showLastVisitedSites(IWebView& webView)
 
     int currentHistoryItem = 0;
     for (int i = 0; i < totalListCount; ++i) {
-        updateMenuItemForHistoryItem(menu, *(m_historyItems[allItemsOffset + currentHistoryItem]), currentHistoryItem);
+        updateMenuItemForHistoryItem(menu, *(gHistoryItems[allItemsOffset + currentHistoryItem]), currentHistoryItem);
         ++currentHistoryItem;
     }
 
@@ -266,96 +316,737 @@ void WinLauncher::showLastVisitedSites(IWebView& webView)
         ::EnableMenuItem(menu, IDM_HISTORY_LINK0 + i, MF_BYCOMMAND | MF_DISABLED);
 }
 
-void WinLauncher::launchInspector()
+typedef _com_ptr_t<_com_IIID<IDOMDocument, &__uuidof(IDOMDocument)>> IDOMDocumentPtr;
+typedef _com_ptr_t<_com_IIID<IDOMElement, &__uuidof(IDOMElement)>> IDOMElementPtr;
+typedef _com_ptr_t<_com_IIID<IDOMEventTarget, &__uuidof(IDOMEventTarget)>> IDOMEventTargetPtr;
+
+HRESULT WinLauncherWebHost::didFinishLoadForFrame(IWebView* webView, IWebFrame* frame)
 {
-    if (!m_webViewPrivate)
+    IDOMDocumentPtr doc;
+    frame->DOMDocument(&doc.GetInterfacePtr());
+
+    IDOMElementPtr element;
+    IDOMEventTargetPtr target;
+
+    showLastVisitedSites(*webView);
+
+    // The following is for the test page:
+    HRESULT hr = doc->getElementById(L"webkit logo", &element.GetInterfacePtr());
+    if (!SUCCEEDED(hr))
+        return hr;
+
+    hr = element->QueryInterface(IID_IDOMEventTarget, reinterpret_cast<void**>(&target.GetInterfacePtr()));
+    if (!SUCCEEDED(hr))
+        return hr;
+
+    hr = target->addEventListener(L"click", new SimpleEventListener (L"webkit logo click"), FALSE);
+    if (!SUCCEEDED(hr))
+        return hr;
+
+    return hr;
+}
+
+static void resizeSubViews()
+{
+    if (usesLayeredWebView() || !gViewWindow)
         return;
 
-    if (!SUCCEEDED(m_webViewPrivate->inspector(&m_inspector.GetInterfacePtr())))
+    RECT rcClient;
+    GetClientRect(hMainWnd, &rcClient);
+    MoveWindow(hBackButtonWnd, 0, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
+    MoveWindow(hForwardButtonWnd, CONTROLBUTTON_WIDTH, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
+    MoveWindow(hURLBarWnd, CONTROLBUTTON_WIDTH * 2, 0, rcClient.right, URLBAR_HEIGHT, TRUE);
+    MoveWindow(gViewWindow, 0, URLBAR_HEIGHT, rcClient.right, rcClient.bottom - URLBAR_HEIGHT, TRUE);
+}
+
+static void subclassForLayeredWindow()
+{
+    hMainWnd = gViewWindow;
+#if defined _M_AMD64 || defined _WIN64
+    DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hMainWnd, GWLP_WNDPROC));
+    ::SetWindowLongPtr(hMainWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc));
+#else
+    DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(hMainWnd, GWL_WNDPROC));
+    ::SetWindowLong(hMainWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc));
+#endif
+}
+
+static void computeFullDesktopFrame()
+{
+    RECT desktop;
+    if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0))
         return;
 
-    m_inspector->show();
+    s_windowPosition.x = 0;
+    s_windowPosition.y = 0;
+    s_windowSize.cx = desktop.right - desktop.left;
+    s_windowSize.cy = desktop.bottom - desktop.top;
+}
+
+BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, LPVOID)
+{
+    if (reason == DLL_PROCESS_ATTACH)
+        hInst = dllInstance;
+
+    return TRUE;
+}
+
+static bool getAppDataFolder(_bstr_t& directory)
+{
+    wchar_t appDataDirectory[MAX_PATH];
+    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
+        return false;
+
+    wchar_t executablePath[MAX_PATH];
+    ::GetModuleFileNameW(0, executablePath, MAX_PATH);
+    ::PathRemoveExtensionW(executablePath);
+
+    directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
+
+    return true;
+}
+
+static bool setToDefaultPreferences()
+{
+    HRESULT hr = gStandardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&gPrefsPrivate.GetInterfacePtr()));
+    if (!SUCCEEDED(hr))
+        return false;
+
+#if USE(CG)
+    gStandardPreferences->setAVFoundationEnabled(TRUE);
+    gPrefsPrivate->setAcceleratedCompositingEnabled(TRUE);
+#endif
+
+    gPrefsPrivate->setFullScreenEnabled(TRUE);
+    gPrefsPrivate->setShowDebugBorders(FALSE);
+    gPrefsPrivate->setShowRepaintCounter(FALSE);
+
+    gStandardPreferences->setLoadsImagesAutomatically(TRUE);
+    gPrefsPrivate->setAuthorAndUserStylesEnabled(TRUE);
+    gStandardPreferences->setJavaScriptEnabled(TRUE);
+    gPrefsPrivate->setAllowUniversalAccessFromFileURLs(FALSE);
+    gPrefsPrivate->setAllowFileAccessFromFileURLs(TRUE);
+
+    gPrefsPrivate->setDeveloperExtrasEnabled(TRUE);
+
+    return true;
+}
+
+static bool setCacheFolder()
+{
+    IWebCachePtr webCache;
+
+    HRESULT hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(webCache), reinterpret_cast<void**>(&webCache.GetInterfacePtr()));
+    if (FAILED(hr))
+        return false;
+
+    _bstr_t appDataFolder;
+    if (!getAppDataFolder(appDataFolder))
+        return false;
+
+    appDataFolder += L"\\cache";
+    webCache->setCacheFolder(appDataFolder);
+
+    return true;
 }
 
-void WinLauncher::navigateForwardOrBackward(HWND hWnd, UINT menuID)
+void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
 {
-    if (!m_webView)
+    _bstr_t directory;
+
+    if (!getAppDataFolder(directory))
+        return;
+
+    if (::SHCreateDirectoryEx(0, directory, 0) != ERROR_SUCCESS
+        && ::GetLastError() != ERROR_FILE_EXISTS
+        && ::GetLastError() != ERROR_ALREADY_EXISTS)
+        return;
+
+    std::wstring fileName = directory + L"\\CrashReport.dmp";
+    HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+    if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
+
+        MINIDUMP_EXCEPTION_INFORMATION mdei;
+        mdei.ThreadId = ::GetCurrentThreadId();
+        mdei.ExceptionPointers  = exceptionPointers;
+        mdei.ClientPointers = 0;
+
+#ifdef _DEBUG
+        MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
+#else
+        MINIDUMP_TYPE dumpType = MiniDumpNormal;
+#endif
+
+        ::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
+        ::CloseHandle(miniDumpFile);
+        processCrashReport(fileName.c_str());
+    }
+}
+
+int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int nCmdShow)
+{
+#ifdef _CRTDBG_MAP_ALLOC
+    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+#endif
+
+     // TODO: Place code here.
+    MSG msg = {0};
+    HACCEL hAccelTable;
+
+    INITCOMMONCONTROLSEX InitCtrlEx;
+
+    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
+    InitCtrlEx.dwICC  = 0x00004000; //ICC_STANDARD_CLASSES;
+    InitCommonControlsEx(&InitCtrlEx);
+
+    _bstr_t requestedURL;
+    int argc = 0;
+    WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+    for (int i = 1; i < argc; ++i) {
+        if (!wcsicmp(argv[i], L"--transparent"))
+            s_usesLayeredWebView = true;
+        else if (!wcsicmp(argv[i], L"--desktop"))
+            s_fullDesktop = true;
+        else if (!requestedURL)
+            requestedURL = argv[i];
+    }
+
+    // Initialize global strings
+    LoadString(hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+    LoadString(hInst, IDC_WINLAUNCHER, szWindowClass, MAX_LOADSTRING);
+    MyRegisterClass(hInst);
+
+    if (shouldUseFullDesktop())
+        computeFullDesktopFrame();
+
+    // Init COM
+    OleInitialize(NULL);
+
+    if (usesLayeredWebView()) {
+        hURLBarWnd = CreateWindow(L"EDIT", L"Type URL Here",
+                    WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 
+                    s_windowPosition.x, s_windowPosition.y + s_windowSize.cy, s_windowSize.cx, URLBAR_HEIGHT,
+                    0,
+                    0,
+                    hInst, 0);
+    } else {
+        hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+                       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInst, 0);
+
+        if (!hMainWnd)
+            return FALSE;
+
+        hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE  | BS_TEXT, 0, 0, 0, 0, hMainWnd, 0, hInst, 0);
+        hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE  | BS_TEXT, CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0);
+        hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0);
+
+        ShowWindow(hMainWnd, nCmdShow);
+        UpdateWindow(hMainWnd);
+    }
+
+    DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC));
+    DefButtonProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC));
+    SetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
+    SetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc));
+    SetWindowLongPtr(hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc));
+
+    SetFocus(hURLBarWnd);
+
+    RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
+
+    IWebPreferencesPtr tmpPreferences;
+    if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences.GetInterfacePtr()))))
+        goto exit;
+
+    if (FAILED(tmpPreferences->standardPreferences(&gStandardPreferences.GetInterfacePtr())))
+        goto exit;
+
+    if (!setToDefaultPreferences())
+        goto exit;
+
+    HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&gWebView.GetInterfacePtr()));
+    if (FAILED(hr))
+        goto exit;
+
+    hr = gWebView->QueryInterface(IID_IWebViewPrivate, reinterpret_cast<void**>(&gWebViewPrivate.GetInterfacePtr()));
+    if (FAILED(hr))
+        goto exit;
+
+    hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(gWebHistory), reinterpret_cast<void**>(&gWebHistory.GetInterfacePtr()));
+    if (FAILED(hr))
+        goto exit;
+
+    if (!setCacheFolder())
+        goto exit;
+
+    gWebHost = new WinLauncherWebHost();
+    gWebHost->AddRef();
+    hr = gWebView->setFrameLoadDelegate(gWebHost);
+    if (FAILED(hr))
+        goto exit;
+
+    gPrintDelegate = new PrintWebUIDelegate;
+    gPrintDelegate->AddRef();
+    hr = gWebView->setUIDelegate(gPrintDelegate);
+    if (FAILED (hr))
+        goto exit;
+
+    gAccessibilityDelegate = new AccessibilityDelegate;
+    gAccessibilityDelegate->AddRef();
+    hr = gWebView->setAccessibilityDelegate(gAccessibilityDelegate);
+    if (FAILED (hr))
+        goto exit;
+
+    hr = gWebView->setHostWindow(reinterpret_cast<OLE_HANDLE>(hMainWnd));
+    if (FAILED(hr))
+        goto exit;
+
+    hr = gWebView->initWithFrame(clientRect, 0, 0);
+    if (FAILED(hr))
+        goto exit;
+
+    if (!requestedURL) {
+        IWebFramePtr frame;
+        hr = gWebView->mainFrame(&frame.GetInterfacePtr());
+        if (FAILED(hr))
+            goto exit;
+
+        frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
+    }
+
+    hr = gWebViewPrivate->setTransparent(usesLayeredWebView());
+    if (FAILED(hr))
+        goto exit;
+
+    hr = gWebViewPrivate->setUsesLayeredWindow(usesLayeredWebView());
+    if (FAILED(hr))
+        goto exit;
+
+    hr = gWebViewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&gViewWindow));
+    if (FAILED(hr) || !gViewWindow)
+        goto exit;
+
+    if (usesLayeredWebView())
+        subclassForLayeredWindow();
+
+    resizeSubViews();
+
+    ShowWindow(gViewWindow, nCmdShow);
+    UpdateWindow(gViewWindow);
+
+    hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_WINLAUNCHER));
+
+    if (requestedURL.length())
+        loadURL(requestedURL.GetBSTR());
+
+#pragma warning(disable:4509)
+
+    // Main message loop:
+    __try {
+        while (GetMessage(&msg, 0, 0, 0)) {
+#if USE(CF)
+            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+#endif
+            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
+                TranslateMessage(&msg);
+                DispatchMessage(&msg);
+            }
+#if USE(GLIB)
+            g_main_context_iteration(0, false);
+#endif
+        }
+    } __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
+
+exit:
+    gPrintDelegate->Release();
+
+    shutDownWebKit();
+#ifdef _CRTDBG_MAP_ALLOC
+    _CrtDumpMemoryLeaks();
+#endif
+
+    // Shut down COM.
+    OleUninitialize();
+    
+    return static_cast<int>(msg.wParam);
+}
+
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+    WNDCLASSEX wcex;
+
+    wcex.cbSize = sizeof(WNDCLASSEX);
+
+    wcex.style          = CS_HREDRAW | CS_VREDRAW;
+    wcex.lpfnWndProc    = WndProc;
+    wcex.cbClsExtra     = 0;
+    wcex.cbWndExtra     = 0;
+    wcex.hInstance      = hInstance;
+    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINLAUNCHER));
+    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
+    wcex.hbrBackground  = 0;
+    wcex.lpszMenuName   = MAKEINTRESOURCE(IDC_WINLAUNCHER);
+    wcex.lpszClassName  = szWindowClass;
+    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+    return RegisterClassEx(&wcex);
+}
+
+static BOOL CALLBACK AbortProc(HDC hDC, int Error)
+{
+    MSG msg;
+    while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
+        ::TranslateMessage(&msg);
+        ::DispatchMessage(&msg);
+    }
+
+    return TRUE;
+}
+
+static HDC getPrinterDC()
+{
+    PRINTDLG pdlg;
+    memset(&pdlg, 0, sizeof(PRINTDLG));
+    pdlg.lStructSize = sizeof(PRINTDLG);
+    pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC;
+
+    ::PrintDlg(&pdlg);
+
+    return pdlg.hDC;
+}
+
+static void initDocStruct(DOCINFO* di, TCHAR* docname)
+{
+    memset(di, 0, sizeof(DOCINFO));
+    di->cbSize = sizeof(DOCINFO);
+    di->lpszDocName = docname;
+}
+
+typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
+
+void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    HDC printDC = getPrinterDC();
+    if (!printDC) {
+        ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK);
+        return;
+    }
+
+    if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) {
+        ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK);
+        return;
+    }
+
+    IWebFramePtr frame;
+    IWebFramePrivatePtr framePrivate;
+    if (FAILED(gWebView->mainFrame(&frame.GetInterfacePtr())))
+        return;
+
+    if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr())))
+        return;
+
+    framePrivate->setInPrintingMode(TRUE, printDC);
+
+    UINT pageCount = 0;
+    framePrivate->getPrintedPageCount(printDC, &pageCount);
+
+    DOCINFO di;
+    initDocStruct(&di, L"WebKit Doc");
+    ::StartDoc(printDC, &di);
+
+    // FIXME: Need CoreGraphics implementation
+    void* graphicsContext = 0;
+    for (size_t page = 1; page <= pageCount; ++page) {
+        ::StartPage(printDC);
+        framePrivate->spoolPages(printDC, page, page, graphicsContext);
+        ::EndPage(printDC);
+    }
+
+    framePrivate->setInPrintingMode(FALSE, printDC);
+
+    ::EndDoc(printDC);
+    ::DeleteDC(printDC);
+}
+
+static void ToggleMenuItem(HWND hWnd, UINT menuID)
+{
+    HMENU menu = ::GetMenu(hWnd);
+
+    MENUITEMINFO info;
+    ::memset(&info, 0x00, sizeof(info));
+    info.cbSize = sizeof(info);
+    info.fMask = MIIM_STATE;
+
+    if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))
+        return;
+
+    BOOL newState = !(info.fState & MFS_CHECKED);
+
+    if (!gStandardPreferences || !gPrefsPrivate)
+        return;
+
+    switch (menuID) {
+    case IDM_AVFOUNDATION:
+        gStandardPreferences->setAVFoundationEnabled(newState);
+        break;
+    case IDM_ACC_COMPOSITING:
+        gPrefsPrivate->setAcceleratedCompositingEnabled(newState);
+        break;
+    case IDM_WK_FULLSCREEN:
+        gPrefsPrivate->setFullScreenEnabled(newState);
+        break;
+    case IDM_COMPOSITING_BORDERS:
+        gPrefsPrivate->setShowDebugBorders(newState);
+        gPrefsPrivate->setShowRepaintCounter(newState);
+        break;
+    case IDM_DISABLE_IMAGES:
+        gStandardPreferences->setLoadsImagesAutomatically(!newState);
+        break;
+    case IDM_DISABLE_STYLES:
+        gPrefsPrivate->setAuthorAndUserStylesEnabled(!newState);
+        break;
+    case IDM_DISABLE_JAVASCRIPT:
+        gStandardPreferences->setJavaScriptEnabled(!newState);
+        break;
+    case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
+        gPrefsPrivate->setAllowUniversalAccessFromFileURLs(newState);
+        gPrefsPrivate->setAllowFileAccessFromFileURLs(newState);
+        break;
+    }
+
+    info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
+
+    ::SetMenuItemInfo(menu, menuID, FALSE, &info);
+}
+
+static void LaunchInspector(HWND hwnd)
+{
+    if (!gWebViewPrivate)
+        return;
+
+    if (!SUCCEEDED(gWebViewPrivate->inspector(&gInspector.GetInterfacePtr())))
+        return;
+
+    gInspector->show();
+}
+
+static void NavigateForwardOrBackward(HWND hWnd, UINT menuID)
+{
+    if (!gWebView)
         return;
 
     BOOL wentBackOrForward = FALSE;
     if (IDM_HISTORY_FORWARD == menuID)
-        m_webView->goForward(&wentBackOrForward);
+        gWebView->goForward(&wentBackOrForward);
     else
-        m_webView->goBack(&wentBackOrForward);
+        gWebView->goBack(&wentBackOrForward);
 }
 
-void WinLauncher::navigateToHistory(HWND hWnd, UINT menuID)
+static void NavigateToHistory(HWND hWnd, UINT menuID)
 {
-    if (!m_webView)
+    if (!gWebView)
         return;
 
     int historyEntry = menuID - IDM_HISTORY_LINK0;
-    if (historyEntry > m_historyItems.size())
+    if (historyEntry > gHistoryItems.size())
         return;
 
-    IWebHistoryItemPtr desiredHistoryItem = m_historyItems[historyEntry];
+    IWebHistoryItemPtr desiredHistoryItem = gHistoryItems[historyEntry];
     if (!desiredHistoryItem)
         return;
 
     BOOL succeeded = FALSE;
-    m_webView->goToBackForwardItem(desiredHistoryItem, &succeeded);
+    gWebView->goToBackForwardItem(desiredHistoryItem, &succeeded);
 
     _bstr_t frameURL;
     desiredHistoryItem->URLString(frameURL.GetAddress());
 
-    ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());
+    ::SendMessage(hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());
 }
 
-bool WinLauncher::goBack()
+static const int dragBarHeight = 30;
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    WNDPROC parentProc = usesLayeredWebView() ? DefWebKitProc : DefWindowProc;
+
+    switch (message) {
+    case WM_NCHITTEST:
+        if (usesLayeredWebView()) {
+            RECT window;
+            ::GetWindowRect(hWnd, &window);
+            // For testing our transparent window, we need a region to use as a handle for
+            // dragging. The right way to do this would be to query the web view to see what's
+            // under the mouse. However, for testing purposes we just use an arbitrary
+            // 30 pixel band at the top of the view as an arbitrary gripping location.
+            //
+            // When we are within this bad, return HT_CAPTION to tell Windows we want to
+            // treat this region as if it were the title bar on a normal window.
+            int y = HIWORD(lParam);
+
+            if ((y > window.top) && (y < window.top + dragBarHeight))
+                return HTCAPTION;
+        }
+        return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+    case WM_COMMAND: {
+        int wmId = LOWORD(wParam);
+        int wmEvent = HIWORD(wParam);
+        if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) {
+            NavigateToHistory(hWnd, wmId);
+            break;
+        }
+        // Parse the menu selections:
+        switch (wmId) {
+        case IDM_ABOUT:
+            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
+            break;
+        case IDM_EXIT:
+            DestroyWindow(hWnd);
+            break;
+        case IDM_PRINT:
+            PrintView(hWnd, message, wParam, lParam);
+            break;
+        case IDM_WEB_INSPECTOR:
+            LaunchInspector(hWnd);
+            break;
+        case IDM_HISTORY_BACKWARD:
+        case IDM_HISTORY_FORWARD:
+            NavigateForwardOrBackward(hWnd, wmId);
+            break;
+        case IDM_AVFOUNDATION:
+        case IDM_ACC_COMPOSITING:
+        case IDM_WK_FULLSCREEN:
+        case IDM_COMPOSITING_BORDERS:
+        case IDM_DISABLE_IMAGES:
+        case IDM_DISABLE_STYLES:
+        case IDM_DISABLE_JAVASCRIPT:
+        case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
+            ToggleMenuItem(hWnd, wmId);
+            break;
+        default:
+            return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+        }
+        }
+        break;
+    case WM_DESTROY:
+#if USE(CF)
+        CFRunLoopStop(CFRunLoopGetMain());
+#endif
+        PostQuitMessage(0);
+        break;
+    case WM_SIZE:
+        if (!gWebView || usesLayeredWebView())
+           return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+
+        resizeSubViews();
+        break;
+    default:
+        return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+    }
+
+    return 0;
+}
+
+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)
 {
     BOOL wentBack = FALSE;
-    m_webView->goBack(&wentBack);
-    return wentBack;
+    switch (message) {
+    case WM_LBUTTONUP:
+        gWebView->goBack(&wentBack);
+    default:
+        return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam);
+    }
 }
 
-bool WinLauncher::goForward()
+LRESULT CALLBACK ForwardButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {
     BOOL wentForward = FALSE;
-    m_webView->goForward(&wentForward);
-    return wentForward;
+    switch (message) {
+    case WM_LBUTTONUP:
+        gWebView->goForward(&wentForward);
+    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;
 }
 
-HRESULT WinLauncher::loadURL(const BSTR& passedURL)
+static void loadURL(BSTR passedURL)
 {
     _bstr_t urlBStr(passedURL);
     if (!!urlBStr && (::PathFileExists(urlBStr) || ::PathIsUNC(urlBStr))) {
         TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
-        DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]);
+        DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
 
         if (SUCCEEDED(::UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0)))
             urlBStr = fileURL;
     }
 
     IWebFramePtr frame;
-    HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr());
+    HRESULT hr = gWebView->mainFrame(&frame.GetInterfacePtr());
     if (FAILED(hr))
-        return hr;
+        return;
 
     IWebMutableURLRequestPtr request;
     hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&request);
     if (FAILED(hr))
-        return hr;
+        return;
 
     hr = request->initWithURL(wcsstr(static_cast<wchar_t*>(urlBStr), L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60);
     if (FAILED(hr))
-        return hr;
+        return;
 
     _bstr_t methodBStr(L"GET");
     hr = request->setHTTPMethod(methodBStr);
     if (FAILED(hr))
-        return hr;
+        return;
 
     hr = frame->loadRequest(request);
+    if (FAILED(hr))
+        return;
 
-    return hr;
+    SetFocus(gViewWindow);
+}
+
+extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
+{
+    return wWinMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
 }
diff --git a/Tools/WinLauncher/WinLauncher.h b/Tools/WinLauncher/WinLauncher.h
new file mode 100644 (file)
index 0000000..5cd35b3
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#include "resource.h"
+#include <WebKit/WebKit.h>
+
+class WinLauncherWebHost : public IWebFrameLoadDelegate
+{
+public:
+    WinLauncherWebHost() : m_refCount(1) {}
+
+    // IUnknown
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef(void);
+    virtual ULONG STDMETHODCALLTYPE Release(void);
+
+    // IWebFrameLoadDelegate
+    virtual HRESULT STDMETHODCALLTYPE didStartProvisionalLoadForFrame( 
+        /* [in] */ IWebView* webView,
+        /* [in] */ IWebFrame* /*frame*/) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didReceiveServerRedirectForProvisionalLoadForFrame( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didFailProvisionalLoadWithError( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebError *error,
+        /* [in] */ IWebFrame*);
+    
+    virtual HRESULT STDMETHODCALLTYPE didCommitLoadForFrame( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return updateAddressBar(webView); }
+    
+    virtual HRESULT STDMETHODCALLTYPE didReceiveTitle( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ BSTR title,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didChangeIcons(
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+
+    virtual HRESULT STDMETHODCALLTYPE didReceiveIcon( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ OLE_HANDLE hBitmap,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didFinishLoadForFrame( 
+        /* [in] */ IWebView* webView,
+        /* [in] */ IWebFrame* /*frame*/);
+    
+    virtual HRESULT STDMETHODCALLTYPE didFailLoadWithError( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebError *error,
+        /* [in] */ IWebFrame *forFrame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+
+    virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ BSTR url,
+        /* [in] */ double delaySeconds,
+        /* [in] */ DATE fireDate,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE didCancelClientRedirectForFrame( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual HRESULT STDMETHODCALLTYPE willCloseFrame( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+    
+    virtual /* [local] */ HRESULT STDMETHODCALLTYPE windowScriptObjectAvailable( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ JSContextRef context,
+        /* [in] */ JSObjectRef windowScriptObject)  { return S_OK; }
+
+    virtual /* [local] */ HRESULT STDMETHODCALLTYPE didClearWindowObject( 
+        /* [in] */ IWebView *webView,
+        /* [in] */ JSContextRef context,
+        /* [in] */ JSObjectRef windowScriptObject,
+        /* [in] */ IWebFrame *frame) { return S_OK; }
+
+    // WinLauncherWebHost
+
+protected:
+    HRESULT updateAddressBar(IWebView* webView);
+
+protected:
+    ULONG                   m_refCount;
+};
index acff89d..fb3513e 100644 (file)
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\AccessibilityDelegate.cpp" />
-    <ClCompile Include="..\Common.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
-    </ClCompile>
-    <ClCompile Include="..\DOMDefaultImpl.cpp" />
     <ClCompile Include="..\PrintWebUIDelegate.cpp" />
     <ClCompile Include="..\stdafx.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">Create</PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="..\WinLauncher.cpp" />
-    <ClCompile Include="..\WinLauncherWebHost.cpp" />
-    <ClCompile Include="..\WinMain.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\AccessibilityDelegate.h" />
     <ClInclude Include="..\stdafx.h" />
     <ClInclude Include="..\WinLauncher.h" />
     <ClInclude Include="..\WinLauncherReplace.h" />
-    <ClInclude Include="..\WinLauncherWebHost.h" />
     <ClInclude Include="WinLauncherLibResource.h" />
   </ItemGroup>
   <ItemGroup>
index 3c4822d..047a88d 100644 (file)
     <ClCompile Include="..\AccessibilityDelegate.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\WinLauncherWebHost.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\DOMDefaultImpl.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\WinMain.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\Common.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\DOMDefaultImpl.h">
@@ -72,9 +60,6 @@
     <ClInclude Include="..\WinLauncherReplace.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\WinLauncherWebHost.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="WinLauncherLib.rc">
index 00979b4..86754f1 100644 (file)
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WinLauncherReplace_h
-#define WinLauncherReplace_h
-
 // This file is to make it easier for users to manage changes to the internals of WinLauncher
 
-static const wchar_t* defaultHTML = L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>";
-
-static void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
+const wchar_t* defaultHTML = L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>";
 
-#endif
+void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
diff --git a/Tools/WinLauncher/WinLauncherWebHost.cpp b/Tools/WinLauncher/WinLauncherWebHost.cpp
deleted file mode 100644 (file)
index a13dcd0..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2006, 2008, 2013 Apple Inc.  All rights reserved.
- * Copyright (C) 2009, 2011 Brent Fulgham.  All rights reserved.
- * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
- * Copyright (C) 2013 Alex Christensen. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "stdafx.h"
-#include "WinLauncherWebHost.h"
-
-#include "DOMDefaultImpl.h"
-#include "WinLauncher.h"
-#include <WebKit/WebKit.h>
-
-class SimpleEventListener : public DOMEventListener {
-public:
-    SimpleEventListener(LPWSTR type)
-    {
-        wcsncpy_s(m_eventType, 100, type, 100);
-        m_eventType[99] = 0;
-    }
-
-    virtual HRESULT STDMETHODCALLTYPE handleEvent(IDOMEvent* evt)
-    {
-        wchar_t message[255];
-        wcscpy_s(message, 255, m_eventType);
-        wcscat_s(message, 255, L" event fired!");
-        ::MessageBox(0, message, L"Event Handler", MB_OK);
-        return S_OK;
-    }
-
-private:
-    wchar_t m_eventType[100];
-};
-
-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
-typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr;
-typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
-
-HRESULT WinLauncherWebHost::updateAddressBar(IWebView& webView)
-{
-    IWebFramePtr mainFrame;
-    HRESULT hr = webView.mainFrame(&mainFrame.GetInterfacePtr());
-    if (FAILED(hr))
-        return 0;
-
-    IWebDataSourcePtr dataSource;
-    hr = mainFrame->dataSource(&dataSource.GetInterfacePtr());
-    if (FAILED(hr) || !dataSource)
-        hr = mainFrame->provisionalDataSource(&dataSource.GetInterfacePtr());
-    if (FAILED(hr) || !dataSource)
-        return 0;
-
-    IWebMutableURLRequestPtr request;
-    hr = dataSource->request(&request.GetInterfacePtr());
-    if (FAILED(hr) || !request)
-        return 0;
-
-    _bstr_t frameURL;
-    hr = request->mainDocumentURL(frameURL.GetAddress());
-    if (FAILED(hr))
-        return 0;
-
-    ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(frameURL.GetBSTR()));
-
-    return 0;
-}
-
-HRESULT WinLauncherWebHost::didFailProvisionalLoadWithError(IWebView*, IWebError *error, IWebFrame*)
-{
-    _bstr_t errorDescription;
-    HRESULT hr = error->localizedDescription(errorDescription.GetAddress());
-    if (FAILED(hr))
-        errorDescription = L"Failed to load page and to localize error description.";
-
-    if (_wcsicmp(errorDescription, L"Cancelled"))
-        ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
-
-    return S_OK;
-}
-
-HRESULT WinLauncherWebHost::QueryInterface(REFIID riid, void** ppvObject)
-{
-    *ppvObject = 0;
-    if (IsEqualGUID(riid, IID_IUnknown))
-        *ppvObject = static_cast<IWebFrameLoadDelegate*>(this);
-    else if (IsEqualGUID(riid, IID_IWebFrameLoadDelegate))
-        *ppvObject = static_cast<IWebFrameLoadDelegate*>(this);
-    else
-        return E_NOINTERFACE;
-
-    AddRef();
-    return S_OK;
-}
-
-ULONG WinLauncherWebHost::AddRef()
-{
-    return ++m_refCount;
-}
-
-ULONG WinLauncherWebHost::Release()
-{
-    ULONG newRef = --m_refCount;
-    if (!newRef)
-        delete(this);
-
-    return newRef;
-}
-
-typedef _com_ptr_t<_com_IIID<IDOMDocument, &__uuidof(IDOMDocument)>> IDOMDocumentPtr;
-typedef _com_ptr_t<_com_IIID<IDOMElement, &__uuidof(IDOMElement)>> IDOMElementPtr;
-typedef _com_ptr_t<_com_IIID<IDOMEventTarget, &__uuidof(IDOMEventTarget)>> IDOMEventTargetPtr;
-
-HRESULT WinLauncherWebHost::didFinishLoadForFrame(IWebView* webView, IWebFrame* frame)
-{
-    IDOMDocumentPtr doc;
-    frame->DOMDocument(&doc.GetInterfacePtr());
-
-    IDOMElementPtr element;
-    IDOMEventTargetPtr target;
-
-    if (m_client)
-        m_client->showLastVisitedSites(*webView);
-
-    // The following is for the test page:
-    HRESULT hr = doc->getElementById(L"webkit logo", &element.GetInterfacePtr());
-    if (!SUCCEEDED(hr))
-        return hr;
-
-    hr = element->QueryInterface(IID_IDOMEventTarget, reinterpret_cast<void**>(&target.GetInterfacePtr()));
-    if (!SUCCEEDED(hr))
-        return hr;
-
-    hr = target->addEventListener(L"click", new SimpleEventListener (L"webkit logo click"), FALSE);
-    if (!SUCCEEDED(hr))
-        return hr;
-
-    return hr;
-}
diff --git a/Tools/WinLauncher/WinLauncherWebHost.h b/Tools/WinLauncher/WinLauncherWebHost.h
deleted file mode 100644 (file)
index cf48ac7..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006, 2014 Apple Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#pragma once
-
-#include "resource.h"
-#include <WebKit/WebKit.h>
-
-class WinLauncher;
-
-class WinLauncherWebHost : public IWebFrameLoadDelegate {
-public:
-    WinLauncherWebHost(WinLauncher* client, HWND urlBar)
-        : m_refCount(1), m_client(client), m_hURLBarWnd(urlBar) { }
-
-    // IUnknown
-    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
-    virtual ULONG STDMETHODCALLTYPE AddRef();
-    virtual ULONG STDMETHODCALLTYPE Release();
-
-    // IWebFrameLoadDelegate
-    virtual HRESULT STDMETHODCALLTYPE didStartProvisionalLoadForFrame(IWebView*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didReceiveServerRedirectForProvisionalLoadForFrame(IWebView*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didFailProvisionalLoadWithError(IWebView*, IWebError*, IWebFrame*);
-    virtual HRESULT STDMETHODCALLTYPE didCommitLoadForFrame(IWebView* webView, IWebFrame*)
-    {
-        if (!webView)
-            return E_POINTER;
-
-        return updateAddressBar(*webView);
-    }
-    
-    virtual HRESULT STDMETHODCALLTYPE didReceiveTitle(IWebView*, BSTR title, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didChangeIcons(IWebView*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didReceiveIcon(IWebView*, OLE_HANDLE hBitmap, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didFinishLoadForFrame(IWebView*, IWebFrame*);   
-    virtual HRESULT STDMETHODCALLTYPE didFailLoadWithError(IWebView*, IWebError*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(IWebView*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL(IWebView*, BSTR url, double delaySeconds, DATE fireDate, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE didCancelClientRedirectForFrame(IWebView*, IWebFrame*) { return S_OK; }
-    virtual HRESULT STDMETHODCALLTYPE willCloseFrame(IWebView*, IWebFrame*) { return S_OK; }
-    virtual /* [local] */ HRESULT STDMETHODCALLTYPE windowScriptObjectAvailable(IWebView*, JSContextRef, JSObjectRef)  { return S_OK; }
-    virtual /* [local] */ HRESULT STDMETHODCALLTYPE didClearWindowObject(IWebView*, JSContextRef, JSObjectRef, IWebFrame*) { return S_OK; }
-
-protected:
-    HRESULT updateAddressBar(IWebView&);
-
-private:
-    HWND m_hURLBarWnd;
-    ULONG m_refCount;
-    WinLauncher* m_client;
-};
diff --git a/Tools/WinLauncher/WinMain.cpp b/Tools/WinLauncher/WinMain.cpp
deleted file mode 100644 (file)
index 10b0bc2..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2006, 2008, 2013, 2014 Apple Inc.  All rights reserved.
- * Copyright (C) 2009, 2011 Brent Fulgham.  All rights reserved.
- * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
- * Copyright (C) 2013 Alex Christensen. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "stdafx.h"
-#include "WinLauncherLibResource.h"
-#include "WinLauncherWebHost.h"
-#include "Common.cpp"
-
-int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int nCmdShow)
-{
-#ifdef _CRTDBG_MAP_ALLOC
-    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
-    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
-#endif
-
-    MSG msg = {0};
-    HACCEL hAccelTable;
-
-    INITCOMMONCONTROLSEX InitCtrlEx;
-
-    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
-    InitCtrlEx.dwICC  = 0x00004000; // ICC_STANDARD_CLASSES;
-    InitCommonControlsEx(&InitCtrlEx);
-
-    bool usesLayeredWebView = false;
-    bool useFullDesktop = false;
-
-    _bstr_t requestedURL;
-    int argc = 0;
-    WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
-    for (int i = 1; i < argc; ++i) {
-        if (!wcsicmp(argv[i], L"--transparent"))
-            usesLayeredWebView = true;
-        else if (!wcsicmp(argv[i], L"--desktop"))
-            useFullDesktop = true;
-        else if (!requestedURL)
-            requestedURL = argv[i];
-    }
-
-    // Initialize global strings
-    LoadString(hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
-    LoadString(hInst, IDC_WINLAUNCHER, szWindowClass, MAX_LOADSTRING);
-    MyRegisterClass(hInst);
-
-    if (useFullDesktop)
-        computeFullDesktopFrame();
-
-    // Init COM
-    OleInitialize(nullptr);
-
-    if (usesLayeredWebView) {
-        hURLBarWnd = CreateWindow(L"EDIT", L"Type URL Here",
-            WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 
-            s_windowPosition.x, s_windowPosition.y + s_windowSize.cy, s_windowSize.cx, URLBAR_HEIGHT,
-            0, 0, hInst, 0);
-    } else {
-        hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
-            CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInst, 0);
-
-        if (!hMainWnd)
-            return FALSE;
-
-        hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE  | BS_TEXT, 0, 0, 0, 0, hMainWnd, 0, hInst, 0);
-        hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE  | BS_TEXT, CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0);
-        hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0);
-
-        ShowWindow(hMainWnd, nCmdShow);
-        UpdateWindow(hMainWnd);
-    }
-
-    DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC));
-    DefButtonProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC));
-    SetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
-    SetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc));
-    SetWindowLongPtr(hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc));
-
-    SetFocus(hURLBarWnd);
-
-    RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
-
-    gWinLauncher = new WinLauncher(hMainWnd, hURLBarWnd, usesLayeredWebView);
-    if (!gWinLauncher)
-        goto exit;
-
-    if (!gWinLauncher->seedInitialDefaultPreferences())
-        goto exit;
-
-    if (!gWinLauncher->setToDefaultPreferences())
-        goto exit;
-
-    HRESULT hr = gWinLauncher->init();
-    if (FAILED(hr))
-        goto exit;
-
-    if (!setCacheFolder())
-        goto exit;
-
-    hr = gWinLauncher->setFrameLoadDelegate(new WinLauncherWebHost(gWinLauncher, hURLBarWnd));
-    if (FAILED(hr))
-        goto exit;
-
-    hr = gWinLauncher->setUIDelegate(new PrintWebUIDelegate());
-    if (FAILED (hr))
-        goto exit;
-
-    hr = gWinLauncher->setAccessibilityDelegate(new AccessibilityDelegate());
-    if (FAILED (hr))
-        goto exit;
-
-    hr = gWinLauncher->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR(), gViewWindow);
-    if (FAILED(hr) || !gViewWindow)
-        goto exit;
-
-    if (gWinLauncher->usesLayeredWebView())
-        subclassForLayeredWindow();
-
-    resizeSubViews();
-
-    ShowWindow(gViewWindow, nCmdShow);
-    UpdateWindow(gViewWindow);
-
-    hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_WINLAUNCHER));
-
-    if (requestedURL.length())
-        loadURL(requestedURL.GetBSTR());
-
-#pragma warning(disable:4509)
-
-    // Main message loop:
-    __try {
-        while (GetMessage(&msg, 0, 0, 0)) {
-#if USE(CF)
-            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
-#endif
-            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
-                TranslateMessage(&msg);
-                DispatchMessage(&msg);
-            }
-#if USE(GLIB)
-            g_main_context_iteration(0, false);
-#endif
-        }
-    } __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
-
-exit:
-    shutDownWebKit();
-#ifdef _CRTDBG_MAP_ALLOC
-    _CrtDumpMemoryLeaks();
-#endif
-
-    // Shut down COM.
-    OleUninitialize();
-
-    delete gWinLauncher;
-    
-    return static_cast<int>(msg.wParam);
-}
-
-ATOM MyRegisterClass(HINSTANCE hInstance)
-{
-    WNDCLASSEX wcex;
-
-    wcex.cbSize = sizeof(WNDCLASSEX);
-
-    wcex.style          = CS_HREDRAW | CS_VREDRAW;
-    wcex.lpfnWndProc    = WndProc;
-    wcex.cbClsExtra     = 0;
-    wcex.cbWndExtra     = 0;
-    wcex.hInstance      = hInstance;
-    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINLAUNCHER));
-    wcex.hCursor        = LoadCursor(0, IDC_ARROW);
-    wcex.hbrBackground  = 0;
-    wcex.lpszMenuName   = MAKEINTRESOURCE(IDC_WINLAUNCHER);
-    wcex.lpszClassName  = szWindowClass;
-    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
-
-    return RegisterClassEx(&wcex);
-}