Chromium Code Reviews

Side by Side Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 6153002: Start counting at 1 for extension API validation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/renderer/resources
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 var chrome = chrome || {}; 8 var chrome = chrome || {};
9 (function() { 9 (function() {
10 native function GetExtensionAPIDefinition(); 10 native function GetExtensionAPIDefinition();
(...skipping 35 matching lines...)
46 throw new Error("Too many arguments."); 46 throw new Error("Too many arguments.");
47 47
48 for (var i = 0; i < schemas.length; i++) { 48 for (var i = 0; i < schemas.length; i++) {
49 if (i in args && args[i] !== null && args[i] !== undefined) { 49 if (i in args && args[i] !== null && args[i] !== undefined) {
50 var validator = new chromeHidden.JSONSchemaValidator(); 50 var validator = new chromeHidden.JSONSchemaValidator();
51 validator.addTypes(chromeHidden.validationTypes); 51 validator.addTypes(chromeHidden.validationTypes);
52 validator.validate(args[i], schemas[i]); 52 validator.validate(args[i], schemas[i]);
53 if (validator.errors.length == 0) 53 if (validator.errors.length == 0)
54 continue; 54 continue;
55 55
56 var message = "Invalid value for argument " + i + ". "; 56 var message = "Invalid value for argument " + (i + 1) + ". ";
57 for (var i = 0, err; err = validator.errors[i]; i++) { 57 for (var i = 0, err; err = validator.errors[i]; i++) {
58 if (err.path) { 58 if (err.path) {
59 message += "Property '" + err.path + "': "; 59 message += "Property '" + err.path + "': ";
60 } 60 }
61 message += err.message; 61 message += err.message;
62 message = message.substring(0, message.length - 1); 62 message = message.substring(0, message.length - 1);
63 message += ", "; 63 message += ", ";
64 } 64 }
65 message = message.substring(0, message.length - 2); 65 message = message.substring(0, message.length - 2);
66 message += "."; 66 message += ".";
67 67
68 throw new Error(message); 68 throw new Error(message);
69 } else if (!schemas[i].optional) { 69 } else if (!schemas[i].optional) {
70 throw new Error("Parameter " + i + " is required."); 70 throw new Error("Parameter " + (i + 1) + " is required.");
71 } 71 }
72 } 72 }
73 }; 73 };
74 74
75 // Callback handling. 75 // Callback handling.
76 var requests = []; 76 var requests = [];
77 chromeHidden.handleResponse = function(requestId, name, 77 chromeHidden.handleResponse = function(requestId, name,
78 success, response, error) { 78 success, response, error) {
79 try { 79 try {
80 var request = requests[requestId]; 80 var request = requests[requestId];
(...skipping 721 matching lines...)
802 802
803 if (!chrome.experimental) 803 if (!chrome.experimental)
804 chrome.experimental = {}; 804 chrome.experimental = {};
805 805
806 if (!chrome.experimental.accessibility) 806 if (!chrome.experimental.accessibility)
807 chrome.experimental.accessibility = {}; 807 chrome.experimental.accessibility = {};
808 808
809 if (!chrome.experimental.tts) 809 if (!chrome.experimental.tts)
810 chrome.experimental.tts = {}; 810 chrome.experimental.tts = {};
811 })(); 811 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine