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

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

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 schemaRegistry = requireNative('schema_registry'); 5 var schemaRegistry = requireNative('schema_registry');
6 var CHECK = requireNative('logging').CHECK; 6 var CHECK = requireNative('logging').CHECK;
7 var WARNING = requireNative('logging').WARNING; 7 var WARNING = requireNative('logging').WARNING;
8 8
9 // An object forEach. Calls |f| with each (key, value) pair of |obj|, using 9 // An object forEach. Calls |f| with each (key, value) pair of |obj|, using
10 // |self| as the target. 10 // |self| as the target.
(...skipping 14 matching lines...) Expand all
25 return undefined; 25 return undefined;
26 } else if (matches.length == 1) { 26 } else if (matches.length == 1) {
27 return matches[0] 27 return matches[0]
28 } else { 28 } else {
29 throw new Error("Failed lookup of field '" + field + "' with value '" + 29 throw new Error("Failed lookup of field '" + field + "' with value '" +
30 value + "'"); 30 value + "'");
31 } 31 }
32 } 32 }
33 33
34 function loadTypeSchema(typeName, defaultSchema) { 34 function loadTypeSchema(typeName, defaultSchema) {
35 var parts = typeName.split('.'); 35 var parts = $String.split(typeName, '.');
36 if (parts.length == 1) { 36 if (parts.length == 1) {
37 if (defaultSchema == null) { 37 if (defaultSchema == null) {
38 WARNING('Trying to reference "' + typeName + '" ' + 38 WARNING('Trying to reference "' + typeName + '" ' +
39 'with neither namespace nor default schema.'); 39 'with neither namespace nor default schema.');
40 return null; 40 return null;
41 } 41 }
42 var types = defaultSchema.types; 42 var types = defaultSchema.types;
43 } else { 43 } else {
44 var schemaName = parts.slice(0, parts.length - 1).join('.') 44 var schemaName = $Array.join($Array.slice(parts, 0, parts.length - 1), '.');
45 var types = schemaRegistry.GetSchema(schemaName).types; 45 var types = schemaRegistry.GetSchema(schemaName).types;
46 } 46 }
47 for (var i = 0; i < types.length; ++i) { 47 for (var i = 0; i < types.length; ++i) {
48 if (types[i].id == typeName) 48 if (types[i].id == typeName)
49 return types[i]; 49 return types[i];
50 } 50 }
51 return null; 51 return null;
52 } 52 }
53 53
54 exports.forEach = forEach; 54 exports.forEach = forEach;
55 exports.loadTypeSchema = loadTypeSchema; 55 exports.loadTypeSchema = loadTypeSchema;
56 exports.lookup = lookup; 56 exports.lookup = lookup;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698