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

Unified Diff: chrome/browser/resources/options2/chromeos/bluetooth_device_list.js

Issue 9570018: Fix Bluetooth list redraw issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add parameter description. Created 8 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }
}
},
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698