| Index: chrome/renderer/resources/extension_process_bindings.js
|
| diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
|
| index 657baece06980ce6884d94fb5da375742a1364a3..95e520eb01d0a04fe32f890beb5345bed3487281 100644
|
| --- a/chrome/renderer/resources/extension_process_bindings.js
|
| +++ b/chrome/renderer/resources/extension_process_bindings.js
|
| @@ -115,6 +115,24 @@ var chrome = chrome || {};
|
| }
|
| };
|
|
|
| + chromeHidden.setViewType = function(type) {
|
| + var modeClass = "chrome-" + type;
|
| + var className = document.documentElement.className;
|
| + if (className && className.length) {
|
| + var classes = className.split(" ");
|
| + var new_classes = [];
|
| + classes.forEach(function(cls) {
|
| + if (cls.indexOf("chrome-") != 0) {
|
| + new_classes.push(cls);
|
| + }
|
| + });
|
| + new_classes.push(modeClass);
|
| + document.documentElement.className = new_classes.join(" ");
|
| + } else {
|
| + document.documentElement.className = modeClass;
|
| + }
|
| + };
|
| +
|
| function prepareRequest(args, argSchemas) {
|
| var request = {};
|
| var argCount = args.length;
|
| @@ -156,14 +174,6 @@ var chrome = chrome || {};
|
| request.callback ? true : false);
|
| }
|
|
|
| - // Using forEach for convenience, and to bind |module|s & |apiDefs|s via
|
| - // closures.
|
| - function forEach(a, f) {
|
| - for (var i = 0; i < a.length; i++) {
|
| - f(a[i], i);
|
| - }
|
| - }
|
| -
|
| function bind(obj, func) {
|
| return function() {
|
| return func.apply(obj, arguments);
|
| @@ -211,20 +221,20 @@ var chrome = chrome || {};
|
| // for api functions that wish to insert themselves into the call.
|
| var apiDefinitions = JSON.parse(GetExtensionAPIDefinition());
|
|
|
| - forEach(apiDefinitions, function(apiDef) {
|
| + apiDefinitions.forEach(function(apiDef) {
|
| chrome[apiDef.namespace] = chrome[apiDef.namespace] || {};
|
| var module = chrome[apiDef.namespace];
|
|
|
| // Add types to global validationTypes
|
| if (apiDef.types) {
|
| - forEach(apiDef.types, function(t) {
|
| + apiDef.types.forEach(function(t) {
|
| chromeHidden.validationTypes.push(t);
|
| });
|
| }
|
|
|
| // Setup Functions.
|
| if (apiDef.functions) {
|
| - forEach(apiDef.functions, function(functionDef) {
|
| + apiDef.functions.forEach(function(functionDef) {
|
| // Module functions may have been defined earlier by hand. Don't
|
| // clobber them.
|
| if (module[functionDef.name])
|
| @@ -249,7 +259,7 @@ var chrome = chrome || {};
|
|
|
| // Setup Events
|
| if (apiDef.events) {
|
| - forEach(apiDef.events, function(eventDef) {
|
| + apiDef.events.forEach(function(eventDef) {
|
| // Module events may have been defined earlier by hand. Don't clobber
|
| // them.
|
| if (module[eventDef.name])
|
| @@ -296,8 +306,8 @@ var chrome = chrome || {};
|
|
|
| apiFunctions["devtools.getTabEvents"].handleRequest = function(tabId) {
|
| var tabIdProxy = {};
|
| - forEach(["onPageEvent", "onTabUrlChange", "onTabClose"],
|
| - function(name) {
|
| + var functions = ["onPageEvent", "onTabUrlChange", "onTabClose"];
|
| + functions.forEach(function(name) {
|
| // Event disambiguation is handled by name munging. See
|
| // chrome/browser/extensions/extension_devtools_events.h for the C++
|
| // equivalent of this logic.
|
|
|