Chromium Code Reviews| Index: chrome/browser/resources/media_router/elements/route_details/route_details.js |
| diff --git a/chrome/browser/resources/media_router/elements/route_details/route_details.js b/chrome/browser/resources/media_router/elements/route_details/route_details.js |
| index ae7ebcca5e1d63a66b704f13ce420e12c896879c..2e2d443e8ba0b96fbdf813c3f4ff998e7c108f21 100644 |
| --- a/chrome/browser/resources/media_router/elements/route_details/route_details.js |
| +++ b/chrome/browser/resources/media_router/elements/route_details/route_details.js |
| @@ -24,7 +24,7 @@ Polymer({ |
| changeRouteSourceAvailable_: { |
| type: Boolean, |
| computed: 'computeChangeRouteSourceAvailable_(route, sink,' + |
| - 'isAnySinkCurrentlyLaunching, shownCastModeValue)', |
| + 'isAnySinkCurrentlyLaunching, shownCastModeValue)', |
| }, |
| /** |
| @@ -37,12 +37,23 @@ Polymer({ |
| }, |
| /** |
| + * Whether the custom controller extension view should be hidden. |
| + * The extension view is shown iff |route| specifies customControllerPath, |
| + * the view can be loaded, and we are not using the new controls. |
| + * @private {boolean} |
| + */ |
| + isExtensionViewHidden_: { |
| + type: Boolean, |
| + value: true, |
| + }, |
| + |
| + /** |
| * The route to show. |
| * @type {?media_router.Route|undefined} |
| */ |
| route: { |
| type: Object, |
| - observer: 'maybeLoadCustomController_', |
| + observer: 'onRouteChange_', |
| }, |
| /** |
| @@ -65,15 +76,13 @@ Polymer({ |
| }, |
| /** |
| - * Whether the custom controller should be hidden. |
| - * A custom controller is shown iff |route| specifies customControllerPath |
| - * and the view can be loaded. |
| - * @private {boolean} |
| + * Whether we should use the new route controls. If false, we use the |
| + * extension view. |
| */ |
| - isCustomControllerHidden_: { |
| + useNewRouteControls: { |
| type: Boolean, |
| - value: true, |
| - }, |
| + value: false, |
| + } |
| }, |
| behaviors: [ |
| @@ -87,6 +96,7 @@ Polymer({ |
| * @private |
| */ |
| closeRoute_: function() { |
| + this.routeStatus = null; |
| this.fire('close-route', {route: this.route}); |
| }, |
| @@ -155,41 +165,20 @@ Polymer({ |
| }, |
| /** |
| - * Fires a join-route-click event if the current route is joinable, otherwise |
| - * it fires a change-route-source-click event, which changes the source of the |
| - * current route. This may cause the current route to be closed and a new |
| - * route to be started. This is called when the button to start casting to the |
| - * current route is clicked. |
| - * |
| - * @private |
| - */ |
| - startCastingToRoute_: function() { |
| - if (this.route.canJoin) { |
| - this.fire('join-route-click', {route: this.route}); |
| - } else { |
| - this.fire('change-route-source-click', { |
| - route: this.route, |
| - selectedCastMode: |
| - this.computeSelectedCastMode_(this.shownCastModeValue, this.sink) |
| - }); |
| - } |
| - }, |
| - |
| - /** |
| * Loads the custom controller if |route.customControllerPath| exists. |
| * Falls back to the default route details view otherwise, or if load fails. |
| * Updates |activityStatus_| for the default view. |
| * |
| * @private |
| */ |
| - maybeLoadCustomController_: function() { |
| + maybeLoadExtensionView_: function() { |
| this.activityStatus_ = this.route ? |
| loadTimeData.getStringF('castingActivityStatus', |
| this.route.description) : |
| ''; |
| if (!this.route || !this.route.customControllerPath) { |
| - this.isCustomControllerHidden_ = true; |
| + this.isExtensionViewHidden_ = true; |
| return; |
| } |
| @@ -198,17 +187,88 @@ Polymer({ |
| // Do nothing if the url is the same and the view is not hidden. |
| if (this.route.customControllerPath == extensionview.src && |
| - !this.isCustomControllerHidden_) |
| + !this.isExtensionViewHidden_) |
| return; |
| var that = this; |
| extensionview.load(this.route.customControllerPath) |
| .then(function() { |
| // Load was successful; show the custom controller. |
| - that.isCustomControllerHidden_ = false; |
| + that.isExtensionViewHidden_ = false; |
| }, function() { |
| // Load was unsuccessful; fall back to default view. |
| - that.isCustomControllerHidden_ = true; |
| + that.isExtensionViewHidden_ = true; |
| }); |
| }, |
| + |
| + /** |
| + * Called when the route details view is closed. |
| + */ |
| + onClosed: function() { |
| + this.$$('route-controls').onRouteDetailsClosed(); |
| + }, |
| + |
| + /** |
| + * Called when the route details view is opened. |
| + */ |
| + onOpened: function() { |
| + media_router.ui.setRouteControls(this.$$('route-controls')); |
| + }, |
| + |
| + /** |
| + * Updates either the extension view or the new route controller, depending on |
| + * which should be shown. |
| + * @private |
| + */ |
| + onRouteChange_: function(newRoute) { |
| + if (!this.useNewRouteControls) |
| + this.maybeLoadExtensionView_(); |
| + |
| + if (newRoute) |
| + this.$$('route-controls').route = newRoute; |
| + }, |
| + |
| + /** |
| + * @param {bool} useNewRouteControls |
| + * @param {bool} isExtensionViewHidden |
| + * @return {bool} Whether the extension view should be shown instead of the |
| + * default route info element or the new route controller. |
| + * @private |
| + */ |
| + shouldShowExtensionView_: function(useNewRouteControls, |
| + isExtensionViewHidden) { |
| + return !useNewRouteControls && !isExtensionViewHidden; |
|
mark a. foltz
2017/05/03 21:27:01
If !isExtensionViewHidden is it already being show
takumif
2017/05/05 18:57:40
Renamed the variable to isExtensionViewReady
|
| + }, |
| + |
| + /** |
| + * @param {bool} useNewRouteControls |
| + * @param {bool} isExtensionViewHidden |
| + * @return {bool} Whether the route info element should be shown instead of |
| + * the extension view or the new route controller. |
| + * @private |
| + */ |
| + shouldShowRouteInfo_: function(useNewRouteControls, isExtensionViewHidden) { |
|
mark a. foltz
2017/05/03 21:27:01
Is this for routes that have no media controls?
It
takumif
2017/05/05 18:57:40
This is for when extension view is enabled but the
|
| + return !useNewRouteControls && isExtensionViewHidden; |
| + }, |
| + |
| + /** |
| + * Fires a join-route-click event if the current route is joinable, otherwise |
| + * it fires a change-route-source-click event, which changes the source of the |
| + * current route. This may cause the current route to be closed and a new |
| + * route to be started. This is called when the button to start casting to the |
| + * current route is clicked. |
| + * |
| + * @private |
| + */ |
| + startCastingToRoute_: function() { |
| + if (this.route.canJoin) { |
|
mark a. foltz
2017/05/03 21:27:01
"Joining" or "changing source" should just be anot
takumif
2017/05/05 18:57:40
Acknowledged.
|
| + this.fire('join-route-click', {route: this.route}); |
| + } else { |
| + this.fire('change-route-source-click', { |
| + route: this.route, |
| + selectedCastMode: |
| + this.computeSelectedCastMode_(this.shownCastModeValue, this.sink) |
| + }); |
| + } |
| + }, |
| }); |