summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/devtools/device/devtools_android_bridge.cc4
-rw-r--r--chrome/browser/devtools/device/devtools_android_bridge.h1
-rw-r--r--chrome/browser/devtools/devtools_targets_ui.cc14
-rw-r--r--chrome/browser/resources/inspect/inspect.js23
4 files changed, 22 insertions, 20 deletions
diff --git a/chrome/browser/devtools/device/devtools_android_bridge.cc b/chrome/browser/devtools/device/devtools_android_bridge.cc
index d6c7a9b..5f5ddb5 100644
--- a/chrome/browser/devtools/device/devtools_android_bridge.cc
+++ b/chrome/browser/devtools/device/devtools_android_bridge.cc
@@ -610,6 +610,10 @@ bool DevToolsAndroidBridge::RemoteBrowser::IsWebView() {
return type_ == AndroidDeviceManager::BrowserInfo::kTypeWebView;
}
+std::string DevToolsAndroidBridge::RemoteBrowser::GetId() {
+ return serial() + ":" + socket();
+}
+
DevToolsAndroidBridge::RemoteBrowser::ParsedVersion
DevToolsAndroidBridge::RemoteBrowser::GetParsedVersion() {
ParsedVersion result;
diff --git a/chrome/browser/devtools/device/devtools_android_bridge.h b/chrome/browser/devtools/device/devtools_android_bridge.h
index fde14f5..3b1bb7f 100644
--- a/chrome/browser/devtools/device/devtools_android_bridge.h
+++ b/chrome/browser/devtools/device/devtools_android_bridge.h
@@ -103,6 +103,7 @@ class DevToolsAndroidBridge : public KeyedService {
bool IsChrome();
bool IsWebView();
+ std::string GetId();
typedef std::vector<int> ParsedVersion;
ParsedVersion GetParsedVersion();
diff --git a/chrome/browser/devtools/devtools_targets_ui.cc b/chrome/browser/devtools/devtools_targets_ui.cc
index e84a602..09066a3 100644
--- a/chrome/browser/devtools/devtools_targets_ui.cc
+++ b/chrome/browser/devtools/devtools_targets_ui.cc
@@ -62,16 +62,6 @@ const char kAdbAttachedForeignField[] = "adbAttachedForeign";
const char kPortForwardingPorts[] = "ports";
const char kPortForwardingBrowserId[] = "browserId";
-std::string SerializeBrowserId(
- scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser) {
- return base::StringPrintf(
- "browser:%s:%s:%s:%s",
- browser->serial().c_str(), // Ensure uniqueness across devices.
- browser->display_name().c_str(), // Sort by display name.
- browser->version().c_str(), // Then by version.
- browser->socket().c_str()); // Ensure uniqueness on the device.
-}
-
// CancelableTimer ------------------------------------------------------------
class CancelableTimer {
@@ -379,7 +369,7 @@ void AdbTargetsUIHandler::DeviceListChanged(
browser_data->SetInteger(
kAdbBrowserChromeVersionField,
browser->IsChrome() && !parsed.empty() ? parsed[0] : 0);
- std::string browser_id = SerializeBrowserId(browser);
+ std::string browser_id = browser->GetId();
browser_data->SetString(kTargetIdField, browser_id);
browser_data->SetString(kTargetSourceField, source_id());
@@ -517,7 +507,7 @@ void PortForwardingStatusSerializer::PortStatusChanged(
base::DictionaryValue* device_status_dict = new base::DictionaryValue();
device_status_dict->Set(kPortForwardingPorts, port_status_dict);
device_status_dict->SetString(kPortForwardingBrowserId,
- SerializeBrowserId(sit->first));
+ sit->first->GetId());
std::string device_id = base::StringPrintf(
kAdbDeviceIdFormat,
diff --git a/chrome/browser/resources/inspect/inspect.js b/chrome/browser/resources/inspect/inspect.js
index b278aeb..78f117d 100644
--- a/chrome/browser/resources/inspect/inspect.js
+++ b/chrome/browser/resources/inspect/inspect.js
@@ -179,16 +179,23 @@ function populateRemoteTargets(devices) {
return;
}
- function insertChildSortedById(parent, child) {
- for (var sibling = parent.firstElementChild;
- sibling;
- sibling = sibling.nextElementSibling) {
- if (sibling.id > child.id) {
- parent.insertBefore(child, sibling);
+ function browserCompare(a, b) {
+ if (a.adbBrowserName != b.adbBrowserName)
+ return a.adbBrowserName < b.adbBrowserName;
+ if (a.adbBrowserVersion != b.adbBrowserVersion)
+ return a.adbBrowserVersion < b.adbBrowserVersion;
+ return a.id < b.id;
+ }
+
+ function insertBrowser(browserList, browser) {
+ for (var sibling = browserList.firstElementChild; sibling;
+ sibling = sibling.nextElementSibling) {
+ if (browserCompare(browser, sibling)) {
+ browserList.insertBefore(browser, sibling);
return;
}
}
- parent.appendChild(child);
+ browserList.appendChild(browser);
}
var deviceList = $('devices-list');
@@ -273,7 +280,7 @@ function populateRemoteTargets(devices) {
browserSection = document.createElement('div');
browserSection.id = browser.id;
browserSection.className = 'browser';
- insertChildSortedById(browserList, browserSection);
+ insertBrowser(browserList, browserSection);
var browserHeader = document.createElement('div');
browserHeader.className = 'browser-header';