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

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

Issue 1413403003: [Media Router] Auto-close Media Router dialog after starting or stopping a session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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_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 97a12730001de3168e046345628f476e393a527e..a49d23d73a87893c11cc7d95432333f048ad8706 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
@@ -194,11 +194,25 @@ Polymer({
type: Array,
value: [],
},
+
+ /**
+ * List of active timer IDs. Used to retrieve active timer IDs when
+ * clearing timers.
+ * @private {!Array<number>}
+ */
+ timerIdList_: {
+ type: Array,
+ value: [],
+ },
+ },
+
+ listeners: {
+ 'tap': 'onTap_',
},
ready: function() {
this.addEventListener('arrow-drop-click', this.toggleCastModeHidden_);
- this.addEventListener('close-route-click', this.removeRoute);
+ this.addEventListener('close-route-click', this.startTapTimer_);
imcheng 2015/10/22 18:44:14 I see that there is also an event handler for clos
apacible 2015/10/23 18:03:11 Done.
this.showSinkList_();
},
@@ -558,6 +572,8 @@ Polymer({
// which results in the correct sink to route mapping.
this.routeList.push(route);
this.showRouteDetails_(route);
+
+ this.startTapTimer_();
},
onNotifyRouteCreationTimeout: function() {
@@ -575,6 +591,24 @@ Polymer({
},
/**
+ * Called when a tap event is triggered. Clears any active timers. onTap_
+ * is called before a new timer is started for taps that trigger a new active
+ * timer.
+ *
+ * @private
+ */
+ onTap_: function(e) {
+ if (this.timerIdList_.length == 0)
+ return;
+
+ this.timerIdList_.forEach(function(id) {
+ clearTimeout(id);
+ }, this);
+
+ this.timerIdList_ = [];
+ },
+
+ /**
* Called when |routeList| is updated. Rebuilds |routeMap_| and
* |sinkToRouteMap_|.
*
@@ -719,6 +753,20 @@ Polymer({
},
/**
+ * Starts a timer which fires a close-dialog event if the timer has not been
+ * cleared within three seconds.
+ *
+ * @private
+ */
+ startTapTimer_: function() {
+ var id = setTimeout(function() {
+ this.fire('close-dialog');
+ }.bind(this), 3000 /* 3 seconds */);
+
+ this.timerIdList_.push(id);
+ },
+
+ /**
* Toggles |currentView_| between CAST_MODE_LIST and SINK_LIST.
*
* @private

Powered by Google App Engine
This is Rietveld 408576698