Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: chrome/test/chromedriver/chrome/devtools_http_client.cc

Issue 654713004: [chromedriver] Add support for all target types from DevToolsTargetImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/chrome/devtools_http_client.cc
diff --git a/chrome/test/chromedriver/chrome/devtools_http_client.cc b/chrome/test/chromedriver/chrome/devtools_http_client.cc
index 9e4599be1c38e07187f2e521bd6184cf8aecb676..7f3a49e9f134a84bcc6988b02f00c09dec90a72a 100644
--- a/chrome/test/chromedriver/chrome/devtools_http_client.cc
+++ b/chrome/test/chromedriver/chrome/devtools_http_client.cc
@@ -234,8 +234,7 @@ bool DevToolsHttpClient::FetchUrlAndLog(const std::string& url,
namespace internal {
-Status ParseWebViewsInfo(const std::string& data,
- WebViewsInfo* views_info) {
+Status ParseWebViewsInfo(const std::string& data, WebViewsInfo* views_info) {
scoped_ptr<base::Value> value(base::JSONReader::Read(data));
if (!value.get())
return Status(kUnknownError, "DevTools returned invalid JSON");
@@ -260,25 +259,36 @@ Status ParseWebViewsInfo(const std::string& data,
std::string debugger_url;
info->GetString("webSocketDebuggerUrl", &debugger_url);
WebViewInfo::Type type;
- if (type_as_string == "app")
- type = WebViewInfo::kApp;
- else if (type_as_string == "background_page")
- type = WebViewInfo::kBackgroundPage;
- else if (type_as_string == "page")
- type = WebViewInfo::kPage;
- else if (type_as_string == "worker")
- type = WebViewInfo::kWorker;
- else if (type_as_string == "webview")
- type = WebViewInfo::kWebView;
- else if (type_as_string == "other")
- type = WebViewInfo::kOther;
- else
- return Status(kUnknownError,
- "DevTools returned unknown type:" + type_as_string);
+ Status status = ParseType(type_as_string, &type);
+ if (status.IsError())
+ return status;
temp_views_info.push_back(WebViewInfo(id, debugger_url, url, type));
}
*views_info = WebViewsInfo(temp_views_info);
return Status(kOk);
}
+Status ParseType(const std::string& type_as_string, WebViewInfo::Type* type) {
+ if (type_as_string == "app")
+ *type = WebViewInfo::kApp;
+ else if (type_as_string == "background_page")
+ *type = WebViewInfo::kBackgroundPage;
+ else if (type_as_string == "page")
+ *type = WebViewInfo::kPage;
+ else if (type_as_string == "worker")
+ *type = WebViewInfo::kWorker;
+ else if (type_as_string == "webview")
+ *type = WebViewInfo::kWebView;
+ else if (type_as_string == "iframe")
+ *type = WebViewInfo::kIFrame;
+ else if (type_as_string == "other")
+ *type = WebViewInfo::kOther;
+ else if (type_as_string == "service_worker")
+ *type = WebViewInfo::kServiceWorker;
+ else
+ return Status(kUnknownError,
+ "DevTools returned unknown type:" + type_as_string);
+ return Status(kOk);
+}
+
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698