<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170339] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170339">170339</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-06-23 17:51:58 -0700 (Mon, 23 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Win] Clean up and refactor WinLauncher
https://bugs.webkit.org/show_bug.cgi?id=134209
Reviewed by Tim Horton.
Make WinLauncher a class, and move all non-class driver functions
into "Common.cpp" and "WinMain.cpp". These files are distinct
to allow some internal tools to reuse the code in 'Common'.
* WinLauncher/Common.cpp: Added. Consists of code moved from
'WinLauncher.cpp' that can be reused for other tools.
(subclassForLayeredWindow):
(computeFullDesktopFrame):
(DllMain):
(getAppDataFolder):
(setCacheFolder):
(createCrashReport):
(AbortProc):
(getPrinterDC):
(initDocStruct):
(PrintView):
(ToggleMenuItem):
(WndProc):
(EditProc):
(BackButtonProc):
(ForwardButtonProc):
(About):
(loadURL):
(dllLauncherEntryPoint):
* WinLauncher/DOMDefaultImpl.cpp: Copied from WinLauncher/DOMDefaultImpl.h.
(DOMEventListener::Release):
(WebScriptObject::WebScriptObject): Deleted.
(WebScriptObject::~WebScriptObject): Deleted.
(WebScriptObject::throwException): Deleted.
(WebScriptObject::callWebScriptMethod): Deleted.
(WebScriptObject::evaluateWebScript): Deleted.
(WebScriptObject::removeWebScriptKey): Deleted.
(WebScriptObject::stringRepresentation): Deleted.
(WebScriptObject::webScriptValueAtIndex): Deleted.
(WebScriptObject::setWebScriptValueAtIndex): Deleted.
(WebScriptObject::setException): Deleted.
(DOMEventListener::throwException): Deleted.
(DOMEventListener::callWebScriptMethod): Deleted.
(DOMEventListener::evaluateWebScript): Deleted.
(DOMEventListener::removeWebScriptKey): Deleted.
(DOMEventListener::stringRepresentation): Deleted.
(DOMEventListener::webScriptValueAtIndex): Deleted.
(DOMEventListener::setWebScriptValueAtIndex): Deleted.
(DOMEventListener::setException): Deleted.
(DOMEventListener::handleEvent): Deleted.
* WinLauncher/DOMDefaultImpl.h:
(WebScriptObject::QueryInterface): Deleted.
(WebScriptObject::AddRef): Deleted.
(WebScriptObject::Release): Deleted.
(DOMObject::QueryInterface): Deleted.
(DOMEventListener::QueryInterface): Deleted.
(DOMEventListener::AddRef): Deleted.
(DOMEventListener::Release): Deleted.
* WinLauncher/WinLauncher.cpp: Converted stand-alone implementation
into a C++ class and removed WinAPI code.
(WinLauncher::WinLauncher):
(WinLauncher::init):
(WinLauncher::prepareViews):
(WinLauncher::setFrameLoadDelegate):
(WinLauncher::setUIDelegate):
(WinLauncher::setAccessibilityDelegate):
(WinLauncher::mainFrame):
(WinLauncher::seedInitialDefaultPreferences):
(WinLauncher::setToDefaultPreferences):
(updateMenuItemForHistoryItem):
(WinLauncher::showLastVisitedSites):
(WinLauncher::launchInspector):
(WinLauncher::navigateForwardOrBackward):
(WinLauncher::navigateToHistory):
(WinLauncher::goBack):
(WinLauncher::goForward):
(WinLauncher::loadURL):
(shouldUseFullDesktop): Deleted.
(SimpleEventListener::SimpleEventListener): Deleted.
(SimpleEventListener::handleEvent): Deleted.
(WinLauncherWebHost::updateAddressBar): Deleted.
(WinLauncherWebHost::didFailProvisionalLoadWithError): Deleted.
(WinLauncherWebHost::QueryInterface): Deleted.
(WinLauncherWebHost::AddRef): Deleted.
(WinLauncherWebHost::Release): Deleted.
(showLastVisitedSites): Deleted.
(WinLauncherWebHost::didFinishLoadForFrame): Deleted.
(resizeSubViews): Deleted.
(subclassForLayeredWindow): Deleted.
(computeFullDesktopFrame): Deleted.
(DllMain): Deleted.
(getAppDataFolder): Deleted.
(setToDefaultPreferences): Deleted.
(setCacheFolder): Deleted.
(createCrashReport): Deleted.
(wWinMain): Deleted.
(MyRegisterClass): Deleted.
(AbortProc): Deleted.
(getPrinterDC): Deleted.
(initDocStruct): Deleted.
(PrintView): Deleted.
(ToggleMenuItem): Deleted.
(LaunchInspector): Deleted.
(NavigateForwardOrBackward): Deleted.
(NavigateToHistory): Deleted.
(WndProc): Deleted.
(EditProc): Deleted.
(BackButtonProc): Deleted.
(ForwardButtonProc): Deleted.
(About): Deleted.
(loadURL): Deleted.
(dllLauncherEntryPoint): Deleted.
* WinLauncher/WinLauncher.h: Removed.
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
* WinLauncher/WinLauncherReplace.h:
(processCrashReport):
* WinLauncher/WinLauncherWebHost.cpp: Added.
(SimpleEventListener::SimpleEventListener):
(SimpleEventListener::handleEvent):
(WinLauncherWebHost::updateAddressBar):
(WinLauncherWebHost::didFailProvisionalLoadWithError):
(WinLauncherWebHost::QueryInterface):
(WinLauncherWebHost::AddRef):
(WinLauncherWebHost::Release):
(WinLauncherWebHost::didFinishLoadForFrame):
* WinLauncher/WinLauncherWebHost.h: Copied from WinLauncher/WinLauncher.h.
Moved WinLauncherWebHost implementation from WinLauncher.cpp into
its own set of files.
(WinLauncherWebHost::WinLauncherWebHost):
(WinLauncherWebHost::didStartProvisionalLoadForFrame):
(WinLauncherWebHost::didReceiveServerRedirectForProvisionalLoadForFrame):
(WinLauncherWebHost::didCommitLoadForFrame):
(WinLauncherWebHost::didReceiveTitle):
(WinLauncherWebHost::didChangeIcons):
(WinLauncherWebHost::didReceiveIcon):
(WinLauncherWebHost::didFailLoadWithError):
(WinLauncherWebHost::didChangeLocationWithinPageForFrame):
(WinLauncherWebHost::willPerformClientRedirectToURL):
(WinLauncherWebHost::didCancelClientRedirectForFrame):
(WinLauncherWebHost::willCloseFrame):
(WinLauncherWebHost::windowScriptObjectAvailable):
(WinLauncherWebHost::didClearWindowObject):
* WinLauncher/WinMain.cpp: Added. This consists of code from
WinLauncher that is unique to the WinLauncher utility, and is
not part of the WinLauncher class.
(wWinMain):
(MyRegisterClass):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWinLauncherDOMDefaultImplh">trunk/Tools/WinLauncher/DOMDefaultImpl.h</a></li>
<li><a href="#trunkToolsWinLauncherWinLaunchercpp">trunk/Tools/WinLauncher/WinLauncher.cpp</a></li>
<li><a href="#trunkToolsWinLauncherWinLaunchervcxprojWinLauncherLibvcxproj">trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj</a></li>
<li><a href="#trunkToolsWinLauncherWinLaunchervcxprojWinLauncherLibvcxprojfilters">trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters</a></li>
<li><a href="#trunkToolsWinLauncherWinLauncherReplaceh">trunk/Tools/WinLauncher/WinLauncherReplace.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsWinLauncherCommoncpp">trunk/Tools/WinLauncher/Common.cpp</a></li>
<li><a href="#trunkToolsWinLauncherDOMDefaultImplcpp">trunk/Tools/WinLauncher/DOMDefaultImpl.cpp</a></li>
<li><a href="#trunkToolsWinLauncherWinLauncherWebHostcpp">trunk/Tools/WinLauncher/WinLauncherWebHost.cpp</a></li>
<li><a href="#trunkToolsWinLauncherWinLauncherWebHosth">trunk/Tools/WinLauncher/WinLauncherWebHost.h</a></li>
<li><a href="#trunkToolsWinLauncherWinMaincpp">trunk/Tools/WinLauncher/WinMain.cpp</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkToolsWinLauncherWinLauncherh">trunk/Tools/WinLauncher/WinLauncher.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/ChangeLog        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -1,3 +1,154 @@
</span><ins>+2014-06-23 Brent Fulgham <bfulgham@apple.com>
+
+ [Win] Clean up and refactor WinLauncher
+ https://bugs.webkit.org/show_bug.cgi?id=134209
+
+ Reviewed by Tim Horton.
+
+ Make WinLauncher a class, and move all non-class driver functions
+ into "Common.cpp" and "WinMain.cpp". These files are distinct
+ to allow some internal tools to reuse the code in 'Common'.
+
+ * WinLauncher/Common.cpp: Added. Consists of code moved from
+ 'WinLauncher.cpp' that can be reused for other tools.
+ (subclassForLayeredWindow):
+ (computeFullDesktopFrame):
+ (DllMain):
+ (getAppDataFolder):
+ (setCacheFolder):
+ (createCrashReport):
+ (AbortProc):
+ (getPrinterDC):
+ (initDocStruct):
+ (PrintView):
+ (ToggleMenuItem):
+ (WndProc):
+ (EditProc):
+ (BackButtonProc):
+ (ForwardButtonProc):
+ (About):
+ (loadURL):
+ (dllLauncherEntryPoint):
+ * WinLauncher/DOMDefaultImpl.cpp: Copied from WinLauncher/DOMDefaultImpl.h.
+ (DOMEventListener::Release):
+ (WebScriptObject::WebScriptObject): Deleted.
+ (WebScriptObject::~WebScriptObject): Deleted.
+ (WebScriptObject::throwException): Deleted.
+ (WebScriptObject::callWebScriptMethod): Deleted.
+ (WebScriptObject::evaluateWebScript): Deleted.
+ (WebScriptObject::removeWebScriptKey): Deleted.
+ (WebScriptObject::stringRepresentation): Deleted.
+ (WebScriptObject::webScriptValueAtIndex): Deleted.
+ (WebScriptObject::setWebScriptValueAtIndex): Deleted.
+ (WebScriptObject::setException): Deleted.
+ (DOMEventListener::throwException): Deleted.
+ (DOMEventListener::callWebScriptMethod): Deleted.
+ (DOMEventListener::evaluateWebScript): Deleted.
+ (DOMEventListener::removeWebScriptKey): Deleted.
+ (DOMEventListener::stringRepresentation): Deleted.
+ (DOMEventListener::webScriptValueAtIndex): Deleted.
+ (DOMEventListener::setWebScriptValueAtIndex): Deleted.
+ (DOMEventListener::setException): Deleted.
+ (DOMEventListener::handleEvent): Deleted.
+ * WinLauncher/DOMDefaultImpl.h:
+ (WebScriptObject::QueryInterface): Deleted.
+ (WebScriptObject::AddRef): Deleted.
+ (WebScriptObject::Release): Deleted.
+ (DOMObject::QueryInterface): Deleted.
+ (DOMEventListener::QueryInterface): Deleted.
+ (DOMEventListener::AddRef): Deleted.
+ (DOMEventListener::Release): Deleted.
+ * WinLauncher/WinLauncher.cpp: Converted stand-alone implementation
+ into a C++ class and removed WinAPI code.
+ (WinLauncher::WinLauncher):
+ (WinLauncher::init):
+ (WinLauncher::prepareViews):
+ (WinLauncher::setFrameLoadDelegate):
+ (WinLauncher::setUIDelegate):
+ (WinLauncher::setAccessibilityDelegate):
+ (WinLauncher::mainFrame):
+ (WinLauncher::seedInitialDefaultPreferences):
+ (WinLauncher::setToDefaultPreferences):
+ (updateMenuItemForHistoryItem):
+ (WinLauncher::showLastVisitedSites):
+ (WinLauncher::launchInspector):
+ (WinLauncher::navigateForwardOrBackward):
+ (WinLauncher::navigateToHistory):
+ (WinLauncher::goBack):
+ (WinLauncher::goForward):
+ (WinLauncher::loadURL):
+ (shouldUseFullDesktop): Deleted.
+ (SimpleEventListener::SimpleEventListener): Deleted.
+ (SimpleEventListener::handleEvent): Deleted.
+ (WinLauncherWebHost::updateAddressBar): Deleted.
+ (WinLauncherWebHost::didFailProvisionalLoadWithError): Deleted.
+ (WinLauncherWebHost::QueryInterface): Deleted.
+ (WinLauncherWebHost::AddRef): Deleted.
+ (WinLauncherWebHost::Release): Deleted.
+ (showLastVisitedSites): Deleted.
+ (WinLauncherWebHost::didFinishLoadForFrame): Deleted.
+ (resizeSubViews): Deleted.
+ (subclassForLayeredWindow): Deleted.
+ (computeFullDesktopFrame): Deleted.
+ (DllMain): Deleted.
+ (getAppDataFolder): Deleted.
+ (setToDefaultPreferences): Deleted.
+ (setCacheFolder): Deleted.
+ (createCrashReport): Deleted.
+ (wWinMain): Deleted.
+ (MyRegisterClass): Deleted.
+ (AbortProc): Deleted.
+ (getPrinterDC): Deleted.
+ (initDocStruct): Deleted.
+ (PrintView): Deleted.
+ (ToggleMenuItem): Deleted.
+ (LaunchInspector): Deleted.
+ (NavigateForwardOrBackward): Deleted.
+ (NavigateToHistory): Deleted.
+ (WndProc): Deleted.
+ (EditProc): Deleted.
+ (BackButtonProc): Deleted.
+ (ForwardButtonProc): Deleted.
+ (About): Deleted.
+ (loadURL): Deleted.
+ (dllLauncherEntryPoint): Deleted.
+ * WinLauncher/WinLauncher.h: Removed.
+ * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
+ * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
+ * WinLauncher/WinLauncherReplace.h:
+ (processCrashReport):
+ * WinLauncher/WinLauncherWebHost.cpp: Added.
+ (SimpleEventListener::SimpleEventListener):
+ (SimpleEventListener::handleEvent):
+ (WinLauncherWebHost::updateAddressBar):
+ (WinLauncherWebHost::didFailProvisionalLoadWithError):
+ (WinLauncherWebHost::QueryInterface):
+ (WinLauncherWebHost::AddRef):
+ (WinLauncherWebHost::Release):
+ (WinLauncherWebHost::didFinishLoadForFrame):
+ * WinLauncher/WinLauncherWebHost.h: Copied from WinLauncher/WinLauncher.h.
+ Moved WinLauncherWebHost implementation from WinLauncher.cpp into
+ its own set of files.
+ (WinLauncherWebHost::WinLauncherWebHost):
+ (WinLauncherWebHost::didStartProvisionalLoadForFrame):
+ (WinLauncherWebHost::didReceiveServerRedirectForProvisionalLoadForFrame):
+ (WinLauncherWebHost::didCommitLoadForFrame):
+ (WinLauncherWebHost::didReceiveTitle):
+ (WinLauncherWebHost::didChangeIcons):
+ (WinLauncherWebHost::didReceiveIcon):
+ (WinLauncherWebHost::didFailLoadWithError):
+ (WinLauncherWebHost::didChangeLocationWithinPageForFrame):
+ (WinLauncherWebHost::willPerformClientRedirectToURL):
+ (WinLauncherWebHost::didCancelClientRedirectForFrame):
+ (WinLauncherWebHost::willCloseFrame):
+ (WinLauncherWebHost::windowScriptObjectAvailable):
+ (WinLauncherWebHost::didClearWindowObject):
+ * WinLauncher/WinMain.cpp: Added. This consists of code from
+ WinLauncher that is unique to the WinLauncher utility, and is
+ not part of the WinLauncher class.
+ (wWinMain):
+ (MyRegisterClass):
+
</ins><span class="cx"> 2014-06-23 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Enable the Web Inspector in MiniBrowser
</span></span></pre></div>
<a id="trunkToolsWinLauncherCommoncpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/WinLauncher/Common.cpp (0 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/Common.cpp         (rev 0)
+++ trunk/Tools/WinLauncher/Common.cpp        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -0,0 +1,490 @@
</span><ins>+/*
+ * 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);
+}
</ins></span></pre></div>
<a id="trunkToolsWinLauncherDOMDefaultImplcppfromrev170299trunkToolsWinLauncherDOMDefaultImplh"></a>
<div class="copfile"><h4>Copied: trunk/Tools/WinLauncher/DOMDefaultImpl.cpp (from rev 170299, trunk/Tools/WinLauncher/DOMDefaultImpl.h) (0 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/DOMDefaultImpl.cpp         (rev 0)
+++ trunk/Tools/WinLauncher/DOMDefaultImpl.cpp        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+/*
+ * 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();
+}
</ins></span></pre></div>
<a id="trunkToolsWinLauncherDOMDefaultImplh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/DOMDefaultImpl.h (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/DOMDefaultImpl.h        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/DOMDefaultImpl.h        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -87,70 +87,4 @@
</span><span class="cx"> virtual HRESULT STDMETHODCALLTYPE handleEvent(IDOMEvent*) { return E_NOTIMPL; }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-// 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();
-}
-
</del><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsWinLauncherWinLaunchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncher.cpp        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2008, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved.
</span><span class="cx"> * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
</span><span class="cx"> * Copyright (C) 2013 Alex Christensen. All rights reserved.
</span><span class="lines">@@ -29,9 +29,7 @@
</span><span class="cx"> #include "stdafx.h"
</span><span class="cx"> #include "WinLauncher.h"
</span><span class="cx">
</span><del>-#include "AccessibilityDelegate.h"
</del><span class="cx"> #include "DOMDefaultImpl.h"
</span><del>-#include "PrintWebUIDelegate.h"
</del><span class="cx"> #include "WinLauncherLibResource.h"
</span><span class="cx"> #include "WinLauncherReplace.h"
</span><span class="cx"> #include <WebKit/WebKitCOMAPI.h>
</span><span class="lines">@@ -42,191 +40,143 @@
</span><span class="cx"> #include <CoreFoundation/CFRunLoop.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if USE(GLIB)
-#include <glib.h>
-#endif
-
</del><span class="cx"> #include <algorithm>
</span><del>-#include <assert.h>
-#include <comip.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#include <comutil.h>
-#include <dbghelp.h>
</del><ins>+#include <cassert>
</ins><span class="cx"> #include <functional>
</span><del>-#include <objbase.h>
-#include <shellapi.h>
-#include <shlobj.h>
-#include <shlwapi.h>
</del><ins>+#include <memory>
</ins><span class="cx"> #include <string>
</span><span class="cx"> #include <vector>
</span><del>-#include <wininet.h>
</del><span class="cx">
</span><del>-#define MAX_LOADSTRING 100
-#define URLBAR_HEIGHT 24
-#define CONTROLBUTTON_WIDTH 24
-
</del><span class="cx"> static const int maxHistorySize = 10;
</span><span class="cx">
</span><del>-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;
</del><span class="cx"> typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
</span><del>-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;
</del><span class="cx"> typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr;
</span><span class="cx">
</span><del>-// 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
</del><ins>+WinLauncher::WinLauncher(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView)
+ : m_hMainWnd(mainWnd)
+ , m_hURLBarWnd(urlBarWnd)
+ , m_useLayeredWebView(useLayeredWebView)
+{
+}
</ins><span class="cx">
</span><del>-// Support moving the transparent window
-POINT s_windowPosition = { 100, 100 };
-SIZE s_windowSize = { 800, 400 };
-bool s_usesLayeredWebView = false;
-bool s_fullDesktop = false;
</del><ins>+HRESULT WinLauncher::init()
+{
+ HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&m_webView.GetInterfacePtr()));
+ if (FAILED(hr))
+ return hr;
</ins><span class="cx">
</span><del>-// 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);
</del><ins>+ hr = m_webView->QueryInterface(IID_IWebViewPrivate, reinterpret_cast<void**>(&m_webViewPrivate.GetInterfacePtr()));
+ if (FAILED(hr))
+ return hr;
</ins><span class="cx">
</span><del>-static void loadURL(BSTR urlBStr);
</del><ins>+ hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(m_webHistory), reinterpret_cast<void**>(&m_webHistory.GetInterfacePtr()));
</ins><span class="cx">
</span><del>-static bool usesLayeredWebView()
-{
- return s_usesLayeredWebView;
</del><ins>+ return hr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static bool shouldUseFullDesktop()
</del><ins>+HRESULT WinLauncher::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL, HWND& viewHwnd)
</ins><span class="cx"> {
</span><del>- return s_fullDesktop;
-}
</del><ins>+ if (!m_webView)
+ return E_FAIL;
</ins><span class="cx">
</span><del>-class SimpleEventListener : public DOMEventListener {
-public:
- SimpleEventListener(LPWSTR type)
- {
- wcsncpy_s(m_eventType, 100, type, 100);
- m_eventType[99] = 0;
- }
</del><ins>+ HRESULT hr = m_webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(mainWnd));
+ if (FAILED(hr))
+ return hr;
</ins><span class="cx">
</span><del>- 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;
- }
</del><ins>+ hr = m_webView->initWithFrame(clientRect, 0, 0);
+ if (FAILED(hr))
+ return hr;
</ins><span class="cx">
</span><del>-private:
- wchar_t m_eventType[100];
-};
</del><ins>+ if (!requestedURL) {
+ IWebFramePtr frame;
+ hr = m_webView->mainFrame(&frame.GetInterfacePtr());
+ if (FAILED(hr))
+ return hr;
</ins><span class="cx">
</span><del>-typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr;
</del><ins>+ frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
+ }
</ins><span class="cx">
</span><del>-HRESULT WinLauncherWebHost::updateAddressBar(IWebView* webView)
-{
- IWebFramePtr mainFrame;
- HRESULT hr = webView->mainFrame(&mainFrame.GetInterfacePtr());
</del><ins>+ hr = m_webViewPrivate->setTransparent(m_useLayeredWebView);
</ins><span class="cx"> if (FAILED(hr))
</span><del>- return 0;
</del><ins>+ return hr;
</ins><span class="cx">
</span><del>- 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());
</del><ins>+ hr = m_webViewPrivate->setUsesLayeredWindow(m_useLayeredWebView);
</ins><span class="cx"> if (FAILED(hr))
</span><del>- return 0;
</del><ins>+ return hr;
</ins><span class="cx">
</span><del>- ::SendMessage(hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(frameURL.GetBSTR()));
</del><ins>+ hr = m_webViewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewHwnd));
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+ return hr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-HRESULT WinLauncherWebHost::didFailProvisionalLoadWithError(IWebView*, IWebError *error, IWebFrame*)
</del><ins>+HRESULT WinLauncher::setFrameLoadDelegate(IWebFrameLoadDelegate* frameLoadDelegate)
</ins><span class="cx"> {
</span><del>- _bstr_t errorDescription;
- HRESULT hr = error->localizedDescription(errorDescription.GetAddress());
- if (FAILED(hr))
- errorDescription = L"Failed to load page and to localize error description.";
</del><ins>+ m_frameLoadDelegate = frameLoadDelegate;
+ return m_webView->setFrameLoadDelegate(frameLoadDelegate);
+}
</ins><span class="cx">
</span><del>- if (_wcsicmp(errorDescription, L"Cancelled"))
- ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
-
- return S_OK;
</del><ins>+HRESULT WinLauncher::setUIDelegate(IWebUIDelegate* uiDelegate)
+{
+ m_uiDelegate = uiDelegate;
+ return m_webView->setUIDelegate(uiDelegate);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-HRESULT STDMETHODCALLTYPE WinLauncherWebHost::QueryInterface(REFIID riid, void** ppvObject)
</del><ins>+HRESULT WinLauncher::setAccessibilityDelegate(IAccessibilityDelegate* accessibilityDelegate)
</ins><span class="cx"> {
</span><del>- *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;
</del><ins>+ m_accessibilityDelegate = accessibilityDelegate;
+ return m_webView->setAccessibilityDelegate(accessibilityDelegate);
+}
</ins><span class="cx">
</span><del>- AddRef();
- return S_OK;
</del><ins>+IWebFramePtr WinLauncher::mainFrame()
+{
+ IWebFramePtr framePtr;
+ m_webView->mainFrame(&framePtr.GetInterfacePtr());
+ return framePtr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-ULONG STDMETHODCALLTYPE WinLauncherWebHost::AddRef(void)
</del><ins>+bool WinLauncher::seedInitialDefaultPreferences()
</ins><span class="cx"> {
</span><del>- return ++m_refCount;
</del><ins>+ 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;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-ULONG STDMETHODCALLTYPE WinLauncherWebHost::Release(void)
</del><ins>+bool WinLauncher::setToDefaultPreferences()
</ins><span class="cx"> {
</span><del>- ULONG newRef = --m_refCount;
- if (!newRef)
- delete(this);
</del><ins>+ HRESULT hr = m_standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&m_prefsPrivate.GetInterfacePtr()));
+ if (!SUCCEEDED(hr))
+ return false;
</ins><span class="cx">
</span><del>- return newRef;
</del><ins>+#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);
+
+ return true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void updateMenuItemForHistoryItem(HMENU menu, IWebHistoryItem& historyItem, int currentHistoryItem)
</span><span class="cx"> {
</span><span class="cx"> UINT menuID = IDM_HISTORY_LINK0 + currentHistoryItem;
</span><span class="cx">
</span><del>- MENUITEMINFO menuItemInfo = {0};
</del><ins>+ MENUITEMINFO menuItemInfo = { 0 };
</ins><span class="cx"> menuItemInfo.cbSize = sizeof(MENUITEMINFO);
</span><span class="cx"> menuItemInfo.fMask = MIIM_TYPE;
</span><span class="cx"> menuItemInfo.fType = MFT_STRING;
</span><span class="lines">@@ -239,9 +189,9 @@
</span><span class="cx"> ::EnableMenuItem(menu, menuID, MF_BYCOMMAND | MF_ENABLED);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void showLastVisitedSites(IWebView& webView)
</del><ins>+void WinLauncher::showLastVisitedSites(IWebView& webView)
</ins><span class="cx"> {
</span><del>- HMENU menu = ::GetMenu(hMainWnd);
</del><ins>+ HMENU menu = ::GetMenu(m_hMainWnd);
</ins><span class="cx">
</span><span class="cx"> _com_ptr_t<_com_IIID<IWebBackForwardList, &__uuidof(IWebBackForwardList)>> backForwardList;
</span><span class="cx"> HRESULT hr = webView.backForwardList(&backForwardList.GetInterfacePtr());
</span><span class="lines">@@ -274,12 +224,12 @@
</span><span class="cx"> if (FAILED(hr))
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- hr = gWebHistory->addItems(1, &currentItem.GetInterfacePtr());
</del><ins>+ hr = m_webHistory->addItems(1, &currentItem.GetInterfacePtr());
</ins><span class="cx"> if (FAILED(hr))
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> _com_ptr_t<_com_IIID<IWebHistoryPrivate, &__uuidof(IWebHistoryPrivate)>> webHistory;
</span><del>- hr = gWebHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr()));
</del><ins>+ hr = m_webHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr()));
</ins><span class="cx"> if (FAILED(hr))
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -288,7 +238,7 @@
</span><span class="cx"> if (FAILED(hr))
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- gHistoryItems.resize(totalListCount);
</del><ins>+ m_historyItems.resize(totalListCount);
</ins><span class="cx">
</span><span class="cx"> std::vector<IWebHistoryItem*> historyToLoad(totalListCount);
</span><span class="cx"> hr = webHistory->allItems(&totalListCount, historyToLoad.data());
</span><span class="lines">@@ -296,8 +246,8 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> size_t i = 0;
</span><del>- for (auto cur = historyToLoad.begin(); cur != historyToLoad.end(); ++cur) {
- gHistoryItems[i].Attach(*cur);
</del><ins>+ for (auto& cur : historyToLoad) {
+ m_historyItems[i].Attach(cur);
</ins><span class="cx"> ++i;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -307,7 +257,7 @@
</span><span class="cx">
</span><span class="cx"> int currentHistoryItem = 0;
</span><span class="cx"> for (int i = 0; i < totalListCount; ++i) {
</span><del>- updateMenuItemForHistoryItem(menu, *(gHistoryItems[allItemsOffset + currentHistoryItem]), currentHistoryItem);
</del><ins>+ updateMenuItemForHistoryItem(menu, *(m_historyItems[allItemsOffset + currentHistoryItem]), currentHistoryItem);
</ins><span class="cx"> ++currentHistoryItem;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -316,737 +266,96 @@
</span><span class="cx"> ::EnableMenuItem(menu, IDM_HISTORY_LINK0 + i, MF_BYCOMMAND | MF_DISABLED);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+void WinLauncher::launchInspector()
</ins><span class="cx"> {
</span><del>- 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)
</del><ins>+ if (!m_webViewPrivate)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- 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))
</del><ins>+ if (!SUCCEEDED(m_webViewPrivate->inspector(&m_inspector.GetInterfacePtr())))
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- s_windowPosition.x = 0;
- s_windowPosition.y = 0;
- s_windowSize.cx = desktop.right - desktop.left;
- s_windowSize.cy = desktop.bottom - desktop.top;
</del><ins>+ m_inspector->show();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, LPVOID)
</del><ins>+void WinLauncher::navigateForwardOrBackward(HWND hWnd, UINT menuID)
</ins><span class="cx"> {
</span><del>- 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 createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
-{
- _bstr_t directory;
-
- if (!getAppDataFolder(directory))
</del><ins>+ if (!m_webView)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- 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;
-
</del><span class="cx"> BOOL wentBackOrForward = FALSE;
</span><span class="cx"> if (IDM_HISTORY_FORWARD == menuID)
</span><del>- gWebView->goForward(&wentBackOrForward);
</del><ins>+ m_webView->goForward(&wentBackOrForward);
</ins><span class="cx"> else
</span><del>- gWebView->goBack(&wentBackOrForward);
</del><ins>+ m_webView->goBack(&wentBackOrForward);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static void NavigateToHistory(HWND hWnd, UINT menuID)
</del><ins>+void WinLauncher::navigateToHistory(HWND hWnd, UINT menuID)
</ins><span class="cx"> {
</span><del>- if (!gWebView)
</del><ins>+ if (!m_webView)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> int historyEntry = menuID - IDM_HISTORY_LINK0;
</span><del>- if (historyEntry > gHistoryItems.size())
</del><ins>+ if (historyEntry > m_historyItems.size())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- IWebHistoryItemPtr desiredHistoryItem = gHistoryItems[historyEntry];
</del><ins>+ IWebHistoryItemPtr desiredHistoryItem = m_historyItems[historyEntry];
</ins><span class="cx"> if (!desiredHistoryItem)
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> BOOL succeeded = FALSE;
</span><del>- gWebView->goToBackForwardItem(desiredHistoryItem, &succeeded);
</del><ins>+ m_webView->goToBackForwardItem(desiredHistoryItem, &succeeded);
</ins><span class="cx">
</span><span class="cx"> _bstr_t frameURL;
</span><span class="cx"> desiredHistoryItem->URLString(frameURL.GetAddress());
</span><span class="cx">
</span><del>- ::SendMessage(hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());
</del><ins>+ ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static const int dragBarHeight = 30;
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
</del><ins>+bool WinLauncher::goBack()
</ins><span class="cx"> {
</span><del>- 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)
-{
</del><span class="cx"> BOOL wentBack = FALSE;
</span><del>- switch (message) {
- case WM_LBUTTONUP:
- gWebView->goBack(&wentBack);
- default:
- return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam);
- }
</del><ins>+ m_webView->goBack(&wentBack);
+ return wentBack;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-LRESULT CALLBACK ForwardButtonProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
</del><ins>+bool WinLauncher::goForward()
</ins><span class="cx"> {
</span><span class="cx"> BOOL wentForward = FALSE;
</span><del>- switch (message) {
- case WM_LBUTTONUP:
- gWebView->goForward(&wentForward);
- default:
- return CallWindowProc(DefButtonProc, hDlg, message, wParam, lParam);
- }
</del><ins>+ m_webView->goForward(&wentForward);
+ return wentForward;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// Message handler for about box.
-INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
</del><ins>+HRESULT WinLauncher::loadURL(const BSTR& passedURL)
</ins><span class="cx"> {
</span><del>- 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)
-{
</del><span class="cx"> _bstr_t urlBStr(passedURL);
</span><span class="cx"> if (!!urlBStr && (::PathFileExists(urlBStr) || ::PathIsUNC(urlBStr))) {
</span><span class="cx"> TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
</span><del>- DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
</del><ins>+ DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]);
</ins><span class="cx">
</span><span class="cx"> if (SUCCEEDED(::UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0)))
</span><span class="cx"> urlBStr = fileURL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> IWebFramePtr frame;
</span><del>- HRESULT hr = gWebView->mainFrame(&frame.GetInterfacePtr());
</del><ins>+ HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr());
</ins><span class="cx"> if (FAILED(hr))
</span><del>- return;
</del><ins>+ return hr;
</ins><span class="cx">
</span><span class="cx"> IWebMutableURLRequestPtr request;
</span><span class="cx"> hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&request);
</span><span class="cx"> if (FAILED(hr))
</span><del>- return;
</del><ins>+ return hr;
</ins><span class="cx">
</span><span class="cx"> hr = request->initWithURL(wcsstr(static_cast<wchar_t*>(urlBStr), L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60);
</span><span class="cx"> if (FAILED(hr))
</span><del>- return;
</del><ins>+ return hr;
</ins><span class="cx">
</span><span class="cx"> _bstr_t methodBStr(L"GET");
</span><span class="cx"> hr = request->setHTTPMethod(methodBStr);
</span><span class="cx"> if (FAILED(hr))
</span><del>- return;
</del><ins>+ return hr;
</ins><span class="cx">
</span><span class="cx"> hr = frame->loadRequest(request);
</span><del>- if (FAILED(hr))
- return;
</del><span class="cx">
</span><del>- SetFocus(gViewWindow);
</del><ins>+ return hr;
</ins><span class="cx"> }
</span><del>-
-extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
-{
- return wWinMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
-}
</del></span></pre></div>
<a id="trunkToolsWinLauncherWinLauncherh"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/WinLauncher/WinLauncher.h (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncher.h        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/WinLauncher.h        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -1,119 +0,0 @@
</span><del>-/*
- * 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;
-};
</del></span></pre></div>
<a id="trunkToolsWinLauncherWinLaunchervcxprojWinLauncherLibvcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -203,6 +203,15 @@
</span><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClCompile Include="..\AccessibilityDelegate.cpp" />
</span><ins>+ <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" />
</ins><span class="cx"> <ClCompile Include="..\PrintWebUIDelegate.cpp" />
</span><span class="cx"> <ClCompile Include="..\stdafx.cpp">
</span><span class="cx"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</span><span class="lines">@@ -219,6 +228,8 @@
</span><span class="cx"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">Create</PrecompiledHeader>
</span><span class="cx"> </ClCompile>
</span><span class="cx"> <ClCompile Include="..\WinLauncher.cpp" />
</span><ins>+ <ClCompile Include="..\WinLauncherWebHost.cpp" />
+ <ClCompile Include="..\WinMain.cpp" />
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClInclude Include="..\AccessibilityDelegate.h" />
</span><span class="lines">@@ -227,6 +238,7 @@
</span><span class="cx"> <ClInclude Include="..\stdafx.h" />
</span><span class="cx"> <ClInclude Include="..\WinLauncher.h" />
</span><span class="cx"> <ClInclude Include="..\WinLauncherReplace.h" />
</span><ins>+ <ClInclude Include="..\WinLauncherWebHost.h" />
</ins><span class="cx"> <ClInclude Include="WinLauncherLibResource.h" />
</span><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span></span></pre></div>
<a id="trunkToolsWinLauncherWinLaunchervcxprojWinLauncherLibvcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -37,6 +37,18 @@
</span><span class="cx"> <ClCompile Include="..\AccessibilityDelegate.cpp">
</span><span class="cx"> <Filter>Source Files</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <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>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClInclude Include="..\DOMDefaultImpl.h">
</span><span class="lines">@@ -60,6 +72,9 @@
</span><span class="cx"> <ClInclude Include="..\WinLauncherReplace.h">
</span><span class="cx"> <Filter>Header Files</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\WinLauncherWebHost.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ResourceCompile Include="WinLauncherLib.rc">
</span></span></pre></div>
<a id="trunkToolsWinLauncherWinLauncherReplaceh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/WinLauncherReplace.h (170338 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncherReplace.h        2014-06-24 00:49:59 UTC (rev 170338)
+++ trunk/Tools/WinLauncher/WinLauncherReplace.h        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -22,8 +22,13 @@
</span><span class="cx"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#ifndef WinLauncherReplace_h
+#define WinLauncherReplace_h
+
</ins><span class="cx"> // This file is to make it easier for users to manage changes to the internals of WinLauncher
</span><span class="cx">
</span><del>-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>";
</del><ins>+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>";
</ins><span class="cx">
</span><del>-void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
</del><ins>+static void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
+
+#endif
</ins></span></pre></div>
<a id="trunkToolsWinLauncherWinLauncherWebHostcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/WinLauncher/WinLauncherWebHost.cpp (0 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncherWebHost.cpp         (rev 0)
+++ trunk/Tools/WinLauncher/WinLauncherWebHost.cpp        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -0,0 +1,160 @@
</span><ins>+/*
+ * 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;
+}
</ins></span></pre></div>
<a id="trunkToolsWinLauncherWinLauncherWebHosthfromrev170299trunkToolsWinLauncherWinLauncherh"></a>
<div class="copfile"><h4>Copied: trunk/Tools/WinLauncher/WinLauncherWebHost.h (from rev 170299, trunk/Tools/WinLauncher/WinLauncher.h) (0 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinLauncherWebHost.h         (rev 0)
+++ trunk/Tools/WinLauncher/WinLauncherWebHost.h        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * 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;
+};
</ins></span></pre></div>
<a id="trunkToolsWinLauncherWinMaincpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/WinLauncher/WinMain.cpp (0 => 170339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WinLauncher/WinMain.cpp         (rev 0)
+++ trunk/Tools/WinLauncher/WinMain.cpp        2014-06-24 00:51:58 UTC (rev 170339)
</span><span class="lines">@@ -0,0 +1,203 @@
</span><ins>+/*
+ * 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 "Common.cpp"
+#include "WinLauncherLibResource.h"
+#include "WinLauncherWebHost.h"
+
+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);
+}
</ins></span></pre>
</div>
</div>
</body>
</html>