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

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

Issue 1680743006: [Media Router] Show user email in header if cloud sink is present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix breaks in native code and address comments. Everything works with no bugs detected in this pat… Created 4 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
Index: chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
diff --git a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
index 3afac7f4c94f5f801b7cd3894fa72c585f64f2aa..72ff40f254624433a70d4db8b031abcd585bde73 100644
--- a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
+++ b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
@@ -36,13 +36,23 @@ Polymer({
},
/**
- * The current view that this header should reflect.
- * @type {?media_router.MediaRouterView}
+ * The height of the header when it shows the user email.
+ * @private {number}
*/
- view: {
- type: String,
- value: null,
- observer: 'updateHeaderCursorStyle_',
+ headerWithEmailHeight_: {
+ type: Number,
+ readOnly: true,
+ value: 62,
imcheng 2016/02/17 00:51:08 nit: seems like you can just make this a String '6
amp 2016/02/17 02:11:37 It would work as a string, but if we ever need to
+ },
+
+ /**
+ * Whether to show the user email in the header.
+ * @type {boolean}
+ */
+ showEmail: {
+ type: Boolean,
+ value: false,
+ observer: 'maybeChangeHeaderHeight_',
},
/**
@@ -53,6 +63,25 @@ Polymer({
type: String,
value: '',
},
+
+ /**
+ * The user email if they are signed in.
+ * @type {string}
+ */
+ userEmail: {
+ type: String,
+ value: '',
+ },
+
+ /**
+ * The current view that this header should reflect.
+ * @type {?media_router.MediaRouterView}
+ */
+ view: {
+ type: String,
+ value: null,
+ observer: 'updateHeaderCursorStyle_',
+ },
},
attached: function() {
@@ -121,6 +150,36 @@ Polymer({
},
/**
+ * Updates header height to accomodate email text. This is called on changes
+ * to |showEmail| and will return early if the value has not changed.
+ *
+ * @param {boolean} oldValue .
+ * @param {boolean} newValue .
+ * @private
+ */
+ maybeChangeHeaderHeight_: function(oldValue, newValue) {
+ if (oldValue == newValue) {
+ return;
+ }
+
+ // Ensures conditional templates are stamped.
+ this.async(function() {
+ var currentHeight = this.offsetHeight;
+
+ this.$$('#header-toolbar').style.height =
+ this.showEmail &&
+ !$('media-router-container').isEmptyOrWhitespace_(this.userEmail) ?
+ this.headerWithEmailHeight_ + 'px' : undefined;
+
+ var newHeight = this.offsetHeight;
+ // Only fire if height actually changed.
+ if (currentHeight != newHeight) {
+ this.fire('header-height-changed');
+ }
+ });
+ },
+
+ /**
* Updates the cursor style for the header text when the view changes. When
* the drop arrow is also shown, the header text is also clickable.
*

Powered by Google App Engine
This is Rietveld 408576698