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/session_commands.h" | 5 #include "chrome/test/chromedriver/session_commands.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/logging.h" // For CHECK macros. | 11 #include "base/logging.h" // For CHECK macros. |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/test/chromedriver/basic_types.h" | 17 #include "chrome/test/chromedriver/basic_types.h" |
18 #include "chrome/test/chromedriver/chrome/automation_extension.h" | 18 #include "chrome/test/chromedriver/chrome/automation_extension.h" |
19 #include "chrome/test/chromedriver/chrome/chrome.h" | 19 #include "chrome/test/chromedriver/chrome/chrome.h" |
20 #include "chrome/test/chromedriver/chrome/devtools_event_logger.h" | |
20 #include "chrome/test/chromedriver/chrome/geoposition.h" | 21 #include "chrome/test/chromedriver/chrome/geoposition.h" |
21 #include "chrome/test/chromedriver/chrome/status.h" | 22 #include "chrome/test/chromedriver/chrome/status.h" |
22 #include "chrome/test/chromedriver/chrome/web_view.h" | 23 #include "chrome/test/chromedriver/chrome/web_view.h" |
23 #include "chrome/test/chromedriver/session.h" | 24 #include "chrome/test/chromedriver/session.h" |
24 #include "chrome/test/chromedriver/session_map.h" | 25 #include "chrome/test/chromedriver/session_map.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 const char kWindowHandlePrefix[] = "CDwindow-"; | 29 const char kWindowHandlePrefix[] = "CDwindow-"; |
29 | 30 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 Session* session, | 466 Session* session, |
466 const base::DictionaryValue& params, | 467 const base::DictionaryValue& params, |
467 scoped_ptr<base::Value>* value) { | 468 scoped_ptr<base::Value>* value) { |
468 AutomationExtension* extension = NULL; | 469 AutomationExtension* extension = NULL; |
469 Status status = session->chrome->GetAutomationExtension(&extension); | 470 Status status = session->chrome->GetAutomationExtension(&extension); |
470 if (status.IsError()) | 471 if (status.IsError()) |
471 return status; | 472 return status; |
472 | 473 |
473 return extension->MaximizeWindow(); | 474 return extension->MaximizeWindow(); |
474 } | 475 } |
476 | |
477 Status ExecuteGetAvailableLogTypes( | |
478 Session* session, | |
479 const base::DictionaryValue& params, | |
480 scoped_ptr<base::Value>* value) { | |
481 if (params.size() != 0) { | |
kkania
2013/04/18 17:34:39
remove this; we don't bother checking this anywher
klm
2013/04/18 19:11:31
Done.
| |
482 return Status(kUnknownError, "unexpected parameters"); | |
483 } | |
484 scoped_ptr<ListValue> types(new base::ListValue()); | |
485 for (ScopedVector<DevToolsEventLogger>::const_iterator logger = | |
486 session->devtools_event_loggers.begin(); | |
487 logger != session->devtools_event_loggers.end(); ++logger) { | |
488 types->AppendString((*logger)->GetLogType()); | |
489 } | |
490 value->reset(types.release()); | |
491 return Status(kOk); | |
492 } | |
493 | |
494 Status ExecuteGetLog( | |
495 Session* session, | |
496 const base::DictionaryValue& params, | |
497 scoped_ptr<base::Value>* value) { | |
498 if (params.size() != 1) { | |
kkania
2013/04/18 17:34:39
remove this
klm
2013/04/18 19:11:31
Done.
| |
499 return Status(kUnknownError, "unexpected parameters"); | |
500 } | |
501 std::string log_type; | |
502 if (!params.GetString("type", &log_type)) { | |
503 return Status(kUnknownError, "missing or invalid 'type'"); | |
504 } | |
505 for (ScopedVector<DevToolsEventLogger>::const_iterator logger = | |
506 session->devtools_event_loggers.begin(); | |
507 logger != session->devtools_event_loggers.end(); ++logger) { | |
508 if (log_type == (*logger)->GetLogType()) { | |
509 scoped_ptr<ListValue> log_entries = (*logger)->GetAndClearLogEntries(); | |
510 value->reset(log_entries.release()); | |
511 return Status(kOk); | |
512 } | |
513 } | |
514 return Status(kUnknownError, "log type '" + log_type + "' not found"); | |
515 } | |
OLD | NEW |