Title: [89685] trunk/Source/WebKit2
Revision
89685
Author
[email protected]
Date
2011-06-24 11:09:14 -0700 (Fri, 24 Jun 2011)

Log Message

Make the web process pause dialog look better on Vista/7 and robust against executable renames

Fixes <http://webkit.org/b/63335> Web process pause dialog looks bad on Vista/7

Reviewed by Brian Weinstein.

* WebProcess/WebKitMain.cpp:
(pauseProcessIfNeeded): Moved code to show the pause dialog here from WebKitMain. We now
fetch the executable name using ::GetModuleFileNameW instead of hard-coding it. The string
we pass to ::MessageBoxW no longer has embedded newlines, which improves its appearance on
Vista/7 (which were doing their own wrapping in addition to our newlines). Appearance is
different but fine on XP. Note that the message text now contains the "[_debug].exe" suffix when
referring to the process; that is different from before but seems fine.
(WebKitMain): Call the new function.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (89684 => 89685)


--- trunk/Source/WebKit2/ChangeLog	2011-06-24 17:52:09 UTC (rev 89684)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-24 18:09:14 UTC (rev 89685)
@@ -1,3 +1,21 @@
+2011-06-24  Adam Roben  <[email protected]>
+
+        Make the web process pause dialog look better on Vista/7 and robust against executable
+        renames
+
+        Fixes <http://webkit.org/b/63335> Web process pause dialog looks bad on Vista/7
+
+        Reviewed by Brian Weinstein.
+
+        * WebProcess/WebKitMain.cpp:
+        (pauseProcessIfNeeded): Moved code to show the pause dialog here from WebKitMain. We now
+        fetch the executable name using ::GetModuleFileNameW instead of hard-coding it. The string
+        we pass to ::MessageBoxW no longer has embedded newlines, which improves its appearance on
+        Vista/7 (which were doing their own wrapping in addition to our newlines). Appearance is
+        different but fine on XP. Note that the message text now contains the "[_debug].exe" suffix when
+        referring to the process; that is different from before but seems fine.
+        (WebKitMain): Call the new function.
+
 2011-06-24  Dominic Cooney  <[email protected]>
 
         Reviewed by Dimitri Glazkov.

Modified: trunk/Source/WebKit2/WebProcess/WebKitMain.cpp (89684 => 89685)


--- trunk/Source/WebKit2/WebProcess/WebKitMain.cpp	2011-06-24 17:52:09 UTC (rev 89684)
+++ trunk/Source/WebKit2/WebProcess/WebKitMain.cpp	2011-06-24 18:09:14 UTC (rev 89685)
@@ -29,6 +29,7 @@
 #include "PluginProcessMain.h"
 #include "ProcessLauncher.h"
 #include "WebProcessMain.h"
+#include <shlwapi.h>
 #include <wtf/text/CString.h>
 
 #if PLATFORM(MAC)
@@ -74,12 +75,6 @@
 
 #elif PLATFORM(WIN)
 
-#ifndef DEBUG_ALL
-#define PROCESS_NAME L"WebKit2WebKitProcess.exe"
-#else
-#define PROCESS_NAME L"WebKit2WebProcess_debug.exe"
-#endif
-
 static void enableDataExecutionPrevention()
 {
     // Enable Data Execution prevention at runtime rather than via /NXCOMPAT
@@ -148,17 +143,36 @@
     FreeLibrary(lib);
 }
 
-extern "C" __declspec(dllexport) 
-int WebKitMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
+#ifndef NDEBUG
+static void pauseProcessIfNeeded(HMODULE module)
 {
-#ifndef NDEBUG
     // Show an alert when Ctrl-Alt-Shift is held down during launch to give the user time to attach a
     // debugger. This is useful for debugging problems that happen early in the web process's lifetime.
     const unsigned short highBitMaskShort = 0x8000;
-    if (getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH") || (::GetKeyState(VK_CONTROL) & highBitMaskShort) && (::GetKeyState(VK_MENU) & highBitMaskShort) && (::GetKeyState(VK_SHIFT) & highBitMaskShort))
-        ::MessageBoxW(0, L"You can now attach a debugger to " PROCESS_NAME L". You can use\nthe same debugger for WebKit2WebProcessand the UI process, if desired.\nClick OK when you are ready for WebKit2WebProcess to continue.", L"WebKit2WebProcess has launched", MB_OK | MB_ICONINFORMATION);
+    if (!getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH") && !(::GetKeyState(VK_CONTROL) & highBitMaskShort) && (::GetKeyState(VK_MENU) & highBitMaskShort) && (::GetKeyState(VK_SHIFT) & highBitMaskShort))
+        return;
+
+    wchar_t path[MAX_PATH];
+    DWORD length = ::GetModuleFileNameW(module, path, WTF_ARRAY_LENGTH(path));
+    if (!length || length == WTF_ARRAY_LENGTH(path))
+        return;
+
+    wchar_t* startOfFilename = ::PathFindFileNameW(path);
+    String filenameString(startOfFilename, length - (startOfFilename - path));
+
+    String message = L"You can now attach a debugger to " + filenameString + L". You can use the same debugger for " + filenameString + L" and the UI process, if desired. Click OK when you are ready for " + filenameString + L" to continue.";
+    String title = filenameString + L" has launched";
+    ::MessageBoxW(0, message.charactersWithNullTermination(), title.charactersWithNullTermination(), MB_OK | MB_ICONINFORMATION);
+}
 #endif
 
+extern "C" __declspec(dllexport) 
+int WebKitMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
+{
+#ifndef NDEBUG
+    pauseProcessIfNeeded(hInstance);
+#endif
+
     enableDataExecutionPrevention();
 
     enableTerminationOnHeapCorruption();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to