Chromium Code Reviews| Index: chrome/renderer/resources/extensions/extension_options.js |
| diff --git a/chrome/renderer/resources/extensions/app_view.js b/chrome/renderer/resources/extensions/extension_options.js |
| similarity index 53% |
| copy from chrome/renderer/resources/extensions/app_view.js |
| copy to chrome/renderer/resources/extensions/extension_options.js |
| index 03174c62d6c627a052518cf5515552cd844bed0e..724ac40979ecf98a2be3f6d605902bb6f0a3d476 100644 |
| --- a/chrome/renderer/resources/extensions/app_view.js |
| +++ b/chrome/renderer/resources/extensions/extension_options.js |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -7,48 +7,55 @@ var GuestViewInternal = |
| require('binding').Binding.create('guestViewInternal').generate(); |
| var IdGenerator = requireNative('id_generator'); |
| -function AppViewInternal(appviewNode) { |
| - privates(appviewNode).internal = this; |
| - this.appviewNode = appviewNode; |
| +function ExtensionOptionsInternal(extensionoptionsNode) { |
| + privates(extensionoptionsNode).internal = this; |
| + this.extensionoptionsNode = extensionoptionsNode; |
| this.browserPluginNode = this.createBrowserPluginNode(); |
| - var shadowRoot = this.appviewNode.createShadowRoot(); |
| + var shadowRoot = this.extensionoptionsNode.createShadowRoot(); |
| shadowRoot.appendChild(this.browserPluginNode); |
| this.viewInstanceId = IdGenerator.GetNextId(); |
| + |
| + if (this.parseExtensionAttribute()) { |
| + this.createGuest(); |
| + } |
| } |
| -AppViewInternal.prototype.createBrowserPluginNode = function() { |
| - // We create BrowserPlugin as a custom element in order to observe changes |
| - // to attributes synchronously. |
| - var browserPluginNode = new AppViewInternal.BrowserPlugin(); |
| +ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { |
| + var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin(); |
| privates(browserPluginNode).internal = this; |
| return browserPluginNode; |
| -}; |
| +} |
| -AppViewInternal.prototype.connect = function(src, callback) { |
| +ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() { |
| + if (this.extensionoptionsNode.hasAttribute('extension')) { |
| + this.extensionId = this.extensionoptionsNode.getAttribute('extension'); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +ExtensionOptionsInternal.prototype.createGuest = function() { |
| var params = { |
| + 'extensionId': this.extensionId, |
| }; |
| var self = this; |
| GuestViewInternal.createGuest( |
| - 'appview', |
| - params, |
| - function(instanceId) { |
| - self.attachWindow(instanceId, src); |
| - if (callback) { |
| - callback(); |
| - } |
| - } |
| - ); |
| + 'extensionoptions', |
| + params, |
| + function(instanceId) { |
| + self.instanceId = instanceId; |
| + self.attachWindow(instanceId); |
| + }); |
| }; |
| -AppViewInternal.prototype.attachWindow = function(instanceId, src) { |
| +ExtensionOptionsInternal.prototype.attachWindow = function(instanceId) { |
| this.instanceId = instanceId; |
| var params = { |
| 'instanceId': this.viewInstanceId, |
| - 'src': src |
| - }; |
| + } |
| return this.browserPluginNode['-internal-attach'](instanceId, params); |
| -}; |
| +} |
| function registerBrowserPluginElement() { |
| var proto = Object.create(HTMLObjectElement.prototype); |
| @@ -64,36 +71,26 @@ function registerBrowserPluginElement() { |
| var unused = this.nonExistentAttribute; |
| }; |
| - AppViewInternal.BrowserPlugin = |
| - DocumentNatives.RegisterElement('appplugin', {extends: 'object', |
| - prototype: proto}); |
| - |
| + ExtensionOptionsInternal.BrowserPlugin = |
| + DocumentNatives.RegisterElement("extensionoptionsplugin", |
| + {extends: 'object', prototype: proto}); |
| delete proto.createdCallback; |
| delete proto.attachedCallback; |
| - delete proto.detachedCallback; |
| - delete proto.attributeChangedCallback; |
|
Fady Samuel
2014/07/11 21:08:05
You want to delete these callbacks too.
ericzeng
2014/07/12 00:10:05
Done.
|
| } |
| -function registerAppViewElement() { |
| +function registerExtensionOptionsElement() { |
| var proto = Object.create(HTMLElement.prototype); |
| proto.createdCallback = function() { |
| - new AppViewInternal(this); |
| - }; |
| - |
| - proto.connect = function() { |
| - var internal = privates(this).internal; |
| - $Function.apply(internal.connect, internal, arguments); |
| + new ExtensionOptionsInternal(this); |
| } |
| - window.AppView = |
| - DocumentNatives.RegisterElement('appview', {prototype: proto}); |
| + |
| + window.ExtensionOptions = |
| + DocumentNatives.RegisterElement('extensionoptions', {prototype: proto}); |
| // Delete the callbacks so developers cannot call them and produce unexpected |
| // behavior. |
| delete proto.createdCallback; |
| - delete proto.attachedCallback; |
| - delete proto.detachedCallback; |
| - delete proto.attributeChangedCallback; |
|
Fady Samuel
2014/07/11 21:08:05
You want to delete these callbacks too.
ericzeng
2014/07/12 00:10:05
Done.
|
| } |
| var useCapture = true; |
| @@ -102,6 +99,6 @@ window.addEventListener('readystatechange', function listener(event) { |
| return; |
| registerBrowserPluginElement(); |
| - registerAppViewElement(); |
| + registerExtensionOptionsElement(); |
| window.removeEventListener(event.type, listener, useCapture); |
| }, useCapture); |