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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 if (status.IsError()) { | 108 if (status.IsError()) { |
109 return Status(kUnknownError, | 109 return Status(kUnknownError, |
110 "'" + device_name + "' must be a valid device", | 110 "'" + device_name + "' must be a valid device", |
111 status); | 111 status); |
112 } | 112 } |
113 | 113 |
114 capabilities->device_metrics.reset(device->device_metrics.release()); | 114 capabilities->device_metrics.reset(device->device_metrics.release()); |
115 // Don't override the user agent if blank (like for notebooks). | 115 // Don't override the user agent if blank (like for notebooks). |
116 if (!device->user_agent.empty()) | 116 if (!device->user_agent.empty()) |
117 capabilities->switches.SetSwitch("user-agent", device->user_agent); | 117 capabilities->user_agent = device->user_agent; |
118 | 118 |
119 return Status(kOk); | 119 return Status(kOk); |
120 } | 120 } |
121 | 121 |
122 Status ParseMobileEmulation(const base::Value& option, | 122 Status ParseMobileEmulation(const base::Value& option, |
123 Capabilities* capabilities) { | 123 Capabilities* capabilities) { |
124 const base::DictionaryValue* mobile_emulation; | 124 const base::DictionaryValue* mobile_emulation; |
125 if (!option.GetAsDictionary(&mobile_emulation)) | 125 if (!option.GetAsDictionary(&mobile_emulation)) |
126 return Status(kUnknownError, "'mobileEmulation' must be a dictionary"); | 126 return Status(kUnknownError, "'mobileEmulation' must be a dictionary"); |
127 | 127 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 new DeviceMetrics(width, height, device_scale_factor, touch, mobile); | 168 new DeviceMetrics(width, height, device_scale_factor, touch, mobile); |
169 capabilities->device_metrics = | 169 capabilities->device_metrics = |
170 std::unique_ptr<DeviceMetrics>(device_metrics); | 170 std::unique_ptr<DeviceMetrics>(device_metrics); |
171 } | 171 } |
172 | 172 |
173 if (mobile_emulation->HasKey("userAgent")) { | 173 if (mobile_emulation->HasKey("userAgent")) { |
174 std::string user_agent; | 174 std::string user_agent; |
175 if (!mobile_emulation->GetString("userAgent", &user_agent)) | 175 if (!mobile_emulation->GetString("userAgent", &user_agent)) |
176 return Status(kUnknownError, "'userAgent' must be a string"); | 176 return Status(kUnknownError, "'userAgent' must be a string"); |
177 | 177 |
178 capabilities->switches.SetSwitch("user-agent", user_agent); | 178 capabilities->user_agent = user_agent; |
179 } | 179 } |
180 | 180 |
181 return Status(kOk); | 181 return Status(kOk); |
182 } | 182 } |
183 | 183 |
184 Status ParsePageLoadStrategy(const base::Value& option, | 184 Status ParsePageLoadStrategy(const base::Value& option, |
185 Capabilities* capabilities) { | 185 Capabilities* capabilities) { |
186 if (!option.GetAsString(&capabilities->page_load_strategy)) | 186 if (!option.GetAsString(&capabilities->page_load_strategy)) |
187 return Status(kUnknownError, "must be a string"); | 187 return Status(kUnknownError, "must be a string"); |
188 if (capabilities->page_load_strategy == PageLoadStrategy::kNormal || | 188 if (capabilities->page_load_strategy == PageLoadStrategy::kNormal || |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 if (iter == logging_prefs.end() || iter->second == Log::kOff) { | 657 if (iter == logging_prefs.end() || iter->second == Log::kOff) { |
658 const base::DictionaryValue* chrome_options = NULL; | 658 const base::DictionaryValue* chrome_options = NULL; |
659 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | 659 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && |
660 chrome_options->HasKey("perfLoggingPrefs")) { | 660 chrome_options->HasKey("perfLoggingPrefs")) { |
661 return Status(kUnknownError, "perfLoggingPrefs specified, " | 661 return Status(kUnknownError, "perfLoggingPrefs specified, " |
662 "but performance logging was not enabled"); | 662 "but performance logging was not enabled"); |
663 } | 663 } |
664 } | 664 } |
665 return Status(kOk); | 665 return Status(kOk); |
666 } | 666 } |
OLD | NEW |