Index: content/browser/resources/media/new/player_list_painter.js |
diff --git a/content/browser/resources/media/new/player_list_painter.js b/content/browser/resources/media/new/player_list_painter.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1c564d573e0cbe31a24d0b7066abf5e047a92c84 |
--- /dev/null |
+++ b/content/browser/resources/media/new/player_list_painter.js |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var playerListPainter = (function () { |
+ "use strict"; |
+ var playerListPainter = {}; |
+ |
+ playerListPainter.paintNew = function (playerInfo, div, opt_properties) { |
+ var ul = document.createElement('ul'); |
+ var playerManager = opt_properties.playerManager; |
+ |
+ goog.object.forEach(playerManager.players, function (player, id) { |
+ // If we have the opportunity to name it |
+ // something human readable, do so. |
+ |
+ var name; |
+ // If we have a url, use the file name (but not path) as the |
+ // name that is displayed |
+ if (player.properties.url) { |
+ var split = player.properties.url.split("/"); |
+ name = split[split.length - 1]; |
+ } |
+ |
+ name = name || player.properties.name || "player " + id; |
+ var li = document.createElement('li'); |
+ var btn = document.createElement('button'); |
+ |
+ btn.onclick = function () { |
+ playerManager.selectPlayer(id); |
+ }; |
+ |
+ btn.appendChild(document.createTextNode(name)); |
+ li.appendChild(btn); |
+ ul.appendChild(li); |
+ }); |
+ |
+ removeChildren(div); |
+ div.appendChild(ul); |
+ }; |
+ |
+ playerListPainter.paintExist = playerListPainter.paintNew; |
+ |
+ playerListPainter.invalidate = function () { |
+ }; |
+ |
+ return playerListPainter; |
+}()); |