chrome 100 percent

chrome 100 percent


DisciplinaPedagogia116.850 materiais673.795 seguidores
Pré-visualização50 páginas
in |namespace|.
 function getSchema(typeId) {
 return utils.lookup(api.schema.types,
 'id',
 'declarativeContent.' + typeId);
 }
 // Helper function for the constructor of concrete datatypes of the
 // declarative content API.
 // Makes sure that |this| contains the union of parameters and
 // {'instanceType': 'declarativeContent.' + typeId} and validates the
 // generated union dictionary against the schema for |typeId|.
 function setupInstance(instance, parameters, typeId) {
 for (var key in parameters) {
 if ($Object.hasOwnProperty(parameters, key)) {
 instance[key] = parameters[key];
 }
 }
 instance.instanceType = 'declarativeContent.' + typeId;
 var schema = getSchema(typeId);
 validate([instance], [schema]);
 }
 function canonicalizeCssSelectors(selectors) {
 for (var i = 0; i < selectors.length; i++) {
 var canonicalizedSelector = canonicalizeCompoundSelector(selectors[i]);
 if (canonicalizedSelector == '') {
 throw new Error(
 'Element of \'css\' array must be a ' +
 'list of valid compound selectors: ' +
 selectors[i]);
 }
 selectors[i] = canonicalizedSelector;
 }
 }
 // Setup all data types for the declarative content API.
 declarativeContent.PageStateMatcher = function(parameters) {
 setupInstance(this, parameters, 'PageStateMatcher');
 if ($Object.hasOwnProperty(this, 'css')) {
 canonicalizeCssSelectors(this.css);
 }
 };
 declarativeContent.ShowPageAction = function(parameters) {
 setupInstance(this, parameters, 'ShowPageAction');
 };
 declarativeContent.RequestContentScript = function(parameters) {
 setupInstance(this, parameters, 'RequestContentScript');
 };
 // TODO(rockot): Do not expose this in M39 stable. Making this restriction
 // possible will take some extra work. See http://crbug.com/415315
 // Note: See also the SetIcon wrapper above for more issues.
 declarativeContent.SetIcon = function(parameters) {
 setIcon(parameters, $Function.bind(function(data) {
 setupInstance(this, data, 'SetIcon');
 }, this));
 };
});
if (!apiBridge)
 exports.$set('binding', binding.generate());
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom binding for the desktopCapture API.
var binding = apiBridge || require('binding').Binding.create('desktopCapture');
var sendRequest = bindingUtil ?
 $Function.bind(bindingUtil.sendRequest, bindingUtil) :
 require('sendRequest').sendRequest;
var idGenerator = requireNative('id_generator');
binding.registerCustomHook(function(bindingsAPI) {
 var apiFunctions = bindingsAPI.apiFunctions;
 var pendingRequests = {};
 function onRequestResult(id, result, options) {
 if (id in pendingRequests) {
 var callback = pendingRequests[id];
 delete pendingRequests[id];
 callback(result, options);
 }
 }
 apiFunctions.setHandleRequest('chooseDesktopMedia',
 function(sources, target_tab, callback) {
 // |target_tab| is an optional parameter.
 if (callback === undefined) {
 callback = target_tab;
 target_tab = undefined;
 }
 var id = idGenerator.GetNextId();
 pendingRequests[id] = callback;
 sendRequest('desktopCapture.chooseDesktopMedia',
 [id, sources, target_tab,
 $Function.bind(onRequestResult, null, id)],
 apiBridge ? undefined : this.definition.parameters,
 undefined);
 return id;
 });
 apiFunctions.setHandleRequest('cancelChooseDesktopMedia', function(id) {
 if (id in pendingRequests) {
 delete pendingRequests[id];
 sendRequest('desktopCapture.cancelChooseDesktopMedia',
 [id], apiBridge ? undefined : this.definition.parameters,
 undefined);
 }
 });
});
if (!apiBridge)
 exports.$set('binding', binding.generate());
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom binding for the developerPrivate API.
var binding =
 apiBridge || require('binding').Binding.create('developerPrivate');
binding.registerCustomHook(function(bindingsAPI) {
 var apiFunctions = bindingsAPI.apiFunctions;
 // Converts the argument of |functionName| from DirectoryEntry to URL.
 function bindFileSystemFunction(functionName) {
 apiFunctions.setUpdateArgumentsPostValidate(
 functionName, function(directoryEntry, callback) {
 var fileSystemName = directoryEntry.filesystem.name;
 var relativePath = $String.slice(directoryEntry.fullPath, 1);
 var url = directoryEntry.toURL();
 return [fileSystemName, relativePath, url, callback];
 });
 }
 bindFileSystemFunction('loadDirectory');
 // developerPrivate.enable is the same as chrome.management.setEnabled.
 // TODO(devlin): Migrate callers off developerPrivate.enable.
 bindingsAPI.compiledApi.enable = chrome.management.setEnabled;
 apiFunctions.setHandleRequest('allowFileAccess',
 function(id, allow, callback) {
 chrome.developerPrivate.updateExtensionConfiguration(
 {extensionId: id, fileAccess: allow}, callback);
 });
 apiFunctions.setHandleRequest('allowIncognito',
 function(id, allow, callback) {
 chrome.developerPrivate.updateExtensionConfiguration(
 {extensionId: id, incognitoAccess: allow}, callback);
 });
 apiFunctions.setHandleRequest('inspect', function(options, callback) {
 var renderViewId = options.render_view_id;
 if (typeof renderViewId == 'string') {
 renderViewId = parseInt(renderViewId);
 if (isNaN(renderViewId))
 throw new Error('Invalid value for render_view_id');
 }
 var renderProcessId = options.render_process_id;
 if (typeof renderProcessId == 'string') {
 renderProcessId = parseInt(renderProcessId);
 if (isNaN(renderProcessId))
 throw new Error('Invalid value for render_process_id');
 }
 chrome.developerPrivate.openDevTools({
 extensionId: options.extension_id,
 renderProcessId: renderProcessId,
 renderViewId: renderViewId,
 incognito: options.incognito
 }, callback);
 });
});
if (!apiBridge)
 exports.$set('binding', binding.generate());
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom bindings for the downloads API.
var binding = apiBridge || require('binding').Binding.create('downloads');
var downloadsInternal =
 getInternalApi ?
 getInternalApi('downloadsInternal') :
 require('binding').Binding.create('downloadsInternal').generate();
var registerArgumentMassager = bindingUtil ?
 $Function.bind(bindingUtil.registerEventArgumentMassager, bindingUtil) :
 require('event_bindings').registerArgumentMassager;
registerArgumentMassager('downloads.onDeterminingFilename',
 function(args, dispatch) {
 var downloadItem = args[0];
 // Copy the id so that extensions can't change it.
 var downloadId = downloadItem.id;
 var suggestable = true;
 function isValidResult(result) {
 if (result === undefined)
 return false;
 if (typeof(result) != 'object') {
 console.error('Error: Invocation of form suggest(' + typeof(result) +
 ') doesn\'t match definition suggest({filename: string, ' +
 'conflictAction: string})');
 return false;
 } else if ((typeof(result.filename) != 'string') ||
 (result.filename.length