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

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

Issue 1026703004: Refactored extensionOptions to use the new guestViewAttributes module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment. Created 5 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WebView (<webview>) as a custom element that wraps a 5 // This module implements WebView (<webview>) as a custom element that wraps a
6 // BrowserPlugin object element. The object element is hidden within 6 // BrowserPlugin object element. The object element is hidden within
7 // the shadow DOM of the WebView element. 7 // the shadow DOM of the WebView element.
8 8
9 var DocumentNatives = requireNative('document_natives'); 9 var DocumentNatives = requireNative('document_natives');
10 var GuestView = require('guestView').GuestView; 10 var GuestView = require('guestView').GuestView;
11 var GuestViewContainer = require('guestViewContainer').GuestViewContainer; 11 var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
12 var GuestViewInternalNatives = requireNative('guest_view_internal'); 12 var GuestViewInternalNatives = requireNative('guest_view_internal');
13 var WebViewConstants = require('webViewConstants').WebViewConstants; 13 var WebViewConstants = require('webViewConstants').WebViewConstants;
14 var WebViewEvents = require('webViewEvents').WebViewEvents; 14 var WebViewEvents = require('webViewEvents').WebViewEvents;
15 var WebViewInternal = require('webViewInternal').WebViewInternal; 15 var WebViewInternal = require('webViewInternal').WebViewInternal;
16 16
17 // Represents the internal state of <webview>. 17 // Represents the internal state of <webview>.
18 function WebViewImpl(webviewElement) { 18 function WebViewImpl(webviewElement) {
19 GuestViewContainer.call(this, webviewElement, 'webview'); 19 GuestViewContainer.call(this, webviewElement, 'webview');
20 20
21 this.setupWebViewAttributes();
22 this.setupElementProperties(); 21 this.setupElementProperties();
23
24 new WebViewEvents(this, this.viewInstanceId); 22 new WebViewEvents(this, this.viewInstanceId);
25 } 23 }
26 24
27 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; 25 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype;
28 26
29 WebViewImpl.VIEW_TYPE = 'WebView'; 27 WebViewImpl.VIEW_TYPE = 'WebView';
30 28
31 // Add extra functionality to |this.element|. 29 // Add extra functionality to |this.element|.
32 WebViewImpl.setupElement = function(proto) { 30 WebViewImpl.setupElement = function(proto) {
33 // Public-facing API methods. 31 // Public-facing API methods.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return this.guest.getContentWindow(); 89 return this.guest.getContentWindow();
92 } 90 }
93 window.console.error( 91 window.console.error(
94 WebViewConstants.ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE); 92 WebViewConstants.ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE);
95 }.bind(this), 93 }.bind(this),
96 // No setter. 94 // No setter.
97 enumerable: true 95 enumerable: true
98 }); 96 });
99 }; 97 };
100 98
101 // This observer monitors mutations to attributes of the <webview>.
102 WebViewImpl.prototype.handleAttributeMutation = function(
103 attributeName, oldValue, newValue) {
104 if (!this.attributes[attributeName]) {
105 return;
106 }
107
108 // Let the changed attribute handle its own mutation;
109 this.attributes[attributeName].maybeHandleMutation(oldValue, newValue);
110 };
111
112 WebViewImpl.prototype.onSizeChanged = function(webViewEvent) { 99 WebViewImpl.prototype.onSizeChanged = function(webViewEvent) {
113 var newWidth = webViewEvent.newWidth; 100 var newWidth = webViewEvent.newWidth;
114 var newHeight = webViewEvent.newHeight; 101 var newHeight = webViewEvent.newHeight;
115 102
116 var element = this.element; 103 var element = this.element;
117 104
118 var width = element.offsetWidth; 105 var width = element.offsetWidth;
119 var height = element.offsetHeight; 106 var height = element.offsetHeight;
120 107
121 // Check the current bounds to make sure we do not resize <webview> 108 // Check the current bounds to make sure we do not resize <webview>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 }.bind(this)); 211 }.bind(this));
225 }; 212 };
226 213
227 // Implemented when the ChromeWebView API is available. 214 // Implemented when the ChromeWebView API is available.
228 WebViewImpl.prototype.maybeSetupContextMenus = function() {}; 215 WebViewImpl.prototype.maybeSetupContextMenus = function() {};
229 216
230 GuestViewContainer.registerElement(WebViewImpl); 217 GuestViewContainer.registerElement(WebViewImpl);
231 218
232 // Exports. 219 // Exports.
233 exports.WebViewImpl = WebViewImpl; 220 exports.WebViewImpl = WebViewImpl;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698