Chromium Code Reviews| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 timeline(InspectorDomainStatus::kDefaultDisabled), | 580 timeline(InspectorDomainStatus::kDefaultDisabled), |
| 581 trace_categories(), | 581 trace_categories(), |
| 582 buffer_usage_reporting_interval(1000) {} | 582 buffer_usage_reporting_interval(1000) {} |
| 583 | 583 |
| 584 PerfLoggingPrefs::~PerfLoggingPrefs() {} | 584 PerfLoggingPrefs::~PerfLoggingPrefs() {} |
| 585 | 585 |
| 586 Capabilities::Capabilities() | 586 Capabilities::Capabilities() |
| 587 : android_use_running_app(false), | 587 : android_use_running_app(false), |
| 588 detach(false), | 588 detach(false), |
| 589 force_devtools_screenshot(false), | 589 force_devtools_screenshot(false), |
| 590 page_loading("normal"), | |
|
samuong
2016/07/25 22:44:33
normal, eager and none should be defined constants
evajiang
2016/07/28 17:15:03
Done.
| |
| 590 network_emulation_enabled(false) {} | 591 network_emulation_enabled(false) {} |
| 591 | 592 |
| 592 Capabilities::~Capabilities() {} | 593 Capabilities::~Capabilities() {} |
| 593 | 594 |
| 594 bool Capabilities::IsAndroid() const { | 595 bool Capabilities::IsAndroid() const { |
| 595 return !android_package.empty(); | 596 return !android_package.empty(); |
| 596 } | 597 } |
| 597 | 598 |
| 598 bool Capabilities::IsRemoteBrowser() const { | 599 bool Capabilities::IsRemoteBrowser() const { |
| 599 return debugger_address.IsValid(); | 600 return debugger_address.IsValid(); |
| 600 } | 601 } |
| 601 | 602 |
| 602 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { | 603 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { |
| 603 std::map<std::string, Parser> parser_map; | 604 std::map<std::string, Parser> parser_map; |
| 604 parser_map["chromeOptions"] = base::Bind(&ParseChromeOptions); | 605 parser_map["chromeOptions"] = base::Bind(&ParseChromeOptions); |
| 605 parser_map["loggingPrefs"] = base::Bind(&ParseLoggingPrefs); | 606 parser_map["loggingPrefs"] = base::Bind(&ParseLoggingPrefs); |
| 606 parser_map["proxy"] = base::Bind(&ParseProxy); | 607 parser_map["proxy"] = base::Bind(&ParseProxy); |
| 608 parser_map["pageLoadingStrategy"] = base::Bind(&ParseString, &page_loading); | |
|
samuong
2016/07/25 22:44:33
this should be called "pageLoadStrategy" (see http
evajiang
2016/07/28 17:15:03
Done.
| |
| 607 // Network emulation requires device mode, which is only enabled when | 609 // Network emulation requires device mode, which is only enabled when |
| 608 // mobile emulation is on. | 610 // mobile emulation is on. |
| 609 if (desired_caps.GetDictionary("chromeOptions.mobileEmulation", nullptr)) { | 611 if (desired_caps.GetDictionary("chromeOptions.mobileEmulation", nullptr)) { |
| 610 parser_map["networkConnectionEnabled"] = | 612 parser_map["networkConnectionEnabled"] = |
| 611 base::Bind(&ParseBoolean, &network_emulation_enabled); | 613 base::Bind(&ParseBoolean, &network_emulation_enabled); |
| 612 } | 614 } |
| 613 for (std::map<std::string, Parser>::iterator it = parser_map.begin(); | 615 for (std::map<std::string, Parser>::iterator it = parser_map.begin(); |
| 614 it != parser_map.end(); ++it) { | 616 it != parser_map.end(); ++it) { |
| 615 const base::Value* capability = NULL; | 617 const base::Value* capability = NULL; |
| 616 if (desired_caps.Get(it->first, &capability)) { | 618 if (desired_caps.Get(it->first, &capability)) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 627 if (iter == logging_prefs.end() || iter->second == Log::kOff) { | 629 if (iter == logging_prefs.end() || iter->second == Log::kOff) { |
| 628 const base::DictionaryValue* chrome_options = NULL; | 630 const base::DictionaryValue* chrome_options = NULL; |
| 629 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | 631 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && |
| 630 chrome_options->HasKey("perfLoggingPrefs")) { | 632 chrome_options->HasKey("perfLoggingPrefs")) { |
| 631 return Status(kUnknownError, "perfLoggingPrefs specified, " | 633 return Status(kUnknownError, "perfLoggingPrefs specified, " |
| 632 "but performance logging was not enabled"); | 634 "but performance logging was not enabled"); |
| 633 } | 635 } |
| 634 } | 636 } |
| 635 return Status(kOk); | 637 return Status(kOk); |
| 636 } | 638 } |
| OLD | NEW |