Chromium Code Reviews| Index: chrome/browser/resources/media_router/elements/route_details/extension_view_wrapper/extension_view_wrapper.js |
| diff --git a/chrome/browser/resources/media_router/elements/route_details/extension_view_wrapper/extension_view_wrapper.js b/chrome/browser/resources/media_router/elements/route_details/extension_view_wrapper/extension_view_wrapper.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b7f83018c6da433f277194960d46f5d8281a2367 |
| --- /dev/null |
| +++ b/chrome/browser/resources/media_router/elements/route_details/extension_view_wrapper/extension_view_wrapper.js |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2017 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. |
| + |
| +// This Polymer element shows the custom controller for a route using extension |
|
apacible
2017/05/17 21:52:17
nit: extensionview (one word)
takumif
2017/05/18 18:01:55
Done.
|
| +// view. |
| +Polymer({ |
| + is: 'extension-view-wrapper', |
| + |
| + properties: { |
| + /** |
| + * The route to show the custom controller for. |
| + * @type {?media_router.Route|undefined} |
| + */ |
| + route: { |
| + type: Object, |
| + observer: 'maybeLoadExtensionView_', |
| + }, |
| + |
| + /** |
| + * Whether the extension view is ready to be shown. |
| + * @type {boolean} |
| + */ |
| + isExtensionViewReady: { |
| + type: Boolean, |
| + value: false, |
| + notify: true, |
| + }, |
| + }, |
| + |
| + /** |
| + * Loads the custom controller if the controller path for the current route is |
| + * valid. |
| + */ |
| + maybeLoadExtensionView_: function() { |
| + var extensionview = this.$['custom-controller']; |
| + |
| + // Do nothing if the controller path doesn't exist or is already shown in |
| + // the extension view. |
| + if (!this.route || |
| + !this.route.customControllerPath || |
| + this.route.customControllerPath == extensionview.src) { |
| + return; |
| + } |
| + |
| + var that = this; |
| + extensionview.load(this.route.customControllerPath) |
| + .then(function() { |
| + // Load was successful; show the custom controller. |
| + that.isExtensionViewReady = true; |
| + }, function() { |
| + // Load was unsuccessful; fall back to default view. |
| + that.isExtensionViewReady = false; |
| + }); |
| + }, |
| + |
| + /** |
| + * Called by Polymer when this module has loaded. |
| + */ |
| + ready: function() { |
| + this.maybeLoadExtensionView_(); |
| + }, |
| +}); |