diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 01:21:48 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 01:21:48 +0000 |
commit | 82a200191df08bab26f78240af1883ca46b1942f (patch) | |
tree | 0ff39c52e8e86e0eff79f88d74d35bd003e8960e /chrome/test/automation/window_proxy.cc | |
parent | 58567187439fdcad4cf4fdc39a1d92668b7afbb8 (diff) | |
download | chromium_src-82a200191df08bab26f78240af1883ca46b1942f.zip chromium_src-82a200191df08bab26f78240af1883ca46b1942f.tar.gz chromium_src-82a200191df08bab26f78240af1883ca46b1942f.tar.bz2 |
Refactor automation wrappers. Move the methods from AutomationProxy to the appropriate classes.
Review URL: http://codereview.chromium.org/18335
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation/window_proxy.cc')
-rw-r--r-- | chrome/test/automation/window_proxy.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc index 986b41d2..1780956 100644 --- a/chrome/test/automation/window_proxy.cc +++ b/chrome/test/automation/window_proxy.cc @@ -160,3 +160,34 @@ bool WindowProxy::GetFocusedViewID(int* view_id) { return false; } + +BrowserProxy* WindowProxy::GetBrowser() { + return GetBrowserWithTimeout(INFINITE, NULL); +} + +BrowserProxy* WindowProxy::GetBrowserWithTimeout(uint32 timeout_ms, + bool* is_timeout) { + if (!is_valid()) + return false; + + IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( + new AutomationMsg_BrowserForWindowRequest(0, handle_), &response, + AutomationMsg_BrowserForWindowResponse::ID, timeout_ms, is_timeout); + if (!succeeded) + return NULL; + + scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. + int browser_handle = 0; + void* iter = NULL; + bool handle_ok; + succeeded = response->ReadBool(&iter, &handle_ok); + if (succeeded) + succeeded = response->ReadInt(&iter, &browser_handle); + + if (succeeded) { + return new BrowserProxy(sender_, tracker_, browser_handle); + } else { + return NULL; + } +} |