1 // Copyright 2014 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 var DocumentNatives = requireNative('document_natives');
6 var GuestView = require('guestView').GuestView;
7 var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
8 var IdGenerator = requireNative('id_generator');
10 function AppViewImpl(appviewElement) {
11 GuestViewContainer.call(this, appviewElement, 'appview');
17 AppViewImpl.prototype.__proto__ = GuestViewContainer.prototype;
19 AppViewImpl.VIEW_TYPE = 'AppView';
21 // Add extra functionality to |this.element|.
22 AppViewImpl.setupElement = function(proto) {
27 // Forward proto.foo* method calls to AppViewImpl.foo*.
28 GuestViewContainer.forwardApiMethods(proto, apiMethods);
31 AppViewImpl.prototype.getErrorNode = function() {
32 if (!this.errorNode) {
33 this.errorNode = document.createElement('div');
34 this.errorNode.innerText = 'Unable to connect to app.';
35 this.errorNode.style.position = 'absolute';
36 this.errorNode.style.left = '0px';
37 this.errorNode.style.top = '0px';
38 this.errorNode.style.width = '100%';
39 this.errorNode.style.height = '100%';
40 this.element.shadowRoot.appendChild(this.errorNode);
42 return this.errorNode;
45 AppViewImpl.prototype.buildContainerParams = function() {
48 'data': this.data || {}
52 AppViewImpl.prototype.connect = function(app, data, callback) {
53 if (!this.elementAttached) {
64 this.guest.create(this.buildParams(), function() {
65 if (!this.guest.getId()) {
66 var errorMsg = 'Unable to connect to app "' + app + '".';
67 window.console.warn(errorMsg);
68 this.getErrorNode().innerText = errorMsg;
81 GuestViewContainer.registerElement(AppViewImpl);