Index: chrome/browser/resources/options2/chromeos/bluetooth_device_list.js |
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js b/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js |
index b8990c564f035597c04800b7697f7ace5bd459d1..b541eb432367250c7a75536d663e12d81fe6bda5 100644 |
--- a/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js |
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js |
@@ -25,6 +25,7 @@ cr.define('options.system.bluetooth', function() { |
HEADSET: 'headset', |
KEYBOARD: 'input-keyboard', |
MOUSE: 'input-mouse', |
+ TABLET: 'input-tablet', |
PHONE: 'phone', |
}; |
@@ -134,6 +135,12 @@ cr.define('options.system.bluetooth', function() { |
* @return {boolean} True if the devies was successfully added or updated. |
*/ |
appendDevice: function(device) { |
+ if (!device.name || device.name.length == 0) { |
+ device.name = device.address; |
+ var type = this.getDeviceType_(device); |
+ if (type) |
+ device.name = device.name + ' (' + type + ')'; |
+ } |
keybuk
2012/03/02 15:58:02
This is dealt with in the BluetoothDevice C++ now,
kevers
2012/03/02 16:24:39
Done.
|
if (!this.isSupported_(device)) |
return false; |
var index = this.find(device.address); |
@@ -149,6 +156,19 @@ cr.define('options.system.bluetooth', function() { |
}, |
/** |
+ * Forces a revailidation of the list content. Content added while the list |
+ * is hidden is not properly rendered when the list becomes visible. In |
+ * addition, deleting a single item from the list results in a stale cache |
+ * requiring an invalidation. |
+ */ |
+ refresh: function() { |
+ // TODO(kevers): Investigate if the root source of the problems can be |
+ // fixed in cr.ui.list. |
+ this.invalidate(); |
+ this.redraw(); |
+ }, |
+ |
+ /** |
* Perges all devices from the list. |
*/ |
clear: function() { |
@@ -186,10 +206,7 @@ cr.define('options.system.bluetooth', function() { |
[item.address, item.connected ? 'disconnect' : 'forget']); |
} |
this.dataModel.splice(index, 1); |
- // Invalidate the list since it has a stale cache after a splice |
- // involving a deletion. |
- this.invalidate(); |
- this.redraw(); |
+ this.refresh(); |
this.updateListVisibility_(); |
}, |
@@ -209,6 +226,19 @@ cr.define('options.system.bluetooth', function() { |
}, |
/** |
+ * The type of bluetooth device. |
+ " @param {Object.<string,string>} device Description of the device. |
+ * @return {string} The device type. |
+ * @private |
+ */ |
+ getDeviceType_: function(device) { |
+ var name = device.icon; |
+ if (name && name.indexOf('input-') == 0) |
+ name = name.substring(6); |
+ return name; |
+ }, |
keybuk
2012/03/02 15:58:02
The 'icon' property has been dropped from the C++
kevers
2012/03/02 16:24:39
Done.
|
+ |
+ /** |
* If the list has an associated empty list placholder then update the |
* visibility of the list and placeholder. |
* @private |
@@ -217,8 +247,11 @@ cr.define('options.system.bluetooth', function() { |
var empty = this.dataModel.length == 0; |
var listPlaceHolderID = this.id + '-empty-placeholder'; |
if ($(listPlaceHolderID)) { |
- this.hidden = empty; |
- $(listPlaceHolderID).hidden = !empty; |
+ if (this.hidden != empty) { |
+ this.hidden = empty; |
+ $(listPlaceHolderID).hidden = !empty; |
+ this.refresh(); |
+ } |
} |
}, |
}; |