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

Side by Side Diff: extensions/renderer/resources/web_view_request_custom_bindings.js

Issue 654043002: Created "guest_view/" directory to contain all the guestview files (like web_view* and app_view*) i… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « extensions/renderer/resources/web_view_internal.js ('k') | 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Custom binding for the webViewRequest API.
6
7 var binding = require('binding').Binding.create('webViewRequest');
8
9 var declarativeWebRequestSchema =
10 requireNative('schema_registry').GetSchema('declarativeWebRequest');
11 var utils = require('utils');
12 var validate = require('schemaUtils').validate;
13
14 binding.registerCustomHook(function(api) {
15 var webViewRequest = api.compiledApi;
16
17 // Returns the schema definition of type |typeId| defined in
18 // |declarativeWebRequestScheme.types|.
19 function getSchema(typeId) {
20 return utils.lookup(declarativeWebRequestSchema.types,
21 'id',
22 'declarativeWebRequest.' + typeId);
23 }
24
25 // Helper function for the constructor of concrete datatypes of the
26 // declarative webRequest API.
27 // Makes sure that |this| contains the union of parameters and
28 // {'instanceType': 'declarativeWebRequest.' + typeId} and validates the
29 // generated union dictionary against the schema for |typeId|.
30 function setupInstance(instance, parameters, typeId) {
31 for (var key in parameters) {
32 if ($Object.hasOwnProperty(parameters, key)) {
33 instance[key] = parameters[key];
34 }
35 }
36
37 instance.instanceType = 'declarativeWebRequest.' + typeId;
38 var schema = getSchema(typeId);
39 validate([instance], [schema]);
40 }
41
42 // Setup all data types for the declarative webRequest API from the schema.
43 for (var i = 0; i < declarativeWebRequestSchema.types.length; ++i) {
44 var typeSchema = declarativeWebRequestSchema.types[i];
45 var typeId = typeSchema.id.replace('declarativeWebRequest.', '');
46 var action = function(typeId) {
47 return function(parameters) {
48 setupInstance(this, parameters, typeId);
49 };
50 }(typeId);
51 webViewRequest[typeId] = action;
52 }
53 });
54
55 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « extensions/renderer/resources/web_view_internal.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698