Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4262)

Unified Diff: chrome/installer/gcapi/gcapi.cc

Issue 101008: Adds a new API for launching Chrome at a given size and location. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/gcapi/gcapi.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/gcapi/gcapi.cc
===================================================================
--- chrome/installer/gcapi/gcapi.cc (revision 14735)
+++ chrome/installer/gcapi/gcapi.cc (working copy)
@@ -408,3 +408,42 @@
::CoUninitialize();
return ret;
}
+
+#pragma comment(linker, "/EXPORT:LaunchGoogleChromeWithDimensions=_LaunchGoogleChromeWithDimensions@16,PRIVATE")
+DLLEXPORT BOOL __stdcall LaunchGoogleChromeWithDimensions(int x,
+ int y,
+ int width,
+ int height) {
+ if (!LaunchGoogleChrome())
+ return false;
+
+ HWND handle = NULL;
+ int seconds_elapsed = 0;
+
+ // Chrome may have been launched, but the window may not have appeared
+ // yet. Wait for it to appear for 10 seconds, but exit if it takes longer
+ // than that.
+ while (!handle && seconds_elapsed < 10) {
+ handle = FindWindowEx(NULL, handle, L"Chrome_WidgetWin_0", NULL);
+ if (!handle) {
+ Sleep(1000);
+ seconds_elapsed++;
+ }
+ }
+
+ if(!handle)
+ return false;
+
+ // At this point, there are several top-level Chrome windows
+ // but we only want the window that has child windows.
+
+ // This loop iterates through all of the top-level Windows named
+ // Chrome_WidgetWin_0, and looks for the first one with any children.
+ while (handle && !FindWindowEx(handle, NULL, L"Chrome_WidgetWin_0", NULL)) {
+ // Get the next top-level Chrome window.
+ handle = FindWindowEx(NULL, handle, L"Chrome_WidgetWin_0", NULL);
+ }
+
+ return (handle &&
+ SetWindowPos(handle, 0, x, y, width, height, SWP_NOZORDER));
+}
« no previous file with comments | « chrome/installer/gcapi/gcapi.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698