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

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

Issue 14272003: <webview>: Focusing <webview> should propagate to BrowserPlugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to web_view_interactive_browsertest.cc Created 7 years, 8 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 // Shim that simulates a <webview> tag via Mutation Observers. 5 // Shim that simulates a <webview> tag via Mutation Observers.
6 // 6 //
7 // The actual tag is implemented via the browser plugin. The internals of this 7 // The actual tag is implemented via the browser plugin. The internals of this
8 // are hidden via Shadow DOM. 8 // are hidden via Shadow DOM.
9 9
10 var chrome = requireNative('chrome').GetChrome(); 10 var chrome = requireNative('chrome').GetChrome();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 this.objectNode_.style.height = '100%'; 56 this.objectNode_.style.height = '100%';
57 forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) { 57 forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) {
58 // Only copy attributes that have been assigned values, rather than copying 58 // Only copy attributes that have been assigned values, rather than copying
59 // a series of undefined attributes to BrowserPlugin. 59 // a series of undefined attributes to BrowserPlugin.
60 if (this.node_.hasAttribute(attributeName)) { 60 if (this.node_.hasAttribute(attributeName)) {
61 this.objectNode_.setAttribute( 61 this.objectNode_.setAttribute(
62 attributeName, this.node_.getAttribute(attributeName)); 62 attributeName, this.node_.getAttribute(attributeName));
63 } 63 }
64 }, this); 64 }, this);
65 65
66 if (!this.node_.hasAttribute('tabIndex')) {
67 // <webview> needs a tabIndex in order to respond to keyboard focus.
68 // TODO(fsamuel): This introduces unexpected tab ordering. We need to find
69 // a way to take keyboard focus without messing with tab ordering.
70 // See http://crbug.com/231664.
71 this.node_.setAttribute('tabIndex', 0);
72 }
73 var self = this;
74 this.node_.addEventListener('focus', function(e) {
75 // Focus the BrowserPlugin when the <webview> takes focus.
76 self.objectNode_.focus();
77 });
78 this.node_.addEventListener('blur', function(e) {
79 // Blur the BrowserPlugin when the <webview> loses focus.
80 self.objectNode_.blur();
81 });
82
66 shadowRoot.appendChild(this.objectNode_); 83 shadowRoot.appendChild(this.objectNode_);
67 84
68 // this.objectNode_[apiMethod] are not necessarily defined immediately after 85 // this.objectNode_[apiMethod] are not necessarily defined immediately after
69 // the shadow object is appended to the shadow root. 86 // the shadow object is appended to the shadow root.
70 var self = this;
71 forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) { 87 forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) {
72 node[apiMethod] = function(var_args) { 88 node[apiMethod] = function(var_args) {
73 return self.objectNode_[apiMethod].apply(self.objectNode_, arguments); 89 return self.objectNode_[apiMethod].apply(self.objectNode_, arguments);
74 }; 90 };
75 }, this); 91 }, this);
76 92
77 // Map attribute modifications on the <webview> tag to property changes in 93 // Map attribute modifications on the <webview> tag to property changes in
78 // the underlying <object> node. 94 // the underlying <object> node.
79 var handleMutation = function(i, mutation) { 95 var handleMutation = function(i, mutation) {
80 this.handleMutation_(mutation); 96 this.handleMutation_(mutation);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 */ 215 */
200 WebView.prototype.maybeSetupPermissionEvent_ = function() {}; 216 WebView.prototype.maybeSetupPermissionEvent_ = function() {};
201 217
202 /** 218 /**
203 * Implemented when experimental permission is available. 219 * Implemented when experimental permission is available.
204 * @private 220 * @private
205 */ 221 */
206 WebView.prototype.maybeSetupExecuteScript_ = function() {}; 222 WebView.prototype.maybeSetupExecuteScript_ = function() {};
207 223
208 exports.WebView = WebView; 224 exports.WebView = WebView;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698