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

Side by Side Diff: chrome/renderer/resources/extensions/extension_options.js

Issue 453613002: Implement support for <extensionoptions> embedding in WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var DocumentNatives = requireNative('document_natives'); 5 var DocumentNatives = requireNative('document_natives');
6 var ExtensionOptionsEvents = 6 var ExtensionOptionsEvents =
7 require('extensionOptionsEvents').ExtensionOptionsEvents; 7 require('extensionOptionsEvents').ExtensionOptionsEvents;
8 var GuestViewInternal = 8 var GuestViewInternal =
9 require('binding').Binding.create('guestViewInternal').generate(); 9 require('binding').Binding.create('guestViewInternal').generate();
10 var IdGenerator = requireNative('id_generator'); 10 var IdGenerator = requireNative('id_generator');
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { 50 ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() {
51 var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin(); 51 var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin();
52 privates(browserPluginNode).internal = this; 52 privates(browserPluginNode).internal = this;
53 return browserPluginNode; 53 return browserPluginNode;
54 }; 54 };
55 55
56 ExtensionOptionsInternal.prototype.createGuest = function() { 56 ExtensionOptionsInternal.prototype.createGuest = function() {
57 var params = { 57 var params = {
58 'extensionId': this.extensionId, 58 'extensionId': this.extensionId,
59 }; 59 };
60
60 GuestViewInternal.createGuest( 61 GuestViewInternal.createGuest(
61 'extensionoptions', 62 'extensionoptions',
62 params, 63 params,
63 function(instanceId) { 64 function(instanceId) {
64 if (instanceId == 0) { 65 if (instanceId == 0) {
65 this.initCalled = false; 66 this.initCalled = false;
66 } else { 67 } else {
67 this.attachWindow(instanceId); 68 this.attachWindow(instanceId);
68 GuestViewInternal.setAutoSize(this.instanceId, { 69 GuestViewInternal.setAutoSize(this.instanceId, {
69 'enableAutoSize': 70 'enableAutoSize':
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 }); 124 });
124 } 125 }
125 }; 126 };
126 127
127 ExtensionOptionsInternal.prototype.init = function() { 128 ExtensionOptionsInternal.prototype.init = function() {
128 if (this.initCalled) 129 if (this.initCalled)
129 return; 130 return;
130 131
131 this.initCalled = true; 132 this.initCalled = true;
133
132 this.browserPluginNode = this.createBrowserPluginNode(); 134 this.browserPluginNode = this.createBrowserPluginNode();
135
133 var shadowRoot = this.extensionoptionsNode.createShadowRoot(); 136 var shadowRoot = this.extensionoptionsNode.createShadowRoot();
134 shadowRoot.appendChild(this.browserPluginNode); 137 shadowRoot.appendChild(this.browserPluginNode);
135 this.createGuest(); 138 this.createGuest();
136 }; 139 };
137 140
138 ExtensionOptionsInternal.prototype.onSizeChanged = function(width, height) { 141 ExtensionOptionsInternal.prototype.onSizeChanged = function(width, height) {
139 this.browserPluginNode.style.width = width + 'px'; 142 this.browserPluginNode.style.width = width + 'px';
140 this.browserPluginNode.style.height = height + 'px'; 143 this.browserPluginNode.style.height = height + 'px';
141 }; 144 };
142 145
143 ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() { 146 ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() {
144 if (this.extensionoptionsNode.hasAttribute('extension')) { 147 if (this.extensionoptionsNode.hasAttribute('extension')) {
145 var extensionId = this.extensionoptionsNode.getAttribute('extension'); 148 this.extensionId = this.extensionoptionsNode.getAttribute('extension');
146 // Only allow extensions to embed their own options page (if it has one). 149 return true;
not at google - send to devlin 2014/08/07 23:06:03 was this security check important? because now the
ericzeng 2014/08/08 00:23:47 No, the checks will be unnecessary when I rebase o
147 if (chrome.runtime.id == extensionId &&
148 chrome.runtime.getManifest().hasOwnProperty('options_page')) {
149 this.extensionId = extensionId;
150 return true;
151 }
152 } 150 }
153 return false; 151 return false;
154 }; 152 };
155 153
156 // Adds an 'on<event>' property on the view, which can be used to set/unset 154 // Adds an 'on<event>' property on the view, which can be used to set/unset
157 // an event handler. 155 // an event handler.
158 ExtensionOptionsInternal.prototype.setupEventProperty = function(eventName) { 156 ExtensionOptionsInternal.prototype.setupEventProperty = function(eventName) {
159 var propertyName = 'on' + eventName.toLowerCase(); 157 var propertyName = 'on' + eventName.toLowerCase();
160 var self = this; 158 var self = this;
161 var extensionoptionsNode = this.extensionoptionsNode; 159 var extensionoptionsNode = this.extensionoptionsNode;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 269
272 var useCapture = true; 270 var useCapture = true;
273 window.addEventListener('readystatechange', function listener(event) { 271 window.addEventListener('readystatechange', function listener(event) {
274 if (document.readyState == 'loading') 272 if (document.readyState == 'loading')
275 return; 273 return;
276 274
277 registerBrowserPluginElement(); 275 registerBrowserPluginElement();
278 registerExtensionOptionsElement(); 276 registerExtensionOptionsElement();
279 window.removeEventListener(event.type, listener, useCapture); 277 window.removeEventListener(event.type, listener, useCapture);
280 }, useCapture); 278 }, useCapture);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698