OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This module implements the public-facing API functions for the |
| 6 // <extensionview> tag. |
| 7 |
| 8 var ExtensionViewInternal = |
| 9 require('extensionViewInternal').ExtensionViewInternal; |
| 10 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl; |
| 11 var ExtensionViewConstants = |
| 12 require('extensionViewConstants').ExtensionViewConstants; |
| 13 |
| 14 // An array of <extensionview>'s public-facing API methods. |
| 15 var EXTENSION_VIEW_API_METHODS = [ |
| 16 // Sets the extension ID and src for the guest. Must be called every time |
| 17 // the extension ID changes. This is the only way to set the extension ID. |
| 18 'connect' |
| 19 ]; |
| 20 |
| 21 // ----------------------------------------------------------------------------- |
| 22 // Custom API method implementations. |
| 23 |
| 24 ExtensionViewImpl.prototype.connect = function(extension, src) { |
| 25 this.guest.destroy(); |
| 26 |
| 27 // Sets the extension id and src. |
| 28 this.attributes[ExtensionViewConstants.ATTRIBUTE_EXTENSION] |
| 29 .setValueIgnoreMutation(extension); |
| 30 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] |
| 31 .setValueIgnoreMutation(src); |
| 32 |
| 33 this.createGuest(); |
| 34 }; |
| 35 |
| 36 // ----------------------------------------------------------------------------- |
| 37 |
| 38 ExtensionViewImpl.getApiMethods = function() { |
| 39 return EXTENSION_VIEW_API_METHODS; |
| 40 }; |
OLD | NEW |