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

Side by Side Diff: chrome/renderer/resources/extensions/content_watcher.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 unified diff | Download patch | Annotate | Revision Log
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 var contentWatcherNative = requireNative("contentWatcherNative"); 5 var contentWatcherNative = requireNative("contentWatcherNative");
6 var forEach = require('utils').forEach;
6 7
7 // Returns the indices in |css_selectors| that match any element on the page. 8 // Returns the indices in |cssSelectors| that match any element on the page.
8 exports.FindMatchingSelectors = function(css_selectors) { 9 exports.FindMatchingSelectors = function(cssSelectors) {
9 var result = [] 10 var result = []
10 css_selectors.forEach(function(selector, index) { 11 forEach(cssSelectors, function(index, selector) {
11 try { 12 try {
12 if (document.querySelector(selector) != null) 13 if (document.querySelector(selector) != null)
13 result.push(index); 14 result.push(index);
14 } catch (exception) { 15 } catch (exception) {
15 throw new Error("query Selector failed on '" + selector + "': " + 16 throw new Error("query Selector failed on '" + selector + "': " +
16 exception.stack); 17 exception.stack);
17 } 18 }
18 }); 19 });
19 return result; 20 return result;
20 }; 21 };
21 22
22 // Watches the page for all changes and calls FrameMutated (a C++ callback) in 23 // Watches the page for all changes and calls FrameMutated (a C++ callback) in
23 // response. 24 // response.
24 var mutation_observer = new WebKitMutationObserver( 25 var mutation_observer = new WebKitMutationObserver(
25 contentWatcherNative.FrameMutated); 26 contentWatcherNative.FrameMutated);
26 27
27 // This runs once per frame, when the module is 'require'd. 28 // This runs once per frame, when the module is 'require'd.
28 mutation_observer.observe(document, { 29 mutation_observer.observe(document, {
29 childList: true, 30 childList: true,
30 attributes: true, 31 attributes: true,
31 characterData: true, 32 characterData: true,
32 subtree: true}); 33 subtree: true});
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/binding.js ('k') | chrome/renderer/resources/extensions/event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698