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

Unified Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 7104002: Does not crash with unexpected function in debug build. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update Created 9 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 side-by-side diff with in-line comments
Download patch
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 af682c07e189a3c97fa5363260f7862ab0a1cc22..48536985c71afefb28fbea27ac6570041deb0ef4 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -499,6 +499,24 @@ var chrome = chrome || {};
};
}
+ // Get the platform from navigator.appVersion.
+ function getPlatform() {
+ var platforms = [
+ [/CrOS Touch/, "chromeos touch"],
+ [/CrOS/, "chromeos"],
+ [/Linux/, "linux"],
+ [/Mac/, "mac"],
+ [/Win/, "win"],
+ ];
+
+ for (var i = 0; i < platforms.length; i++) {
+ if (platforms[i][0].test(navigator.appVersion)) {
+ return platforms[i][1];
+ }
+ }
+ return "unknown";
+ }
+
chromeHidden.onLoad.addListener(function (extensionId) {
if (!extensionId) {
return;
@@ -521,8 +539,14 @@ var chrome = chrome || {};
// TOOD(rafaelw): Consider providing some convenient override points
// for api functions that wish to insert themselves into the call.
var apiDefinitions = chromeHidden.JSON.parse(GetExtensionAPIDefinition());
+ var platform = getPlatform();
apiDefinitions.forEach(function(apiDef) {
+ // Check platform, if apiDef has platforms key.
+ if (apiDef.platforms && apiDef.platforms.indexOf(platform) == -1) {
+ return;
+ }
+
var module = chrome;
var namespaces = apiDef.namespace.split('.');
for (var index = 0, name; name = namespaces[index]; index++) {

Powered by Google App Engine
This is Rietveld 408576698