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

Unified Diff: chrome/renderer/resources/extensions/web_view.js

Issue 12440030: Use utils.forEach everywhere rather than Array.prototype.forEach to guard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make foreach of an array give numbers Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/web_view.js
diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js
index 6e81a03a69ddc59872e0d328601af60af1a6251e..4c600cb84dd0e3cb79a0d76b8f5f0f286601bcfa 100644
--- a/chrome/renderer/resources/extensions/web_view.js
+++ b/chrome/renderer/resources/extensions/web_view.js
@@ -7,9 +7,9 @@
// The actual tag is implemented via the browser plugin. The internals of this
// are hidden via Shadow DOM.
-var watchForTag = require('tagWatcher').watchForTag;
-
var chrome = requireNative('chrome').GetChrome();
+var forEach = require('utils').forEach;
+var watchForTag = require('tagWatcher').watchForTag;
var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition', 'autosize', 'minheight',
'minwidth', 'maxheight', 'maxwidth'];
@@ -54,7 +54,7 @@ function WebView(node) {
// The <object> node fills in the <webview> container.
this.objectNode_.style.width = '100%';
this.objectNode_.style.height = '100%';
- WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) {
+ forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) {
// Only copy attributes that have been assigned values, rather than copying
// a series of undefined attributes to BrowserPlugin.
if (this.node_.hasAttribute(attributeName)) {
@@ -68,7 +68,7 @@ function WebView(node) {
// this.objectNode_[apiMethod] are not necessarily defined immediately after
// the shadow object is appended to the shadow root.
var self = this;
- WEB_VIEW_API_METHODS.forEach(function(apiMethod) {
+ forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) {
node[apiMethod] = function(var_args) {
return self.objectNode_[apiMethod].apply(self.objectNode_, arguments);
};
@@ -76,17 +76,21 @@ function WebView(node) {
// Map attribute modifications on the <webview> tag to property changes in
// the underlying <object> node.
- var handleMutation = this.handleMutation_.bind(this);
+ var handleMutation = function(i, mutation) {
+ this.handleMutation_(mutation);
+ }.bind(this);
var observer = new WebKitMutationObserver(function(mutations) {
- mutations.forEach(handleMutation);
+ forEach(mutations, handleMutation);
});
observer.observe(
this.node_,
{attributes: true, attributeFilter: WEB_VIEW_ATTRIBUTES});
- var handleObjectMutation = this.handleObjectMutation_.bind(this);
+ var handleObjectMutation = function(i, mutation) {
+ this.handleObjectMutation_(mutation);
+ }.bind(this);
var objectObserver = new WebKitMutationObserver(function(mutations) {
- mutations.forEach(handleObjectMutation);
+ forEach(mutations, handleObjectMutation);
});
objectObserver.observe(
this.objectNode_,
@@ -94,7 +98,7 @@ function WebView(node) {
var objectNode = this.objectNode_;
// Expose getters and setters for the attributes.
- WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) {
+ forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) {
Object.defineProperty(this.node_, attributeName, {
get: function() {
return objectNode[attributeName];
@@ -175,7 +179,7 @@ WebView.prototype.setupEvent_ = function(eventname, attribs) {
this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
var evt = new Event(eventname, { bubbles: true });
var detail = e.detail ? JSON.parse(e.detail) : {};
- attribs.forEach(function(attribName) {
+ forEach(attribs, function(i, attribName) {
evt[attribName] = detail[attribName];
});
node.dispatchEvent(evt);
« no previous file with comments | « chrome/renderer/resources/extensions/utils.js ('k') | chrome/renderer/resources/extensions/web_view_experimental.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698