| Index: chrome/test/webdriver/webdriver_util.cc
|
| diff --git a/chrome/test/webdriver/webdriver_util.cc b/chrome/test/webdriver/webdriver_util.cc
|
| index 1347284e0a6fcae56c1d99b775e2a9643477394c..d4b27d2fa90b8db96810e9073a18af6fec1eeba9 100644
|
| --- a/chrome/test/webdriver/webdriver_util.cc
|
| +++ b/chrome/test/webdriver/webdriver_util.cc
|
| @@ -12,6 +12,7 @@
|
| #include "base/rand_util.h"
|
| #include "base/stringprintf.h"
|
| #include "base/string_number_conversions.h"
|
| +#include "base/string_split.h"
|
| #include "base/third_party/icu/icu_utf.h"
|
| #include "chrome/common/automation_id.h"
|
| #include "chrome/test/automation/automation_json_requests.h"
|
| @@ -121,31 +122,37 @@ const char* GetJsonTypeName(Value::Type type) {
|
| return "unknown";
|
| }
|
|
|
| +std::string AutomationIdToString(const AutomationId& id) {
|
| + return base::StringPrintf("%d-%s", id.type(), id.id().c_str());
|
| +}
|
| +
|
| bool StringToAutomationId(const std::string& string_id, AutomationId* id) {
|
| - scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
|
| - std::string error_msg;
|
| - return value.get() && AutomationId::FromValue(value.get(), id, &error_msg);
|
| + std::vector<std::string> split_id;
|
| + base::SplitString(string_id, '-', &split_id);
|
| + if (split_id.size() != 2)
|
| + return false;
|
| + int type;
|
| + if (!base::StringToInt(split_id[0], &type))
|
| + return false;
|
| + *id = AutomationId(static_cast<AutomationId::Type>(type), split_id[1]);
|
| + return true;
|
| }
|
|
|
| std::string WebViewIdToString(const WebViewId& view_id) {
|
| - DictionaryValue* dict = view_id.GetId().ToValue();
|
| - if (view_id.old_style())
|
| - dict->SetBoolean("old_style", true);
|
| - return JsonStringify(dict);
|
| + return base::StringPrintf(
|
| + "%s%s",
|
| + view_id.old_style() ? "t" : "f",
|
| + AutomationIdToString(view_id.GetId()).c_str());
|
| }
|
|
|
| bool StringToWebViewId(const std::string& string_id, WebViewId* view_id) {
|
| - scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
|
| + if (string_id.empty() || (string_id[0] != 'f' && string_id[0] != 't'))
|
| + return false;
|
| + bool old_style = string_id[0] == 't';
|
| AutomationId id;
|
| - std::string error_msg;
|
| - DictionaryValue* dict;
|
| - if (!value.get() || !AutomationId::FromValue(value.get(), &id, &error_msg) ||
|
| - !value->GetAsDictionary(&dict))
|
| + if (!StringToAutomationId(string_id.substr(1), &id))
|
| return false;
|
|
|
| - bool old_style = false;
|
| - dict->GetBoolean("old_style", &old_style);
|
| -
|
| if (old_style) {
|
| int tab_id;
|
| if (!base::StringToInt(id.id(), &tab_id))
|
|
|