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 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/logging.h" // For CHECK macros. | 13 #include "base/logging.h" // For CHECK macros. |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 caps->SetBoolean("nativeEvents", true); | 94 caps->SetBoolean("nativeEvents", true); |
94 caps->SetBoolean("hasTouchScreen", chrome->HasTouchScreen()); | 95 caps->SetBoolean("hasTouchScreen", chrome->HasTouchScreen()); |
95 | 96 |
96 ChromeDesktopImpl* desktop = NULL; | 97 ChromeDesktopImpl* desktop = NULL; |
97 Status status = chrome->GetAsDesktop(&desktop); | 98 Status status = chrome->GetAsDesktop(&desktop); |
98 if (status.IsOk()) { | 99 if (status.IsOk()) { |
99 caps->SetString("chrome.userDataDir", | 100 caps->SetString("chrome.userDataDir", |
100 desktop->command().GetSwitchValueNative("user-data-dir")); | 101 desktop->command().GetSwitchValueNative("user-data-dir")); |
101 } | 102 } |
102 | 103 |
103 return caps.Pass(); | 104 return caps; |
104 } | 105 } |
105 | 106 |
106 Status CheckSessionCreated(Session* session) { | 107 Status CheckSessionCreated(Session* session) { |
107 WebView* web_view = NULL; | 108 WebView* web_view = NULL; |
108 Status status = session->GetTargetWindow(&web_view); | 109 Status status = session->GetTargetWindow(&web_view); |
109 if (status.IsError()) | 110 if (status.IsError()) |
110 return Status(kSessionNotCreatedException, status); | 111 return Status(kSessionNotCreatedException, status); |
111 | 112 |
112 status = web_view->ConnectIfNecessary(); | 113 status = web_view->ConnectIfNecessary(); |
113 if (status.IsError()) | 114 if (status.IsError()) |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 Session* session, | 637 Session* session, |
637 const base::DictionaryValue& params, | 638 const base::DictionaryValue& params, |
638 scoped_ptr<base::Value>* value) { | 639 scoped_ptr<base::Value>* value) { |
639 scoped_ptr<base::ListValue> types(new base::ListValue()); | 640 scoped_ptr<base::ListValue> types(new base::ListValue()); |
640 std::vector<WebDriverLog*> logs = session->GetAllLogs(); | 641 std::vector<WebDriverLog*> logs = session->GetAllLogs(); |
641 for (std::vector<WebDriverLog*>::const_iterator log = logs.begin(); | 642 for (std::vector<WebDriverLog*>::const_iterator log = logs.begin(); |
642 log != logs.end(); | 643 log != logs.end(); |
643 ++log) { | 644 ++log) { |
644 types->AppendString((*log)->type()); | 645 types->AppendString((*log)->type()); |
645 } | 646 } |
646 *value = types.Pass(); | 647 *value = std::move(types); |
647 return Status(kOk); | 648 return Status(kOk); |
648 } | 649 } |
649 | 650 |
650 Status ExecuteGetLog( | 651 Status ExecuteGetLog( |
651 Session* session, | 652 Session* session, |
652 const base::DictionaryValue& params, | 653 const base::DictionaryValue& params, |
653 scoped_ptr<base::Value>* value) { | 654 scoped_ptr<base::Value>* value) { |
654 std::string log_type; | 655 std::string log_type; |
655 if (!params.GetString("type", &log_type)) { | 656 if (!params.GetString("type", &log_type)) { |
656 return Status(kUnknownError, "missing or invalid 'type'"); | 657 return Status(kUnknownError, "missing or invalid 'type'"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 Status ExecuteSetAutoReporting( | 710 Status ExecuteSetAutoReporting( |
710 Session* session, | 711 Session* session, |
711 const base::DictionaryValue& params, | 712 const base::DictionaryValue& params, |
712 scoped_ptr<base::Value>* value) { | 713 scoped_ptr<base::Value>* value) { |
713 bool enabled; | 714 bool enabled; |
714 if (!params.GetBoolean("enabled", &enabled)) | 715 if (!params.GetBoolean("enabled", &enabled)) |
715 return Status(kUnknownError, "missing parameter 'enabled'"); | 716 return Status(kUnknownError, "missing parameter 'enabled'"); |
716 session->auto_reporting_enabled = enabled; | 717 session->auto_reporting_enabled = enabled; |
717 return Status(kOk); | 718 return Status(kOk); |
718 } | 719 } |
OLD | NEW |