summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/resources
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 18:25:01 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 18:25:01 +0000
commit28c47ee963812e92e2eb921ed1778f5db74041bc (patch)
tree4fe3226b1a17e845379d73b4ce29ae8504d39860 /chrome/renderer/resources
parente4c893a1534ba215f0b66eb9ee3ac87bc8c72143 (diff)
downloadchromium_src-28c47ee963812e92e2eb921ed1778f5db74041bc.zip
chromium_src-28c47ee963812e92e2eb921ed1778f5db74041bc.tar.gz
chromium_src-28c47ee963812e92e2eb921ed1778f5db74041bc.tar.bz2
BUG=11200
R=aa Review URL: http://codereview.chromium.org/110001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/resources')
-rw-r--r--chrome/renderer/resources/event_bindings.js54
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js268
-rwxr-xr-xchrome/renderer/resources/json_schema.js60
-rw-r--r--chrome/renderer/resources/renderer_extension_bindings.js32
4 files changed, 207 insertions, 207 deletions
diff --git a/chrome/renderer/resources/event_bindings.js b/chrome/renderer/resources/event_bindings.js
index ed097dc..6fcdd00 100644
--- a/chrome/renderer/resources/event_bindings.js
+++ b/chrome/renderer/resources/event_bindings.js
@@ -7,7 +7,7 @@
// have your change take effect.
// -----------------------------------------------------------------------------
-var chromium = chromium || {};
+var chrome = chrome || {};
(function () {
native function AttachEvent(eventName);
native function DetachEvent(eventName);
@@ -17,41 +17,41 @@ var chromium = chromium || {};
// with that name will route through this object's listeners.
//
// Example:
- // chromium.tabs.onTabChanged = new chromium.Event("tab-changed");
- // chromium.tabs.onTabChanged.addListener(function(data) { alert(data); });
- // chromium.Event.dispatch_("tab-changed", "hi");
+ // chrome.tabs.onChanged = new chrome.Event("tab-changed");
+ // chrome.tabs.onChanged.addListener(function(data) { alert(data); });
+ // chrome.Event.dispatch_("tab-changed", "hi");
// will result in an alert dialog that says 'hi'.
- chromium.Event = function(opt_eventName) {
+ chrome.Event = function(opt_eventName) {
this.eventName_ = opt_eventName;
this.listeners_ = [];
};
// A map of event names to the event object that is registered to that name.
- chromium.Event.attached_ = {};
+ chrome.Event.attached_ = {};
// Dispatches a named event with the given JSON array, which is deserialized
// before dispatch. The JSON array is the list of arguments that will be
// sent with the event callback.
- chromium.Event.dispatchJSON_ = function(name, args) {
- if (chromium.Event.attached_[name]) {
+ chrome.Event.dispatchJSON_ = function(name, args) {
+ if (chrome.Event.attached_[name]) {
if (args) {
args = goog.json.parse(args);
}
- chromium.Event.attached_[name].dispatch.apply(
- chromium.Event.attached_[name], args);
+ chrome.Event.attached_[name].dispatch.apply(
+ chrome.Event.attached_[name], args);
}
};
// Dispatches a named event with the given arguments, supplied as an array.
- chromium.Event.dispatch_ = function(name, args) {
- if (chromium.Event.attached_[name]) {
- chromium.Event.attached_[name].dispatch.apply(
- chromium.Event.attached_[name], args);
+ chrome.Event.dispatch_ = function(name, args) {
+ if (chrome.Event.attached_[name]) {
+ chrome.Event.attached_[name].dispatch.apply(
+ chrome.Event.attached_[name], args);
}
};
// Registers a callback to be called when this event is dispatched.
- chromium.Event.prototype.addListener = function(cb) {
+ chrome.Event.prototype.addListener = function(cb) {
this.listeners_.push(cb);
if (this.listeners_.length == 1) {
this.attach_();
@@ -59,7 +59,7 @@ var chromium = chromium || {};
};
// Unregisters a callback.
- chromium.Event.prototype.removeListener = function(cb) {
+ chrome.Event.prototype.removeListener = function(cb) {
var idx = this.findListener_(cb);
if (idx == -1) {
return;
@@ -72,13 +72,13 @@ var chromium = chromium || {};
};
// Test if the given callback is registered for this event.
- chromium.Event.prototype.hasListener = function(cb) {
+ chrome.Event.prototype.hasListener = function(cb) {
return this.findListeners_(cb) > -1;
};
// Returns the index of the given callback if registered, or -1 if not
// found.
- chromium.Event.prototype.findListener_ = function(cb) {
+ chrome.Event.prototype.findListener_ = function(cb) {
for (var i = 0; i < this.listeners_.length; i++) {
if (this.listeners_[i] == cb) {
return i;
@@ -90,7 +90,7 @@ var chromium = chromium || {};
// Dispatches this event object to all listeners, passing all supplied
// arguments to this function each listener.
- chromium.Event.prototype.dispatch = function(varargs) {
+ chrome.Event.prototype.dispatch = function(varargs) {
var args = Array.prototype.slice.call(arguments);
for (var i = 0; i < this.listeners_.length; i++) {
try {
@@ -103,33 +103,33 @@ var chromium = chromium || {};
// Attaches this event object to its name. Only one object can have a given
// name.
- chromium.Event.prototype.attach_ = function() {
+ chrome.Event.prototype.attach_ = function() {
AttachEvent(this.eventName_);
this.unloadHandler_ = this.detach_.bind(this);
window.addEventListener('unload', this.unloadHandler_, false);
if (!this.eventName_)
return;
- if (chromium.Event.attached_[this.eventName_]) {
- throw new Error("chromium.Event '" + this.eventName_ +
+ if (chrome.Event.attached_[this.eventName_]) {
+ throw new Error("chrome.Event '" + this.eventName_ +
"' is already attached.");
}
- chromium.Event.attached_[this.eventName_] = this;
+ chrome.Event.attached_[this.eventName_] = this;
};
// Detaches this event object from its name.
- chromium.Event.prototype.detach_ = function() {
+ chrome.Event.prototype.detach_ = function() {
window.removeEventListener('unload', this.unloadHandler_, false);
DetachEvent(this.eventName_);
if (!this.eventName_)
return;
- if (!chromium.Event.attached_[this.eventName_]) {
- throw new Error("chromium.Event '" + this.eventName_ +
+ if (!chrome.Event.attached_[this.eventName_]) {
+ throw new Error("chrome.Event '" + this.eventName_ +
"' is not attached.");
}
- delete chromium.Event.attached_[this.eventName_];
+ delete chrome.Event.attached_[this.eventName_];
};
})();
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index d1907d8..70df0fb 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The chrome Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,7 @@
// have your change take effect.
// -----------------------------------------------------------------------------
-var chromium;
+var chrome;
(function() {
native function GetNextCallbackId();
native function GetWindow();
@@ -33,8 +33,8 @@ var chromium;
native function MoveBookmark();
native function SetBookmarkTitle();
- if (!chromium)
- chromium = {};
+ if (!chrome)
+ chrome = {};
// Validate arguments.
function validate(args, schemas) {
@@ -43,7 +43,7 @@ var chromium;
for (var i = 0; i < schemas.length; i++) {
if (i in args && args[i] !== null && args[i] !== undefined) {
- var validator = new chromium.JSONSchemaValidator();
+ var validator = new chrome.JSONSchemaValidator();
validator.validate(args[i], schemas[i]);
if (validator.errors.length == 0)
continue;
@@ -71,7 +71,7 @@ var chromium;
// TODO(aa): This function should not be publicly exposed. Pass it into V8
// instead and hold one per-context. See the way event_bindings.js works.
var callbacks = [];
- chromium.dispatchCallback_ = function(callbackId, str) {
+ chrome.dispatchCallback_ = function(callbackId, str) {
try {
if (str) {
callbacks[callbackId](goog.json.parse(str));
@@ -97,376 +97,376 @@ var chromium;
//----------------------------------------------------------------------------
// Windows.
- chromium.windows = {};
+ chrome.windows = {};
- chromium.windows.get = function(windowId, callback) {
+ chrome.windows.get = function(windowId, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetWindow, windowId, callback);
};
- chromium.windows.get.params = [
- chromium.types.pInt,
- chromium.types.fun
+ chrome.windows.get.params = [
+ chrome.types.pInt,
+ chrome.types.fun
];
- chromium.windows.getCurrent = function(callback) {
+ chrome.windows.getCurrent = function(callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetCurrentWindow, null, callback);
};
- chromium.windows.getCurrent.params = [
- chromium.types.fun
+ chrome.windows.getCurrent.params = [
+ chrome.types.fun
];
- chromium.windows.getFocused = function(callback) {
+ chrome.windows.getFocused = function(callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetFocusedWindow, null, callback);
};
- chromium.windows.getFocused.params = [
- chromium.types.fun
+ chrome.windows.getFocused.params = [
+ chrome.types.fun
];
- chromium.windows.getAll = function(populate, callback) {
+ chrome.windows.getAll = function(populate, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetAllWindows, populate, callback);
};
- chromium.windows.getAll.params = [
- chromium.types.optBool,
- chromium.types.fun
+ chrome.windows.getAll.params = [
+ chrome.types.optBool,
+ chrome.types.fun
];
- chromium.windows.createWindow = function(createData, callback) {
+ chrome.windows.createWindow = function(createData, callback) {
validate(arguments, arguments.callee.params);
sendRequest(CreateWindow, createData, callback);
};
- chromium.windows.createWindow.params = [
+ chrome.windows.createWindow.params = [
{
type: "object",
properties: {
- url: chromium.types.optStr,
- left: chromium.types.optInt,
- top: chromium.types.optInt,
- width: chromium.types.optPInt,
- height: chromium.types.optPInt
+ url: chrome.types.optStr,
+ left: chrome.types.optInt,
+ top: chrome.types.optInt,
+ width: chrome.types.optPInt,
+ height: chrome.types.optPInt
},
optional: true
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.windows.removeWindow = function(windowId, callback) {
+ chrome.windows.removeWindow = function(windowId, callback) {
validate(arguments, arguments.callee.params);
sendRequest(RemoveWindow, windowId, callback);
};
- chromium.windows.removeWindow.params = [
- chromium.types.pInt,
- chromium.types.optFun
+ chrome.windows.removeWindow.params = [
+ chrome.types.pInt,
+ chrome.types.optFun
];
// sends (windowId).
// *WILL* be followed by tab-attached AND then tab-selection-changed.
- chromium.windows.onCreated = new chromium.Event("window-created");
+ chrome.windows.onCreated = new chrome.Event("window-created");
// sends (windowId).
// *WILL* be preceded by sequences of tab-removed AND then
// tab-selection-changed -- one for each tab that was contained in the window
// that closed
- chromium.windows.onRemoved = new chromium.Event("window-removed");
+ chrome.windows.onRemoved = new chrome.Event("window-removed");
// sends (windowId).
- chromium.windows.onFocusChanged =
- new chromium.Event("window-focus-changed");
+ chrome.windows.onFocusChanged =
+ new chrome.Event("window-focus-changed");
//----------------------------------------------------------------------------
// Tabs
- chromium.tabs = {};
+ chrome.tabs = {};
- chromium.tabs.get = function(tabId, callback) {
+ chrome.tabs.get = function(tabId, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetTab, tabId, callback);
};
- chromium.tabs.get.params = [
- chromium.types.pInt,
- chromium.types.fun
+ chrome.tabs.get.params = [
+ chrome.types.pInt,
+ chrome.types.fun
];
- chromium.tabs.getSelected = function(windowId, callback) {
+ chrome.tabs.getSelected = function(windowId, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetSelectedTab, windowId, callback);
};
- chromium.tabs.getSelected.params = [
- chromium.types.optPInt,
- chromium.types.fun
+ chrome.tabs.getSelected.params = [
+ chrome.types.optPInt,
+ chrome.types.fun
];
- chromium.tabs.getAllInWindow = function(windowId, callback) {
+ chrome.tabs.getAllInWindow = function(windowId, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetAllTabsInWindow, windowId, callback);
};
- chromium.tabs.getAllInWindow.params = [
- chromium.types.optPInt,
- chromium.types.fun
+ chrome.tabs.getAllInWindow.params = [
+ chrome.types.optPInt,
+ chrome.types.fun
];
- chromium.tabs.create = function(tab, callback) {
+ chrome.tabs.create = function(tab, callback) {
validate(arguments, arguments.callee.params);
sendRequest(CreateTab, tab, callback);
};
- chromium.tabs.create.params = [
+ chrome.tabs.create.params = [
{
type: "object",
properties: {
- windowId: chromium.types.optPInt,
- index: chromium.types.optPInt,
- url: chromium.types.optStr,
- selected: chromium.types.optBool
+ windowId: chrome.types.optPInt,
+ index: chrome.types.optPInt,
+ url: chrome.types.optStr,
+ selected: chrome.types.optBool
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.tabs.update = function(tabId, updates, callback) {
+ chrome.tabs.update = function(tabId, updates, callback) {
validate(arguments, arguments.callee.params);
sendRequest(UpdateTab, [tabId, updates], callback);
};
- chromium.tabs.update.params = [
- chromium.types.pInt,
+ chrome.tabs.update.params = [
+ chrome.types.pInt,
{
type: "object",
properties: {
- url: chromium.types.optStr,
- selected: chromium.types.optBool
+ url: chrome.types.optStr,
+ selected: chrome.types.optBool
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.tabs.move = function(tabId, moveProps, callback) {
+ chrome.tabs.move = function(tabId, moveProps, callback) {
validate(arguments, arguments.callee.params);
sendRequest(MoveTab, [tabId, moveProps], callback);
};
- chromium.tabs.move.params = [
- chromium.types.pInt,
+ chrome.tabs.move.params = [
+ chrome.types.pInt,
{
type: "object",
properties: {
- windowId: chromium.types.optPInt,
- index: chromium.types.pInt
+ windowId: chrome.types.optPInt,
+ index: chrome.types.pInt
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.tabs.remove = function(tabId) {
+ chrome.tabs.remove = function(tabId) {
validate(arguments, arguments.callee.params);
sendRequest(RemoveTab, tabId);
};
- chromium.tabs.remove.params = [
- chromium.types.pInt
+ chrome.tabs.remove.params = [
+ chrome.types.pInt
];
// Sends ({Tab}).
// Will *NOT* be followed by tab-attached - it is implied.
// *MAY* be followed by tab-selection-changed.
- chromium.tabs.onCreated = new chromium.Event("tab-created");
+ chrome.tabs.onCreated = new chrome.Event("tab-created");
// Sends (tabId, {windowId, fromIndex, toIndex}).
// Tabs can only "move" within a window.
- chromium.tabs.onMoved = new chromium.Event("tab-moved");
+ chrome.tabs.onMoved = new chrome.Event("tab-moved");
// Sends (tabId, {windowId}).
- chromium.tabs.onSelectionChanged =
- new chromium.Event("tab-selection-changed");
+ chrome.tabs.onSelectionChanged =
+ new chrome.Event("tab-selection-changed");
// Sends (tabId, {newWindowId, newPosition}).
// *MAY* be followed by tab-selection-changed.
- chromium.tabs.onAttached = new chromium.Event("tab-attached");
+ chrome.tabs.onAttached = new chrome.Event("tab-attached");
// Sends (tabId, {oldWindowId, oldPosition}).
// *WILL* be followed by tab-selection-changed.
- chromium.tabs.onDetached = new chromium.Event("tab-detached");
+ chrome.tabs.onDetached = new chrome.Event("tab-detached");
// Sends (tabId).
// *WILL* be followed by tab-selection-changed.
// Will *NOT* be followed or preceded by tab-detached.
- chromium.tabs.onRemoved = new chromium.Event("tab-removed");
+ chrome.tabs.onRemoved = new chrome.Event("tab-removed");
//----------------------------------------------------------------------------
// PageActions.
- chromium.pageActions = {};
+ chrome.pageActions = {};
- chromium.pageActions.enableForTab = function(pageActionId, action) {
+ chrome.pageActions.enableForTab = function(pageActionId, action) {
validate(arguments, arguments.callee.params);
sendRequest(EnablePageAction, [pageActionId, action]);
}
- chromium.pageActions.enableForTab.params = [
- chromium.types.str,
+ chrome.pageActions.enableForTab.params = [
+ chrome.types.str,
{
type: "object",
properties: {
- tabId: chromium.types.pInt,
- url: chromium.types.str
+ tabId: chrome.types.pInt,
+ url: chrome.types.str
},
optional: false
}
];
// Sends ({pageActionId, tabId, tabUrl}).
- chromium.pageActions.onExecute =
- new chromium.Event("page-action-executed");
+ chrome.pageActions.onExecute =
+ new chrome.Event("page-action-executed");
//----------------------------------------------------------------------------
// Bookmarks
- chromium.bookmarks = {};
+ chrome.bookmarks = {};
- chromium.bookmarks.get = function(ids, callback) {
+ chrome.bookmarks.get = function(ids, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetBookmarks, ids, callback);
};
- chromium.bookmarks.get.params = [
+ chrome.bookmarks.get.params = [
{
type: "array",
- items: chromium.types.pInt,
+ items: chrome.types.pInt,
optional: true
},
- chromium.types.fun
+ chrome.types.fun
];
- chromium.bookmarks.getChildren = function(id, callback) {
+ chrome.bookmarks.getChildren = function(id, callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetBookmarkChildren, id, callback);
};
- chromium.bookmarks.getChildren.params = [
- chromium.types.pInt,
- chromium.types.fun
+ chrome.bookmarks.getChildren.params = [
+ chrome.types.pInt,
+ chrome.types.fun
];
- chromium.bookmarks.getTree = function(callback) {
+ chrome.bookmarks.getTree = function(callback) {
validate(arguments, arguments.callee.params);
sendRequest(GetBookmarkTree, null, callback);
};
// TODO(erikkay): allow it to take an optional id as a starting point
- chromium.bookmarks.getTree.params = [
- chromium.types.fun
+ chrome.bookmarks.getTree.params = [
+ chrome.types.fun
];
- chromium.bookmarks.search = function(query, callback) {
+ chrome.bookmarks.search = function(query, callback) {
validate(arguments, arguments.callee.params);
sendRequest(SearchBookmarks, query, callback);
};
- chromium.bookmarks.search.params = [
- chromium.types.str,
- chromium.types.fun
+ chrome.bookmarks.search.params = [
+ chrome.types.str,
+ chrome.types.fun
];
- chromium.bookmarks.remove = function(bookmark, callback) {
+ chrome.bookmarks.remove = function(bookmark, callback) {
validate(arguments, arguments.callee.params);
sendRequest(RemoveBookmark, bookmark, callback);
};
- chromium.bookmarks.remove.params = [
+ chrome.bookmarks.remove.params = [
{
type: "object",
properties: {
- id: chromium.types.pInt,
- recursive: chromium.types.optBool
+ id: chrome.types.pInt,
+ recursive: chrome.types.optBool
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.bookmarks.create = function(bookmark, callback) {
+ chrome.bookmarks.create = function(bookmark, callback) {
validate(arguments, arguments.callee.params);
sendRequest(CreateBookmark, bookmark, callback);
};
- chromium.bookmarks.create.params = [
+ chrome.bookmarks.create.params = [
{
type: "object",
properties: {
- parentId: chromium.types.optPInt,
- index: chromium.types.optPInt,
- title: chromium.types.optStr,
- url: chromium.types.optStr,
+ parentId: chrome.types.optPInt,
+ index: chrome.types.optPInt,
+ title: chrome.types.optStr,
+ url: chrome.types.optStr,
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.bookmarks.move = function(obj, callback) {
+ chrome.bookmarks.move = function(obj, callback) {
validate(arguments, arguments.callee.params);
sendRequest(MoveBookmark, obj, callback);
};
- chromium.bookmarks.move.params = [
+ chrome.bookmarks.move.params = [
{
type: "object",
properties: {
- id: chromium.types.pInt,
- parentId: chromium.types.optPInt,
- index: chromium.types.optPInt
+ id: chrome.types.pInt,
+ parentId: chrome.types.optPInt,
+ index: chrome.types.optPInt
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
- chromium.bookmarks.setTitle = function(bookmark, callback) {
+ chrome.bookmarks.setTitle = function(bookmark, callback) {
validate(arguments, arguments.callee.params);
sendRequest(SetBookmarkTitle, bookmark, callback);
};
- chromium.bookmarks.setTitle.params = [
+ chrome.bookmarks.setTitle.params = [
{
type: "object",
properties: {
- id: chromium.types.pInt,
- title: chromium.types.optStr
+ id: chrome.types.pInt,
+ title: chrome.types.optStr
}
},
- chromium.types.optFun
+ chrome.types.optFun
];
// bookmark events
// Sends ({id, title, url, parentId, index})
- chromium.bookmarks.onBookmarkAdded = new chromium.Event("bookmark-added");
+ chrome.bookmarks.onBookmarkAdded = new chrome.Event("bookmark-added");
// Sends ({parentId, index})
- chromium.bookmarks.onBookmarkRemoved = new chromium.Event("bookmark-removed");
+ chrome.bookmarks.onBookmarkRemoved = new chrome.Event("bookmark-removed");
// Sends (id, object) where object has list of properties that have changed.
// Currently, this only ever includes 'title'.
- chromium.bookmarks.onBookmarkChanged = new chromium.Event("bookmark-changed");
+ chrome.bookmarks.onBookmarkChanged = new chrome.Event("bookmark-changed");
// Sends ({id, parentId, index, oldParentId, oldIndex})
- chromium.bookmarks.onBookmarkMoved = new chromium.Event("bookmark-moved");
+ chrome.bookmarks.onBookmarkMoved = new chrome.Event("bookmark-moved");
// Sends (id, [childrenIds])
- chromium.bookmarks.onBookmarkChildrenReordered =
- new chromium.Event("bookmark-children-reordered");
+ chrome.bookmarks.onBookmarkChildrenReordered =
+ new chrome.Event("bookmark-children-reordered");
//----------------------------------------------------------------------------
// Self.
- chromium.self = {};
- chromium.self.onConnect = new chromium.Event("channel-connect");
+ chrome.self = {};
+ chrome.self.onConnect = new chrome.Event("channel-connect");
})();
diff --git a/chrome/renderer/resources/json_schema.js b/chrome/renderer/resources/json_schema.js
index 5fdbd8c..f8a4c7a 100755
--- a/chrome/renderer/resources/json_schema.js
+++ b/chrome/renderer/resources/json_schema.js
@@ -36,12 +36,12 @@
// - made additionalProperties default to false
//==============================================================================
-var chromium = chromium || {};
+var chrome = chrome || {};
/**
* Validates an instance against a schema and accumulates errors. Usage:
*
- * var validator = new chromium.JSONSchemaValidator();
+ * var validator = new chrome.JSONSchemaValidator();
* validator.validate(inst, schema);
* if (validator.errors.length == 0)
* console.log("Valid!");
@@ -53,11 +53,11 @@ var chromium = chromium || {};
* the key that had the problem, and the "message" property contains a sentence
* describing the error.
*/
-chromium.JSONSchemaValidator = function() {
+chrome.JSONSchemaValidator = function() {
this.errors = [];
};
-chromium.JSONSchemaValidator.messages = {
+chrome.JSONSchemaValidator.messages = {
invalidEnum: "Value must be one of: [*].",
propertyRequired: "Property is required.",
unexpectedProperty: "Unexpected property.",
@@ -80,7 +80,7 @@ chromium.JSONSchemaValidator.messages = {
* Builds an error message. Key is the property in the |errors| object, and
* |opt_replacements| is an array of values to replace "*" characters with.
*/
-chromium.JSONSchemaValidator.formatError = function(key, opt_replacements) {
+chrome.JSONSchemaValidator.formatError = function(key, opt_replacements) {
var message = this.messages[key];
if (opt_replacements) {
for (var i = 0; i < opt_replacements.length; i++) {
@@ -95,7 +95,7 @@ chromium.JSONSchemaValidator.formatError = function(key, opt_replacements) {
* don't explicitly disallow 'function', because we want to allow functions in
* the input values.
*/
-chromium.JSONSchemaValidator.getType = function(value) {
+chrome.JSONSchemaValidator.getType = function(value) {
var s = typeof value;
if (s == "object") {
@@ -119,8 +119,8 @@ chromium.JSONSchemaValidator.getType = function(value) {
* value and will be validated recursively. When this method returns, the
* |errors| property will contain a list of errors, if any.
*/
-chromium.JSONSchemaValidator.prototype.validate = function(instance, schema,
- opt_path) {
+chrome.JSONSchemaValidator.prototype.validate = function(instance, schema,
+ opt_path) {
var path = opt_path || "";
if (!schema) {
@@ -174,9 +174,9 @@ chromium.JSONSchemaValidator.prototype.validate = function(instance, schema,
* Validates an instance against a choices schema. The instance must match at
* least one of the provided choices.
*/
-chromium.JSONSchemaValidator.prototype.validateChoices = function(instance,
- schema,
- path) {
+chrome.JSONSchemaValidator.prototype.validateChoices = function(instance,
+ schema,
+ path) {
var originalErrors = this.errors;
for (var i = 0; i < schema.choices.length; i++) {
@@ -197,8 +197,8 @@ chromium.JSONSchemaValidator.prototype.validateChoices = function(instance,
* |errors| property, and returns a boolean indicating whether the instance
* validates.
*/
-chromium.JSONSchemaValidator.prototype.validateEnum = function(instance, schema,
- path) {
+chrome.JSONSchemaValidator.prototype.validateEnum = function(instance, schema,
+ path) {
for (var i = 0; i < schema.enum.length; i++) {
if (instance === schema.enum[i])
return true;
@@ -212,8 +212,8 @@ chromium.JSONSchemaValidator.prototype.validateEnum = function(instance, schema,
* Validates an instance against an object schema and populates the errors
* property.
*/
-chromium.JSONSchemaValidator.prototype.validateObject = function(instance,
- schema, path) {
+chrome.JSONSchemaValidator.prototype.validateObject = function(instance,
+ schema, path) {
for (var prop in schema.properties) {
var propPath = path ? path + "." + prop : prop;
if (schema.properties[prop] == undefined) {
@@ -245,9 +245,9 @@ chromium.JSONSchemaValidator.prototype.validateObject = function(instance,
* Validates an instance against an array schema and populates the errors
* property.
*/
-chromium.JSONSchemaValidator.prototype.validateArray = function(instance,
- schema, path) {
- var typeOfItems = chromium.JSONSchemaValidator.getType(schema.items);
+chrome.JSONSchemaValidator.prototype.validateArray = function(instance,
+ schema, path) {
+ var typeOfItems = chrome.JSONSchemaValidator.getType(schema.items);
if (typeOfItems == 'object') {
if (schema.minItems && instance.length < schema.minItems) {
@@ -292,8 +292,8 @@ chromium.JSONSchemaValidator.prototype.validateArray = function(instance,
/**
* Validates a string and populates the errors property.
*/
-chromium.JSONSchemaValidator.prototype.validateString = function(instance,
- schema, path) {
+chrome.JSONSchemaValidator.prototype.validateString = function(instance,
+ schema, path) {
if (schema.minLength && instance.length < schema.minLength)
this.addError(path, "stringMinLength", [schema.minLength]);
@@ -308,8 +308,8 @@ chromium.JSONSchemaValidator.prototype.validateString = function(instance,
* Validates a number and populates the errors property. The instance is
* assumed to be a number.
*/
-chromium.JSONSchemaValidator.prototype.validateNumber = function(instance,
- schema, path) {
+chrome.JSONSchemaValidator.prototype.validateNumber = function(instance,
+ schema, path) {
if (schema.minimum && instance < schema.minimum)
this.addError(path, "numberMinValue", [schema.minimum]);
@@ -324,9 +324,9 @@ chromium.JSONSchemaValidator.prototype.validateNumber = function(instance,
* Validates the primitive type of an instance and populates the errors
* property. Returns true if the instance validates, false otherwise.
*/
-chromium.JSONSchemaValidator.prototype.validateType = function(instance, schema,
- path) {
- var actualType = chromium.JSONSchemaValidator.getType(instance);
+chrome.JSONSchemaValidator.prototype.validateType = function(instance, schema,
+ path) {
+ var actualType = chrome.JSONSchemaValidator.getType(instance);
if (schema.type != actualType && !(schema.type == "number" &&
actualType == "integer")) {
this.addError(path, "invalidType", [schema.type, actualType]);
@@ -341,15 +341,15 @@ chromium.JSONSchemaValidator.prototype.validateType = function(instance, schema,
* |replacements| is an array of values to replace '*' characters in the
* message.
*/
-chromium.JSONSchemaValidator.prototype.addError = function(path, key,
- replacements) {
+chrome.JSONSchemaValidator.prototype.addError = function(path, key,
+ replacements) {
this.errors.push({
path: path,
- message: chromium.JSONSchemaValidator.formatError(key, replacements)
+ message: chrome.JSONSchemaValidator.formatError(key, replacements)
});
};
-// Set up chromium.types with some commonly used types...
+// Set up chrome.types with some commonly used types...
(function() {
function extend(base, ext) {
var result = {};
@@ -381,5 +381,5 @@ chromium.JSONSchemaValidator.prototype.addError = function(path, key,
};
};
- chromium.types = types;
+ chrome.types = types;
})();
diff --git a/chrome/renderer/resources/renderer_extension_bindings.js b/chrome/renderer/resources/renderer_extension_bindings.js
index 11494e3..667b97d 100644
--- a/chrome/renderer/resources/renderer_extension_bindings.js
+++ b/chrome/renderer/resources/renderer_extension_bindings.js
@@ -7,41 +7,41 @@
// have your change take effect.
// -----------------------------------------------------------------------------
-var chromium = chromium || {};
+var chrome = chrome || {};
(function () {
native function OpenChannelToExtension(id);
native function PostMessage(portId, msg);
// Port object. Represents a connection to another script context through
// which messages can be passed.
- chromium.Port = function(portId) {
- if (chromium.Port.ports_[portId]) {
+ chrome.Port = function(portId) {
+ if (chrome.Port.ports_[portId]) {
throw new Error("Port '" + portId + "' already exists.");
}
this.portId_ = portId; // TODO(mpcomplete): readonly
- this.onMessage = new chromium.Event();
- chromium.Port.ports_[portId] = this;
+ this.onMessage = new chrome.Event();
+ chrome.Port.ports_[portId] = this;
// Note: this object will never get GCed. If we ever care, we could
// add an "ondetach" method to the onMessage Event that gets called
// when there are no more listeners.
};
// Map of port IDs to port object.
- chromium.Port.ports_ = {};
+ chrome.Port.ports_ = {};
// Called by native code when a channel has been opened to this context.
- chromium.Port.dispatchOnConnect_ = function(portId, tab) {
- var port = new chromium.Port(portId);
+ chrome.Port.dispatchOnConnect_ = function(portId, tab) {
+ var port = new chrome.Port(portId);
if (tab) {
tab = goog.json.parse(tab);
}
port.tab = tab;
- chromium.Event.dispatch_("channel-connect", [port]);
+ chrome.Event.dispatch_("channel-connect", [port]);
};
// Called by native code when a message has been sent to the given port.
- chromium.Port.dispatchOnMessage_ = function(msg, portId) {
- var port = chromium.Port.ports_[portId];
+ chrome.Port.dispatchOnMessage_ = function(msg, portId) {
+ var port = chrome.Port.ports_[portId];
if (port) {
if (msg) {
msg = goog.json.parse(msg);
@@ -52,27 +52,27 @@ var chromium = chromium || {};
// Sends a message asynchronously to the context on the other end of this
// port.
- chromium.Port.prototype.postMessage = function(msg) {
+ chrome.Port.prototype.postMessage = function(msg) {
PostMessage(this.portId_, goog.json.serialize(msg));
};
// Extension object.
- chromium.Extension = function(id) {
+ chrome.Extension = function(id) {
this.id_ = id;
};
// Opens a message channel to the extension. Returns a Port for
// message passing.
- chromium.Extension.prototype.connect = function() {
+ chrome.Extension.prototype.connect = function() {
var portId = OpenChannelToExtension(this.id_);
if (portId == -1)
throw new Error("No such extension: '" + this.id_ + "'");
- return new chromium.Port(portId);
+ return new chrome.Port(portId);
};
// Returns a resource URL that can be used to fetch a resource from this
// extension.
- chromium.Extension.prototype.getURL = function(path) {
+ chrome.Extension.prototype.getURL = function(path) {
return "chrome-extension://" + this.id_ + "/" + path;
};
})();