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 scoped_ptr<ListValue> types(new base::ListValue()); |
| 482 for (ScopedVector<DevToolsEventLogger>::const_iterator logger = |
| 483 session->devtools_event_loggers.begin(); |
| 484 logger != session->devtools_event_loggers.end(); ++logger) { |
| 485 types->AppendString((*logger)->GetLogType()); |
| 486 } |
| 487 value->reset(types.release()); |
| 488 return Status(kOk); |
| 489 } |
| 490 |
| 491 Status ExecuteGetLog( |
| 492 Session* session, |
| 493 const base::DictionaryValue& params, |
| 494 scoped_ptr<base::Value>* value) { |
| 495 std::string log_type; |
| 496 if (!params.GetString("type", &log_type)) { |
| 497 return Status(kUnknownError, "missing or invalid 'type'"); |
| 498 } |
| 499 for (ScopedVector<DevToolsEventLogger>::const_iterator logger = |
| 500 session->devtools_event_loggers.begin(); |
| 501 logger != session->devtools_event_loggers.end(); ++logger) { |
| 502 if (log_type == (*logger)->GetLogType()) { |
| 503 scoped_ptr<ListValue> log_entries = (*logger)->GetAndClearLogEntries(); |
| 504 value->reset(log_entries.release()); |
| 505 return Status(kOk); |
| 506 } |
| 507 } |
| 508 return Status(kUnknownError, "log type '" + log_type + "' not found"); |
| 509 } |
OLD | NEW |