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

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

Issue 857093003: Implemented explicit resizing from guestview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. 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
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 GuestViewInternalNatives = requireNative('guest_view_internal');
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 this.element.addEventListener('focus', function(e) { 75 this.element.addEventListener('focus', function(e) {
76 // Focus the BrowserPlugin when the GuestViewContainer takes focus. 76 // Focus the BrowserPlugin when the GuestViewContainer takes focus.
77 privates(this).browserPluginElement.focus(); 77 privates(this).browserPluginElement.focus();
78 }.bind(this)); 78 }.bind(this));
79 this.element.addEventListener('blur', function(e) { 79 this.element.addEventListener('blur', function(e) {
80 // Blur the BrowserPlugin when the GuestViewContainer loses focus. 80 // Blur the BrowserPlugin when the GuestViewContainer loses focus.
81 privates(this).browserPluginElement.blur(); 81 privates(this).browserPluginElement.blur();
82 }.bind(this)); 82 }.bind(this));
83 }; 83 };
84 84
85 GuestViewContainer.prototype.attach = function() {
86 // Augment the attach parameters with the element size, so that the guestview
87 // can fit the element initially.
88 var attachParams = this.buildAttachParams();
89 attachParams['elementWidth'] = parseInt(this.element.offsetWidth);
90 attachParams['elementHeight'] = parseInt(this.element.offsetHeight);
91
92 this.guest.attach(this.internalInstanceId, this.viewInstanceId, attachParams);
93 };
94
85 GuestViewContainer.prototype.attachWindow = function() { 95 GuestViewContainer.prototype.attachWindow = function() {
86 if (!this.internalInstanceId) { 96 if (!this.internalInstanceId) {
87 return true; 97 return true;
88 } 98 }
89 99
90 this.guest.attach(this.internalInstanceId, 100 this.attach();
91 this.viewInstanceId,
92 this.buildAttachParams());
93 return true; 101 return true;
94 }; 102 };
95 103
96 GuestViewContainer.prototype.handleBrowserPluginAttributeMutation = 104 GuestViewContainer.prototype.handleBrowserPluginAttributeMutation =
97 function(name, oldValue, newValue) { 105 function(name, oldValue, newValue) {
98 if (name == 'internalinstanceid' && !oldValue && !!newValue) { 106 if (name == 'internalinstanceid' && !oldValue && !!newValue) {
99 privates(this).browserPluginElement.removeAttribute('internalinstanceid'); 107 privates(this).browserPluginElement.removeAttribute('internalinstanceid');
100 this.internalInstanceId = parseInt(newValue); 108 this.internalInstanceId = parseInt(newValue);
101 109
102 // Track when the element resizes using the element resize callback. 110 // Track when the element resizes using the element resize callback.
103 GuestViewInternalNatives.RegisterElementResizeCallback( 111 GuestViewInternalNatives.RegisterElementResizeCallback(
104 this.internalInstanceId, this.onElementResize.bind(this)); 112 this.internalInstanceId, this.onElementResize.bind(this));
105 113
106 if (!this.guest.getId()) { 114 if (!this.guest.getId()) {
107 return; 115 return;
108 } 116 }
109 this.guest.attach(this.internalInstanceId, 117 this.attach();
110 this.viewInstanceId,
111 this.buildAttachParams());
112 } 118 }
113 }; 119 };
114 120
115 // Implemented by the specific view type, if needed. 121 // Implemented by the specific view type, if needed.
116 GuestViewContainer.prototype.buildAttachParams = function() { return {}; }; 122 GuestViewContainer.prototype.buildAttachParams = function() { return {}; };
117 GuestViewContainer.prototype.handleAttributeMutation = function() {}; 123 GuestViewContainer.prototype.handleAttributeMutation = function() {};
118 GuestViewContainer.prototype.onElementAttached = function() {}; 124 GuestViewContainer.prototype.onElementAttached = function() {};
119 GuestViewContainer.prototype.onElementDetached = function() { 125 GuestViewContainer.prototype.onElementDetached = function() {
120 this.guest.destroy(); 126 this.guest.destroy();
121 }; 127 };
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Delete the callbacks so developers cannot call them and produce unexpected 213 // Delete the callbacks so developers cannot call them and produce unexpected
208 // behavior. 214 // behavior.
209 delete proto.createdCallback; 215 delete proto.createdCallback;
210 delete proto.attachedCallback; 216 delete proto.attachedCallback;
211 delete proto.detachedCallback; 217 delete proto.detachedCallback;
212 delete proto.attributeChangedCallback; 218 delete proto.attributeChangedCallback;
213 } 219 }
214 220
215 // Exports. 221 // Exports.
216 exports.GuestViewContainer = GuestViewContainer; 222 exports.GuestViewContainer = GuestViewContainer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698