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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 | 550 |
| 551 bool Capabilities::IsAndroid() const { | 551 bool Capabilities::IsAndroid() const { |
| 552 return !android_package.empty(); | 552 return !android_package.empty(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 bool Capabilities::IsRemoteBrowser() const { | 555 bool Capabilities::IsRemoteBrowser() const { |
| 556 return debugger_address.IsValid(); | 556 return debugger_address.IsValid(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { | 559 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { |
| 560 // get user prefs and assign to Capabilities prefs | |
| 561 const base::DictionaryValue* _prefs = NULL; | |
| 562 if (desired_caps.GetDictionary("prefs", &_prefs)) { | |
| 563 prefs.reset(new base::DictionaryValue()); | |
| 564 prefs->MergeDictionary(_prefs); | |
| 565 } | |
| 566 // | |
|
samuong
2014/10/01 20:22:12
Could you move this out to a separate function and
andrewcheng
2014/10/08 22:08:26
Done.
| |
| 560 std::map<std::string, Parser> parser_map; | 567 std::map<std::string, Parser> parser_map; |
| 561 parser_map["chromeOptions"] = base::Bind(&ParseChromeOptions); | 568 parser_map["chromeOptions"] = base::Bind(&ParseChromeOptions); |
| 562 parser_map["loggingPrefs"] = base::Bind(&ParseLoggingPrefs); | 569 parser_map["loggingPrefs"] = base::Bind(&ParseLoggingPrefs); |
| 563 parser_map["proxy"] = base::Bind(&ParseProxy); | 570 parser_map["proxy"] = base::Bind(&ParseProxy); |
| 564 for (std::map<std::string, Parser>::iterator it = parser_map.begin(); | 571 for (std::map<std::string, Parser>::iterator it = parser_map.begin(); |
| 565 it != parser_map.end(); ++it) { | 572 it != parser_map.end(); ++it) { |
| 566 const base::Value* capability = NULL; | 573 const base::Value* capability = NULL; |
| 567 if (desired_caps.Get(it->first, &capability)) { | 574 if (desired_caps.Get(it->first, &capability)) { |
| 568 Status status = it->second.Run(*capability, this); | 575 Status status = it->second.Run(*capability, this); |
| 569 if (status.IsError()) { | 576 if (status.IsError()) { |
| 570 return Status( | 577 return Status( |
| 571 kUnknownError, "cannot parse capability: " + it->first, status); | 578 kUnknownError, "cannot parse capability: " + it->first, status); |
| 572 } | 579 } |
| 573 } | 580 } |
| 574 } | 581 } |
| 575 // Perf log must be enabled if perf log prefs are specified; otherwise, error. | 582 // Perf log must be enabled if perf log prefs are specified; otherwise, error. |
| 576 LoggingPrefs::const_iterator iter = logging_prefs.find( | 583 LoggingPrefs::const_iterator iter = logging_prefs.find( |
| 577 WebDriverLog::kPerformanceType); | 584 WebDriverLog::kPerformanceType); |
| 578 if (iter == logging_prefs.end() || iter->second == Log::kOff) { | 585 if (iter == logging_prefs.end() || iter->second == Log::kOff) { |
| 579 const base::DictionaryValue* chrome_options = NULL; | 586 const base::DictionaryValue* chrome_options = NULL; |
| 580 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | 587 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && |
| 581 chrome_options->HasKey("perfLoggingPrefs")) { | 588 chrome_options->HasKey("perfLoggingPrefs")) { |
| 582 return Status(kUnknownError, "perfLoggingPrefs specified, " | 589 return Status(kUnknownError, "perfLoggingPrefs specified, " |
| 583 "but performance logging was not enabled"); | 590 "but performance logging was not enabled"); |
| 584 } | 591 } |
| 585 } | 592 } |
| 586 return Status(kOk); | 593 return Status(kOk); |
| 587 } | 594 } |
| OLD | NEW |