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.
5 // This module implements the public-facing API functions for the
6 // <extensionview> tag.
8 var ExtensionViewInternal =
9 require('extensionViewInternal').ExtensionViewInternal;
10 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl;
11 var ExtensionViewConstants =
12 require('extensionViewConstants').ExtensionViewConstants;
14 // An array of <extensionview>'s public-facing API methods.
15 var EXTENSION_VIEW_API_METHODS = [
16 // Loads the given src into extensionview. Must be called every time the
17 // the extensionview should load a new page. This is the only way to set
18 // the extension and src attributes. Returns a promise indicating whether
19 // or not load was successful.
23 // -----------------------------------------------------------------------------
24 // Custom API method implementations.
26 ExtensionViewImpl.prototype.load = function(src) {
27 return new Promise(function(resolve, reject) {
28 this.loadQueue.push({src: src, resolve: resolve, reject: reject});
31 .then(function onLoadResolved() {
32 this.pendingLoad = null;
34 }.bind(this), function onLoadRejected() {
35 this.pendingLoad = null;
37 reject('Failed to load.');
41 // -----------------------------------------------------------------------------
43 ExtensionViewImpl.getApiMethods = function() {
44 return EXTENSION_VIEW_API_METHODS;