Example #1
0
WebViewImpl.setupElement = function(proto) {
  // Public-facing API methods.
  var apiMethods = WebViewImpl.getApiMethods();

  // Create default implementations for undefined API methods.
  var createDefaultApiMethod = function(m) {
    return function(var_args) {
      if (!this.guest.getId()) {
        return false;
      }
      var args = $Array.concat([this.guest.getId()], $Array.slice(arguments));
      $Function.apply(WebViewInternal[m], null, args);
      return true;
    };
  };
  for (var i = 0; i != apiMethods.length; ++i) {
    if (WebViewImpl.prototype[apiMethods[i]] == undefined) {
      WebViewImpl.prototype[apiMethods[i]] =
          createDefaultApiMethod(apiMethods[i]);
    }
  }

  // Forward proto.foo* method calls to WebViewImpl.foo*.
  GuestViewContainer.forwardApiMethods(proto, apiMethods);
};
AppViewImpl.setupElement = function(proto) {
  var apiMethods = [
    'connect'
  ];

  // Forward proto.foo* method calls to AppViewImpl.foo*.
  GuestViewContainer.forwardApiMethods(proto, apiMethods);
}
ExtensionOptionsImpl.setupElement = function(proto) {
  var apiMethods = [
    'setDeferAutoSize',
    'resumeDeferredAutoSize'
  ];

  // Forward proto.foo* method calls to ExtensionOptionsImpl.foo*.
  GuestViewContainer.forwardApiMethods(proto, apiMethods);
}
// Represents the internal state of <webview>.
function WebViewImpl(webviewElement) {
  GuestViewContainer.call(this, webviewElement, 'webview');

  this.beforeFirstNavigation = true;

  this.setupWebViewAttributes();
  this.setupElementProperties();

  // on* Event handlers.
  this.on = {};
  new WebViewEvents(this, this.viewInstanceId);
}
function ExtensionOptionsImpl(extensionoptionsElement) {
  GuestViewContainer.call(this, extensionoptionsElement, 'extensionoptions');

  // on* Event handlers.
  this.eventHandlers = {};

  // setupEventProperty is normally called in extension_options_events.js to
  // register events, but the createfailed event is registered here because
  // the event is fired from here instead of through
  // extension_options_events.js.
  this.setupEventProperty('createfailed');
  new ExtensionOptionsEvents(this, this.viewInstanceId);

  this.autosizeDeferred = false;

  this.setupElementProperties();
};
function AppViewImpl(appviewElement) {
  GuestViewContainer.call(this, appviewElement, 'appview');
}
  if (!this.elementAttached) {
    if (callback) {
      callback(false);
    }
    return;
  }
  var createParams = {
    'appId': app,
    'data': data || {}
  };

  this.guest.destroy();
  this.guest.create(createParams, function() {
    if (!this.guest.getId()) {
      var errorMsg = 'Unable to connect to app "' + app + '".';
      window.console.warn(errorMsg);
      this.getErrorNode().innerText = errorMsg;
      if (callback) {
        callback(false);
      }
      return;
    }
    this.attachWindow();
    if (callback) {
      callback(true);
    }
  }.bind(this));
};

GuestViewContainer.registerElement(AppViewImpl);
Example #8
0
// Represents the internal state of <webview>.
function WebViewImpl(webviewElement) {
  GuestViewContainer.call(this, webviewElement, 'webview');
  this.cachedZoom = 1;
  this.setupElementProperties();
  new WebViewEvents(this, this.viewInstanceId);
}
Example #9
0
  if (!this.guest.getId()) {
    window.console.error(WebViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT);
    return false;
  }

  var webviewSrc = this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue();
  if (this.baseUrlForDataUrl) {
    webviewSrc = this.baseUrlForDataUrl;
  }

  args = $Array.concat([this.guest.getId(), webviewSrc],
                       $Array.slice(args));
  $Function.apply(func, null, args);
  return true;
}

// Requests the <webview> element wihtin the embedder to enter fullscreen.
WebViewImpl.prototype.makeElementFullscreen = function() {
  GuestViewInternalNatives.RunWithGesture(function() {
    this.element.webkitRequestFullScreen();
  }.bind(this));
};

// Implemented when the ChromeWebView API is available.
WebViewImpl.prototype.maybeSetupContextMenus = function() {};

GuestViewContainer.registerElement(WebViewImpl);

// Exports.
exports.WebViewImpl = WebViewImpl;
/**
 * Toggles whether the element should automatically resize to its preferred
 * size. If set to true, when the element receives new autosize dimensions,
 * it passes them to the embedder in a sizechanged event, but does not resize
 * itself to those dimensions until the embedder calls resumeDeferredAutoSize.
 * This allows the embedder to defer the resizing until it is ready.
 * When set to false, the element resizes whenever it receives new autosize
 * dimensions.
 */
ExtensionOptionsImpl.prototype.setDeferAutoSize = function(value) {
  if (!value)
    resumeDeferredAutoSize();
  this.autosizeDeferred = value;
};

/**
 * Allows the element to resize to most recent set of autosize dimensions if
 * autosizing is being deferred.
 */
ExtensionOptionsImpl.prototype.resumeDeferredAutoSize = function() {
  if (this.autosizeDeferred) {
    this.resize(this.deferredAutoSizeState.newWidth,
                this.deferredAutoSizeState.newHeight,
                this.deferredAutoSizeState.oldWidth,
                this.deferredAutoSizeState.oldHeight);
  }
};

GuestViewContainer.registerElement(ExtensionOptionsImpl);
function SurfaceViewImpl(surfaceviewElement) {
  GuestViewContainer.call(this, surfaceviewElement, 'surfaceview');
}
    'connect'
  ];

  // Forward proto.foo* method calls to SurfaceViewImpl.foo*.
  GuestViewContainer.forwardApiMethods(proto, apiMethods);
}

SurfaceViewImpl.prototype.connect = function(url, callback) {
  if (!this.elementAttached) {
    if (callback) {
      callback(false);
    }
    return;
  }

  this.guest.destroy();

  var createParams = {
    'url': url
  };

  this.guest.create(createParams, function() {
    this.attachWindow();
    if (callback) {
      callback(true);
    }
  }.bind(this));
};

GuestViewContainer.registerElement(SurfaceViewImpl);
Example #13
0
function AppViewImpl(appviewElement) {
  GuestViewContainer.call(this, appviewElement, 'appview');

  this.app = '';
  this.data = '';
}
Example #14
0
function ExtensionOptionsImpl(extensionoptionsElement) {
  GuestViewContainer.call(this, extensionoptionsElement, 'extensionoptions');

  new ExtensionOptionsEvents(this);
};