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

Side by Side Diff: extensions/renderer/resources/guest_view/guest_view_container.js

Issue 856563002: Added the infrastructure for surfaceProxy.onResize() and SurfaceView.onResize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed code from one non-essential function that was causing tests to fail. It will be re-added in… 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 | « extensions/renderer/resources/guest_view/guest_view.js ('k') | 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 // This module implements the shared functionality for different guestview 5 // This module implements the shared functionality for different guestview
6 // containers, such as web_view, app_view, etc. 6 // containers, such as web_view, app_view, etc.
7 7
8 var DocumentNatives = requireNative('document_natives'); 8 var DocumentNatives = requireNative('document_natives');
9 var GuestView = require('guestView').GuestView; 9 var GuestView = require('guestView').GuestView;
10 var GuestViewInternalNatives = requireNative('guest_view_internal');
10 var IdGenerator = requireNative('id_generator'); 11 var IdGenerator = requireNative('id_generator');
11 12
12 function GuestViewContainer(element, viewType) { 13 function GuestViewContainer(element, viewType) {
13 privates(element).internal = this; 14 privates(element).internal = this;
14 this.element = element; 15 this.element = element;
15 this.elementAttached = false; 16 this.elementAttached = false;
16 this.guest = new GuestView(viewType); 17 this.guest = new GuestView(viewType);
17 this.viewInstanceId = IdGenerator.GetNextId(); 18 this.viewInstanceId = IdGenerator.GetNextId();
18 this.viewType = viewType; 19 this.viewType = viewType;
19 20
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 this.buildAttachParams()); 92 this.buildAttachParams());
92 return true; 93 return true;
93 }; 94 };
94 95
95 GuestViewContainer.prototype.handleBrowserPluginAttributeMutation = 96 GuestViewContainer.prototype.handleBrowserPluginAttributeMutation =
96 function(name, oldValue, newValue) { 97 function(name, oldValue, newValue) {
97 if (name == 'internalinstanceid' && !oldValue && !!newValue) { 98 if (name == 'internalinstanceid' && !oldValue && !!newValue) {
98 privates(this).browserPluginElement.removeAttribute('internalinstanceid'); 99 privates(this).browserPluginElement.removeAttribute('internalinstanceid');
99 this.internalInstanceId = parseInt(newValue); 100 this.internalInstanceId = parseInt(newValue);
100 101
102 // Track when the element resizes using the element resize callback.
103 GuestViewInternalNatives.RegisterElementResizeCallback(
104 this.internalInstanceId, this.onElementResize.bind(this));
105
101 if (!this.guest.getId()) { 106 if (!this.guest.getId()) {
102 return; 107 return;
103 } 108 }
104 this.guest.attach(this.internalInstanceId, 109 this.guest.attach(this.internalInstanceId,
105 this.viewInstanceId, 110 this.viewInstanceId,
106 this.buildAttachParams()); 111 this.buildAttachParams());
107 } 112 }
108 }; 113 };
109 114
110 // Implemented by the specific view type, if needed. 115 // Implemented by the specific view type, if needed.
111 GuestViewContainer.prototype.buildAttachParams = function() { return {}; }; 116 GuestViewContainer.prototype.buildAttachParams = function() { return {}; };
112 GuestViewContainer.prototype.handleAttributeMutation = function() {}; 117 GuestViewContainer.prototype.handleAttributeMutation = function() {};
113 GuestViewContainer.prototype.onElementAttached = function() {}; 118 GuestViewContainer.prototype.onElementAttached = function() {};
114 GuestViewContainer.prototype.onElementDetached = function() { 119 GuestViewContainer.prototype.onElementDetached = function() {
115 this.guest.destroy(); 120 this.guest.destroy();
116 }; 121 };
122 GuestViewContainer.prototype.onElementResize = function(oldWidth, oldHeight,
123 newWidth, newHeight) {};
117 124
118 // Registers the browser plugin <object> custom element. |viewType| is the 125 // Registers the browser plugin <object> custom element. |viewType| is the
119 // name of the specific guestview container (e.g. 'webview'). 126 // name of the specific guestview container (e.g. 'webview').
120 function registerBrowserPluginElement(viewType) { 127 function registerBrowserPluginElement(viewType) {
121 var proto = Object.create(HTMLObjectElement.prototype); 128 var proto = Object.create(HTMLObjectElement.prototype);
122 129
123 proto.createdCallback = function() { 130 proto.createdCallback = function() {
124 this.setAttribute('type', 'application/browser-plugin'); 131 this.setAttribute('type', 'application/browser-plugin');
125 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); 132 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId());
126 this.style.width = '100%'; 133 this.style.width = '100%';
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Delete the callbacks so developers cannot call them and produce unexpected 207 // Delete the callbacks so developers cannot call them and produce unexpected
201 // behavior. 208 // behavior.
202 delete proto.createdCallback; 209 delete proto.createdCallback;
203 delete proto.attachedCallback; 210 delete proto.attachedCallback;
204 delete proto.detachedCallback; 211 delete proto.detachedCallback;
205 delete proto.attributeChangedCallback; 212 delete proto.attributeChangedCallback;
206 } 213 }
207 214
208 // Exports. 215 // Exports.
209 exports.GuestViewContainer = GuestViewContainer; 216 exports.GuestViewContainer = GuestViewContainer;
OLDNEW
« no previous file with comments | « extensions/renderer/resources/guest_view/guest_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698