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

Unified Diff: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js

Issue 1475843002: [MR] Add description field to MediaSink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
index 9424143455d7ceeda04291ac7b6a1290e60e4108..f88b92f24820c2c71d1ce9a6d43649c41bde0be7 100644
--- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
+++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
@@ -390,27 +390,6 @@ Polymer({
},
/**
- * @param {!string} sinkId A sink ID.
- * @return {boolean} Whether or not to hide the route info in the sink list
- * that is associated with |sinkId|.
- * @private
- */
- computeRouteInSinkListHidden_: function(sinkId, sinkToRouteMap) {
- return !sinkToRouteMap[sinkId];
- },
-
- /**
- * @param {!string} sinkId A sink ID.
- * @return {string} The description value of the route associated with
- * |sinkId|.
- * @private
- */
- computeRouteInSinkListValue_: function(sinkId, sinkToRouteMap) {
- var route = sinkToRouteMap[sinkId];
- return route ? route.description : '';
- },
-
- /**
* @param {!Array<!media_router.CastMode>} castModeList The current list of
* cast modes.
* @return {boolean} Whether or not to hide the share screen subheading text.
@@ -487,6 +466,38 @@ Polymer({
},
/**
+ * Returns the subtext to be shown for |sink|. Only called if
+ * |computeSinkSubtextHidden_| returns false for the same |sink| and
+ * |sinkToRouteMap|.
+ * @param {!media_router.Sink} sink
+ * @param {!Object<!string, ?media_router.Route>} sinkToRouteMap
+ * @return {string} The subtext to be shown.
+ * @private
+ */
+ computeSinkSubtext_: function(sink, sinkToRouteMap) {
+ var route = sinkToRouteMap[sink.id];
+ if (route && !this.isEmptyOrWhitespace_(route.description))
+ return route.description;
+
+ return sink.description;
+ },
+
+ /**
+ * Returns whether the sink subtext for |sink| should be hidden.
+ * @param {!media_router.Sink} sink
+ * @param {!Object<!string, ?media_router.Route>} sinkToRouteMap
+ * @return {boolean} |true| if the subtext should be hidden.
+ * @private
+ */
+ computeSinkSubtextHidden_: function(sink, sinkToRouteMap) {
+ if (!this.isEmptyOrWhitespace_(sink.description))
+ return false;
+
+ var route = sinkToRouteMap[sink.id];
+ return !route || this.isEmptyOrWhitespace_(route.description);
+ },
+
+ /**
* @param {boolean} justOpened Whether the MR UI was just opened.
* @return {boolean} Whether or not to hide the spinner.
* @private
@@ -527,6 +538,16 @@ Polymer({
},
/**
+ * Returns whether given string is null, empty, or whitespaces only.
+ * @param {?string} str String to be tested.
+ * @return {boolean} |true| if the string is null, empty, or whitespaces.
+ * @private
+ */
+ isEmptyOrWhitespace_: function(str) {
+ return str === null || (/^\s*$/).test(str);
+ },
+
+ /**
* Updates |currentView_| if the dialog had just opened and there's
* only one local route.
*

Powered by Google App Engine
This is Rietveld 408576698