summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorgwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 22:37:51 +0000
committergwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 22:37:51 +0000
commit6d62997c876a6313826dc8904aff75e80ac09104 (patch)
treef22cf315c7e7af7a501ca76017b00c3d14760a8d /chrome/installer
parent416dc5eb378dcd33f97cc4b58c8d05e99ede7154 (diff)
downloadchromium_src-6d62997c876a6313826dc8904aff75e80ac09104.zip
chromium_src-6d62997c876a6313826dc8904aff75e80ac09104.tar.gz
chromium_src-6d62997c876a6313826dc8904aff75e80ac09104.tar.bz2
Adds a new API for launching Chrome at a given size and location.
This only works with post-1.0 Chrome, as it refers to the new Window names. R=kuchhal Review URL: http://codereview.chromium.org/101008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/gcapi/gcapi.cc39
-rw-r--r--chrome/installer/gcapi/gcapi.h12
2 files changed, 51 insertions, 0 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index 0ba5d4c..43498b9 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.cc
@@ -408,3 +408,42 @@ DLLEXPORT BOOL __stdcall LaunchGoogleChrome() {
::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));
+}
diff --git a/chrome/installer/gcapi/gcapi.h b/chrome/installer/gcapi/gcapi.h
index 4d45d30..8c6f74a 100644
--- a/chrome/installer/gcapi/gcapi.h
+++ b/chrome/installer/gcapi/gcapi.h
@@ -33,9 +33,21 @@ DLLEXPORT BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag,
// you called CoInitialize, call CoUninitialize before calling this function).
DLLEXPORT BOOL __stdcall LaunchGoogleChrome();
+// This function launches Google Chrome after a successful install at the
+// given x,y coordinates with size height,length. Make
+// sure COM library is NOT initalized before you call this function (so if
+// you called CoInitialize, call CoUninitialize before calling this function).
+// This call is synchronous, meaning it waits for Chrome to launch and appear
+// to resize it before returning.
+DLLEXPORT BOOL __stdcall LaunchGoogleChromeWithDimensions(int x,
+ int y,
+ int width,
+ int height);
+
// Funtion pointer type declarations to use with GetProcAddress.
typedef BOOL (__stdcall * GCCC_CompatibilityCheck)(BOOL, DWORD *);
typedef BOOL (__stdcall * GCCC_LaunchGC)(HANDLE *);
+typedef BOOL (__stdcall * GCCC_LaunchGCWithDimensions)(int, int, int, int);
} // extern "C"
#endif // # CHROME_INSTALLER_GCAPI_GCAPI_H_