OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/chromedriver/commands.h" | 5 #include "chrome/test/chromedriver/commands.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 scoped_ptr<ChromeDesktopImpl> chrome_desktop(new ChromeDesktopImpl( | 112 scoped_ptr<ChromeDesktopImpl> chrome_desktop(new ChromeDesktopImpl( |
113 context_getter, port, socket_factory)); | 113 context_getter, port, socket_factory)); |
114 status = chrome_desktop->Launch(chrome_exe, args_list, extensions_list, | 114 status = chrome_desktop->Launch(chrome_exe, args_list, extensions_list, |
115 prefs_dict, local_state_dict); | 115 prefs_dict, local_state_dict); |
116 chrome.reset(chrome_desktop.release()); | 116 chrome.reset(chrome_desktop.release()); |
117 } | 117 } |
118 if (status.IsError()) | 118 if (status.IsError()) |
119 return Status(kSessionNotCreatedException, status.message()); | 119 return Status(kSessionNotCreatedException, status.message()); |
120 | 120 |
121 std::list<WebView*> web_views; | 121 std::list<std::string> web_view_ids; |
122 status = chrome->GetWebViews(&web_views); | 122 status = chrome->GetWebViewIds(&web_view_ids); |
123 if (status.IsError() || web_views.empty()) { | 123 if (status.IsError() || web_view_ids.empty()) { |
124 chrome->Quit(); | 124 chrome->Quit(); |
125 return status.IsError() ? status : | 125 return status.IsError() ? status : |
126 Status(kUnknownError, "unable to discover open window in chrome"); | 126 Status(kUnknownError, "unable to discover open window in chrome"); |
127 } | 127 } |
128 WebView* default_web_view = web_views.front(); | |
129 | 128 |
130 std::string new_id = session_id; | 129 std::string new_id = session_id; |
131 if (new_id.empty()) | 130 if (new_id.empty()) |
132 new_id = GenerateId(); | 131 new_id = GenerateId(); |
133 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); | 132 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); |
134 session->window = default_web_view->GetId(); | 133 session->window = web_view_ids.front(); |
135 out_value->reset(session->capabilities->DeepCopy()); | 134 out_value->reset(session->capabilities->DeepCopy()); |
136 *out_session_id = new_id; | 135 *out_session_id = new_id; |
137 | 136 |
138 scoped_refptr<SessionAccessor> accessor( | 137 scoped_refptr<SessionAccessor> accessor( |
139 new SessionAccessorImpl(session.Pass())); | 138 new SessionAccessorImpl(session.Pass())); |
140 session_map->Set(new_id, accessor); | 139 session_map->Set(new_id, accessor); |
141 | 140 |
142 return Status(kOk); | 141 return Status(kOk); |
143 } | 142 } |
144 | 143 |
145 Status ExecuteQuitAll( | 144 Status ExecuteQuitAll( |
146 Command quit_command, | 145 Command quit_command, |
147 SessionMap* session_map, | 146 SessionMap* session_map, |
148 const base::DictionaryValue& params, | 147 const base::DictionaryValue& params, |
149 const std::string& session_id, | 148 const std::string& session_id, |
150 scoped_ptr<base::Value>* out_value, | 149 scoped_ptr<base::Value>* out_value, |
151 std::string* out_session_id) { | 150 std::string* out_session_id) { |
152 std::vector<std::string> session_ids; | 151 std::vector<std::string> session_ids; |
153 session_map->GetKeys(&session_ids); | 152 session_map->GetKeys(&session_ids); |
154 for (size_t i = 0; i < session_ids.size(); ++i) { | 153 for (size_t i = 0; i < session_ids.size(); ++i) { |
155 scoped_ptr<base::Value> unused_value; | 154 scoped_ptr<base::Value> unused_value; |
156 std::string unused_session_id; | 155 std::string unused_session_id; |
157 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); | 156 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); |
158 } | 157 } |
159 return Status(kOk); | 158 return Status(kOk); |
160 } | 159 } |
OLD | NEW |