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

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

Issue 867393002: <extensionoptions>: Add experimental attach/detach API Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GuestView = require('guestView').GuestView; 8 var GuestView = require('guestView').GuestView;
9 var GuestViewContainer = require('guestViewContainer').GuestViewContainer; 9 var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
10 var GuestViewInternal = 10 var GuestViewInternal =
(...skipping 28 matching lines...) Expand all
39 this.setupElementProperties(); 39 this.setupElementProperties();
40 }; 40 };
41 41
42 ExtensionOptionsImpl.prototype.__proto__ = GuestViewContainer.prototype; 42 ExtensionOptionsImpl.prototype.__proto__ = GuestViewContainer.prototype;
43 43
44 ExtensionOptionsImpl.VIEW_TYPE = 'ExtensionOptions'; 44 ExtensionOptionsImpl.VIEW_TYPE = 'ExtensionOptions';
45 45
46 // Add extra functionality to |this.element|. 46 // Add extra functionality to |this.element|.
47 ExtensionOptionsImpl.setupElement = function(proto) { 47 ExtensionOptionsImpl.setupElement = function(proto) {
48 var apiMethods = [ 48 var apiMethods = [
49 'attach',
50 'detach',
49 'setDeferAutoSize', 51 'setDeferAutoSize',
50 'resumeDeferredAutoSize' 52 'resumeDeferredAutoSize'
51 ]; 53 ];
52 54
53 // Forward proto.foo* method calls to ExtensionOptionsImpl.foo*. 55 // Forward proto.foo* method calls to ExtensionOptionsImpl.foo*.
54 GuestViewContainer.forwardApiMethods(proto, apiMethods); 56 GuestViewContainer.forwardApiMethods(proto, apiMethods);
55 } 57 }
56 58
57 ExtensionOptionsImpl.prototype.onElementAttached = function() { 59 ExtensionOptionsImpl.prototype.onElementAttached = function() {
58 this.createGuest(); 60 this.createGuest();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 */ 258 */
257 ExtensionOptionsImpl.prototype.resumeDeferredAutoSize = function() { 259 ExtensionOptionsImpl.prototype.resumeDeferredAutoSize = function() {
258 if (this.autosizeDeferred) { 260 if (this.autosizeDeferred) {
259 this.resize(this.deferredAutoSizeState.newWidth, 261 this.resize(this.deferredAutoSizeState.newWidth,
260 this.deferredAutoSizeState.newHeight, 262 this.deferredAutoSizeState.newHeight,
261 this.deferredAutoSizeState.oldWidth, 263 this.deferredAutoSizeState.oldWidth,
262 this.deferredAutoSizeState.oldHeight); 264 this.deferredAutoSizeState.oldHeight);
263 } 265 }
264 }; 266 };
265 267
268 /**
269 * Attaches a guest to this <extensionoptions> element.
270 */
271 ExtensionOptionsImpl.prototype.attach = function(guest) {
272 if (this.guest === guest) {
273 return;
274 }
275 this.guest.destroy();
276 this.guest = guest;
277 this.attachWindow();
278 };
279
280 /**
281 * Detaches the guest from this <extensionoptions> element.
282 */
283 ExtensionOptionsImpl.prototype.detach = function() {
284 // If we don't have a WindowProxy to this guest, then there's nothing to
285 // detach.
286 if (!this.guest.getContentWindow()) {
287 return null;
288 }
289 var guest = this.guest;
290 guest.detach();
291
292 this.guest = new GuestView('extensionoptions');
293 return guest;
294 };
295
266 GuestViewContainer.registerElement(ExtensionOptionsImpl); 296 GuestViewContainer.registerElement(ExtensionOptionsImpl);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698