Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5673)

Unified Diff: chrome/renderer/resources/extensions/app_view.js

Issue 354483004: Implement <appview> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@app_view_skeleton
Patch Set: Fixed formatting Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/app_view.js
diff --git a/chrome/renderer/resources/extensions/app_view.js b/chrome/renderer/resources/extensions/app_view.js
index 03174c62d6c627a052518cf5515552cd844bed0e..4b2296294dafc830a4614025ef1c7a2fd66c36d1 100644
--- a/chrome/renderer/resources/extensions/app_view.js
+++ b/chrome/renderer/resources/extensions/app_view.js
@@ -17,6 +17,20 @@ function AppViewInternal(appviewNode) {
this.viewInstanceId = IdGenerator.GetNextId();
}
+AppViewInternal.prototype.getErrorNode = function() {
+ if (!this.errorNode) {
+ this.errorNode = document.createElement('div');
+ this.errorNode.innerText = 'Unable to connect to app.';
+ this.errorNode.style.position = 'absolute';
+ this.errorNode.style.left = '0px';
+ this.errorNode.style.top = '0px';
+ this.errorNode.style.width = '100%';
+ this.errorNode.style.height = '100%';
+ this.appviewNode.shadowRoot.appendChild(this.errorNode);
+ }
+ return this.errorNode;
+};
+
AppViewInternal.prototype.createBrowserPluginNode = function() {
// We create BrowserPlugin as a custom element in order to observe changes
// to attributes synchronously.
@@ -25,28 +39,39 @@ AppViewInternal.prototype.createBrowserPluginNode = function() {
return browserPluginNode;
};
-AppViewInternal.prototype.connect = function(src, callback) {
+AppViewInternal.prototype.connect = function(app, callback) {
var params = {
+ 'appId': app
};
var self = this;
GuestViewInternal.createGuest(
'appview',
params,
function(instanceId) {
- self.attachWindow(instanceId, src);
+ if (!instanceId) {
+ self.browserPluginNode.style.visibility = 'hidden';
+ var errorMsg = 'Unable to connect to app "' + app + '".';
+ window.console.warn(errorMsg);
+ self.getErrorNode().innerText = errorMsg;
+ if (callback) {
+ callback(false);
+ }
+ return;
+ }
+ self.attachWindow(instanceId);
if (callback) {
- callback();
+ callback(true);
}
}
);
};
-AppViewInternal.prototype.attachWindow = function(instanceId, src) {
+AppViewInternal.prototype.attachWindow = function(instanceId) {
this.instanceId = instanceId;
var params = {
'instanceId': this.viewInstanceId,
- 'src': src
};
+ this.browserPluginNode.style.visibility = 'visible';
return this.browserPluginNode['-internal-attach'](instanceId, params);
};

Powered by Google App Engine
This is Rietveld 408576698