| Index: chrome/test/chromedriver/session_commands.cc
|
| diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc
|
| index 8e0f70722d4d66b168bde3c0d361a70069ca91d2..b196f6e6555ef231094cc579c26ceaac4d8f3556 100644
|
| --- a/chrome/test/chromedriver/session_commands.cc
|
| +++ b/chrome/test/chromedriver/session_commands.cc
|
| @@ -106,16 +106,16 @@ Status ExecuteGetWindowHandles(
|
| Session* session,
|
| const base::DictionaryValue& params,
|
| scoped_ptr<base::Value>* value) {
|
| - std::list<WebView*> web_views;
|
| - Status status = session->chrome->GetWebViews(&web_views);
|
| + std::list<std::string> web_view_ids;
|
| + Status status = session->chrome->GetWebViewIds(&web_view_ids);
|
| if (status.IsError())
|
| return status;
|
| - base::ListValue window_ids;
|
| - for (std::list<WebView*>::const_iterator it = web_views.begin();
|
| - it != web_views.end(); ++it) {
|
| - window_ids.AppendString(WebViewIdToWindowHandle((*it)->GetId()));
|
| + scoped_ptr<base::ListValue> window_ids(new base::ListValue());
|
| + for (std::list<std::string>::const_iterator it = web_view_ids.begin();
|
| + it != web_view_ids.end(); ++it) {
|
| + window_ids->AppendString(WebViewIdToWindowHandle(*it));
|
| }
|
| - value->reset(window_ids.DeepCopy());
|
| + value->reset(window_ids.release());
|
| return Status(kOk);
|
| }
|
|
|
| @@ -127,20 +127,19 @@ Status ExecuteSwitchToWindow(
|
| if (!params.GetString("name", &name) || name.empty())
|
| return Status(kUnknownError, "'name' must be a nonempty string");
|
|
|
| - std::list<WebView*> web_views;
|
| - Status status = session->chrome->GetWebViews(&web_views);
|
| + std::list<std::string> web_view_ids;
|
| + Status status = session->chrome->GetWebViewIds(&web_view_ids);
|
| if (status.IsError())
|
| return status;
|
|
|
| - WebView* web_view = NULL;
|
| -
|
| std::string web_view_id;
|
| + bool found = false;
|
| if (WindowHandleToWebViewId(name, &web_view_id)) {
|
| // Check if any web_view matches |web_view_id|.
|
| - for (std::list<WebView*>::const_iterator it = web_views.begin();
|
| - it != web_views.end(); ++it) {
|
| - if ((*it)->GetId() == web_view_id) {
|
| - web_view = *it;
|
| + for (std::list<std::string>::const_iterator it = web_view_ids.begin();
|
| + it != web_view_ids.end(); ++it) {
|
| + if (*it == web_view_id) {
|
| + found = true;
|
| break;
|
| }
|
| }
|
| @@ -148,25 +147,30 @@ Status ExecuteSwitchToWindow(
|
| // Check if any of the tab window names match |name|.
|
| const char* kGetWindowNameScript = "function() { return window.name; }";
|
| base::ListValue args;
|
| - for (std::list<WebView*>::const_iterator it = web_views.begin();
|
| - it != web_views.end(); ++it) {
|
| + for (std::list<std::string>::const_iterator it = web_view_ids.begin();
|
| + it != web_view_ids.end(); ++it) {
|
| scoped_ptr<base::Value> result;
|
| - status = (*it)->CallFunction("", kGetWindowNameScript, args, &result);
|
| + WebView* web_view;
|
| + status = session->chrome->GetWebViewById(*it, &web_view);
|
| + if (status.IsError())
|
| + return status;
|
| + status = web_view->CallFunction("", kGetWindowNameScript, args, &result);
|
| if (status.IsError())
|
| return status;
|
| std::string window_name;
|
| if (!result->GetAsString(&window_name))
|
| return Status(kUnknownError, "failed to get window name");
|
| if (window_name == name) {
|
| - web_view = *it;
|
| + web_view_id = *it;
|
| + found = true;
|
| break;
|
| }
|
| }
|
| }
|
|
|
| - if (!web_view)
|
| + if (!found)
|
| return Status(kNoSuchWindow);
|
| - session->window = web_view->GetId();
|
| + session->window = web_view_id;
|
| session->SwitchToTopFrame();
|
| session->mouse_position = WebPoint(0, 0);
|
| return Status(kOk);
|
|
|