OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/window_commands.h" | 5 #include "chrome/test/chromedriver/window_commands.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 Session* session, | 240 Session* session, |
241 WebView* web_view, | 241 WebView* web_view, |
242 const base::DictionaryValue& params, | 242 const base::DictionaryValue& params, |
243 scoped_ptr<base::Value>* value) { | 243 scoped_ptr<base::Value>* value) { |
244 std::string url; | 244 std::string url; |
245 if (!params.GetString("url", &url)) | 245 if (!params.GetString("url", &url)) |
246 return Status(kUnknownError, "'url' must be a string"); | 246 return Status(kUnknownError, "'url' must be a string"); |
247 return web_view->Load(url); | 247 return web_view->Load(url); |
248 } | 248 } |
249 | 249 |
250 Status ExecuteLaunchApp( | |
251 Session* session, | |
252 WebView* web_view, | |
253 const base::DictionaryValue& params, | |
254 scoped_ptr<base::Value>* value) { | |
255 std::string id; | |
256 if (!params.GetString("id", &id)) | |
257 return Status(kUnknownError, "'id' must be a string"); | |
258 | |
259 if (!session->chrome->GetAsDesktop()) | |
260 return Status(kUnknownError, | |
261 "apps can only be launched on desktop platforms"); | |
262 | |
263 AutomationExtension* extension = NULL; | |
264 Status status = | |
265 session->chrome->GetAsDesktop()->GetAutomationExtension(&extension); | |
266 if (status.IsError()) | |
267 return status; | |
268 | |
269 status = extension->LaunchApp(id); | |
270 if (status.IsError()) | |
271 return status; | |
272 | |
273 std::list<std::string> web_view_ids; | |
274 status = session->chrome->GetWebViewIds(&web_view_ids); | |
275 if (status.IsError()) | |
276 return status; | |
277 | |
278 // Switch the active window to the last one opened. | |
279 session->chrome->ActivateWebView(web_view_ids.back()); | |
chrisgao (Use stgao instead)
2014/01/15 21:39:56
The activation might fail. maybe need to check the
bustamante
2014/01/15 23:51:38
Thanks, per the other comment I removed this code
| |
280 session->window = web_view_ids.back(); | |
281 session->SwitchToTopFrame(); | |
282 session->mouse_position = WebPoint(0, 0); | |
283 | |
284 return status; | |
285 } | |
286 | |
250 Status ExecuteExecuteScript( | 287 Status ExecuteExecuteScript( |
251 Session* session, | 288 Session* session, |
252 WebView* web_view, | 289 WebView* web_view, |
253 const base::DictionaryValue& params, | 290 const base::DictionaryValue& params, |
254 scoped_ptr<base::Value>* value) { | 291 scoped_ptr<base::Value>* value) { |
255 std::string script; | 292 std::string script; |
256 if (!params.GetString("script", &script)) | 293 if (!params.GetString("script", &script)) |
257 return Status(kUnknownError, "'script' must be a string"); | 294 return Status(kUnknownError, "'script' must be a string"); |
258 if (script == ":takeHeapSnapshot") { | 295 if (script == ":takeHeapSnapshot") { |
259 return web_view->TakeHeapSnapshot(value); | 296 return web_view->TakeHeapSnapshot(value); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 return status; | 901 return status; |
865 } | 902 } |
866 | 903 |
867 Status ExecuteTakeHeapSnapshot( | 904 Status ExecuteTakeHeapSnapshot( |
868 Session* session, | 905 Session* session, |
869 WebView* web_view, | 906 WebView* web_view, |
870 const base::DictionaryValue& params, | 907 const base::DictionaryValue& params, |
871 scoped_ptr<base::Value>* value) { | 908 scoped_ptr<base::Value>* value) { |
872 return web_view->TakeHeapSnapshot(value); | 909 return web_view->TakeHeapSnapshot(value); |
873 } | 910 } |
OLD | NEW |