| 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/capabilities.h" | 5 #include "chrome/test/chromedriver/capabilities.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 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/json/string_escape.h" | 12 #include "base/json/string_escape.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_tokenizer.h" | 17 #include "base/strings/string_tokenizer.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 Capabilities* capabilities) { | 105 Capabilities* capabilities) { |
| 105 std::unique_ptr<MobileDevice> device; | 106 std::unique_ptr<MobileDevice> device; |
| 106 Status status = FindMobileDevice(device_name, &device); | 107 Status status = FindMobileDevice(device_name, &device); |
| 107 | 108 |
| 108 if (status.IsError()) { | 109 if (status.IsError()) { |
| 109 return Status(kUnknownError, | 110 return Status(kUnknownError, |
| 110 "'" + device_name + "' must be a valid device", | 111 "'" + device_name + "' must be a valid device", |
| 111 status); | 112 status); |
| 112 } | 113 } |
| 113 | 114 |
| 114 capabilities->device_metrics.reset(device->device_metrics.release()); | 115 capabilities->device_metrics = std::move(device->device_metrics); |
| 115 // Don't override the user agent if blank (like for notebooks). | 116 // Don't override the user agent if blank (like for notebooks). |
| 116 if (!device->user_agent.empty()) | 117 if (!device->user_agent.empty()) |
| 117 capabilities->switches.SetSwitch("user-agent", device->user_agent); | 118 capabilities->switches.SetSwitch("user-agent", device->user_agent); |
| 118 | 119 |
| 119 return Status(kOk); | 120 return Status(kOk); |
| 120 } | 121 } |
| 121 | 122 |
| 122 Status ParseMobileEmulation(const base::Value& option, | 123 Status ParseMobileEmulation(const base::Value& option, |
| 123 Capabilities* capabilities) { | 124 Capabilities* capabilities) { |
| 124 const base::DictionaryValue* mobile_emulation; | 125 const base::DictionaryValue* mobile_emulation; |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 if (iter == logging_prefs.end() || iter->second == Log::kOff) { | 661 if (iter == logging_prefs.end() || iter->second == Log::kOff) { |
| 661 const base::DictionaryValue* chrome_options = NULL; | 662 const base::DictionaryValue* chrome_options = NULL; |
| 662 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | 663 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && |
| 663 chrome_options->HasKey("perfLoggingPrefs")) { | 664 chrome_options->HasKey("perfLoggingPrefs")) { |
| 664 return Status(kUnknownError, "perfLoggingPrefs specified, " | 665 return Status(kUnknownError, "perfLoggingPrefs specified, " |
| 665 "but performance logging was not enabled"); | 666 "but performance logging was not enabled"); |
| 666 } | 667 } |
| 667 } | 668 } |
| 668 return Status(kOk); | 669 return Status(kOk); |
| 669 } | 670 } |
| OLD | NEW |