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

Unified Diff: content/browser/resources/media/new/player_manager.js

Issue 18889006: Removed old media-internals page and rewrote it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved all 'new' media internals files into its own folder for a smooth transition. Created 7 years, 5 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: content/browser/resources/media/new/player_manager.js
diff --git a/content/browser/resources/media/new/player_manager.js b/content/browser/resources/media/new/player_manager.js
new file mode 100644
index 0000000000000000000000000000000000000000..0384c861c9b489e9777041b3a5c46f23785ed51f
--- /dev/null
+++ b/content/browser/resources/media/new/player_manager.js
@@ -0,0 +1,103 @@
+// 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.
+
+
+/**
+ * @fileoverview Keeps track of all the existing
+ * PlayerProperty objects and is the entry-point for messages from the backend.
+ */
+var PlayerManager = (function () {
+ "use strict";
+
+ function PlayerManager() {
+ this.players = {};
+ this.renderman = new RenderManager(this);
+
+ var removeCheckbox = document.querySelector("#removal-checkbox");
+ this.shouldRemovePlayer = function () {
+ return removeCheckbox.checked;
+ };
+ removeCheckbox.onclick = function () {
+ if (removeCheckbox.checked) {
+ goog.object.forEach(this.players, function (playerInfo, id) {
+ if (playerInfo.toRemove) {
+ this.removePlayer(id);
+ }
+ }, this);
+ }
+ }.bind(this);
+ }
+
+
+ /**
+ * Adds a player to the list of players to manage.
+ */
+ PlayerManager.prototype.addPlayer = function (id) {
+ if (this.players[id]) {
+ return;
+ }
+ // Make the PlayerProperty and add it to the mapping
+ this.players[id] = new PlayerInfo(id);
+
+ this.renderman.redrawList();
+ };
+
+ PlayerManager.prototype.removePlayer = function (id) {
+ if (this.shouldRemovePlayer()) {
+ delete this.players[id];
+ } else if (this.players[id]) {
+ this.players[id].toRemove = true;
+ }
+ this.renderman.redrawList();
+ };
+
+
+ PlayerManager.prototype.selectPlayer = function (id) {
+ if (!this.players[id]) {
+ throw new Error("[selectPlayer] Id " + id + " does not exist.");
+ }
+
+ this.renderman.select(id);
+ };
+
+ PlayerManager.prototype.updatePlayerInfoNoRecord =
+ function (id, timestamp, key, value) {
+ if (!this.players[id]) {
+ console.error("[updatePlayerInfo] Id " + id +
+ " does not exist");
+ return;
+ }
+
+ this.players[id].addPropertyNoRecord(timestamp, key, value);
+
+
+ // If we can potentially rename the player, do so.
+ if (key === 'name' || key === 'url') {
+ this.renderman.redrawList();
+ }
+
+ this.renderman.update();
+ };
+
+ PlayerManager.prototype.updatePlayerInfo =
+ function (id, timestamp, key, value) {
+ if (!this.players[id]) {
+ console.error("[updatePlayerInfo] Id " + id +
+ " does not exist");
+ return;
+ }
+
+ this.players[id].addProperty(timestamp, key, value);
+
+
+ // If we can potentially rename the player, do so.
+ if (key === 'name' || key === 'url') {
+ this.renderman.redrawList();
+ }
+
+ this.renderman.update();
+ };
+
+ return PlayerManager;
+}());
« no previous file with comments | « content/browser/resources/media/new/player_list_painter.js ('k') | content/browser/resources/media/new/property_painter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698