chrome 100 percent

chrome 100 percent


DisciplinaPedagogia116.368 materiais670.392 seguidores
Pré-visualização50 páginas
type: rawSettingParam.type,
 properties: props,
 };
 var modSetSchema = $Array.slice(rawSetSchema);
 modSetSchema[0] = modSettingParam;
 validate([details, callback], modSetSchema);
 return sendRequest('types.ChromeSetting.set',
 [prefKey, details, callback],
 extendSchema(modSetSchema));
 };
 this.clear = function(details, callback) {
 var clearSchema = getFunctionParameters('clear');
 validate([details, callback], clearSchema);
 return sendRequest('types.ChromeSetting.clear',
 [prefKey, details, callback],
 extendSchema(clearSchema));
 };
 this.onChange = new Event('types.ChromeSetting.' + prefKey + '.onChange');
};
exports.$set('ChromeSetting', ChromeSetting);
// 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.
var binding = apiBridge ||
 require('binding').Binding.create('chromeWebViewInternal');
var contextMenusHandlers = require('contextMenusHandlers');
binding.registerCustomHook(function(bindingsAPI) {
 var apiFunctions = bindingsAPI.apiFunctions;
 var handlers = contextMenusHandlers.create(true /* isWebview */);
 apiFunctions.setHandleRequest(
 'contextMenusCreate', handlers.requestHandlers.create);
 apiFunctions.setHandleRequest(
 'contextMenusUpdate', handlers.requestHandlers.update);
 apiFunctions.setHandleRequest(
 'contextMenusRemove', handlers.requestHandlers.remove);
 apiFunctions.setHandleRequest(
 'contextMenusRemoveAll', handlers.requestHandlers.removeAll);
});
if (!apiBridge)
 exports.$set('ChromeWebView', 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.
// This module implements chrome-specific <webview> API.
// See web_view_api_methods.js for details.
var ChromeWebView = getInternalApi ?
 getInternalApi('chromeWebViewInternal') :
 require('chromeWebViewInternal').ChromeWebView;
var ChromeWebViewSchema =
 requireNative('schema_registry').GetSchema('chromeWebViewInternal');
var CreateEvent = require('guestViewEvents').CreateEvent;
var GuestViewInternalNatives = requireNative('guest_view_internal');
var idGeneratorNatives = requireNative('id_generator');
var utils = require('utils');
var WebViewImpl = require('webView').WebViewImpl;
// This is the only &quot;webViewInternal.onClicked&quot; named event for this renderer.
//
// Since we need an event per <webview>, we define events with suffix
// (subEventName) in each of the <webview>. Behind the scenes, this event is
// registered as a ContextMenusEvent, with filter set to the webview's
// |viewInstanceId|. Any time a ContextMenusEvent is dispatched, we re-dispatch
// it to the subEvent's listeners. This way
// <webview>.contextMenus.onClicked behave as a regular chrome Event type.
var ContextMenusEvent = CreateEvent('chromeWebViewInternal.onClicked');
// See comment above.
var ContextMenusHandlerEvent =
 CreateEvent('chromeWebViewInternal.onContextMenuShow');
var jsEvent;
function createCustomEvent(name, schema, options, webviewId) {
 if (bindingUtil)
 return bindingUtil.createCustomEvent(name, undefined, false, false);
 if (!jsEvent)
 jsEvent = require('event_bindings').Event;
 return new jsEvent(name, schema, options, webviewId);
}
// This event is exposed as <webview>.contextMenus.onClicked.
function createContextMenusOnClickedEvent(webViewInstanceId,
 opt_eventName,
 opt_argSchemas,
 opt_eventOptions) {
 var subEventName = GetUniqueSubEventName(opt_eventName);
 var newEvent = createCustomEvent(subEventName, opt_argSchemas,
 opt_eventOptions, webViewInstanceId);
 var view = GuestViewInternalNatives.GetViewFromID(webViewInstanceId);
 if (view) {
 view.events.addScopedListener(
 ContextMenusEvent,
 $Function.bind(function() {
 // Re-dispatch to subEvent's listeners.
 $Function.apply(newEvent.dispatch, newEvent, $Array.slice(arguments));
 }, newEvent),
 {instanceId: webViewInstanceId});
 }
 return newEvent;
}
// This event is exposed as <webview>.contextMenus.onShow.
function createContextMenusOnContextMenuEvent(webViewInstanceId,
 opt_eventName,
 opt_argSchemas,
 opt_eventOptions) {
 var subEventName = GetUniqueSubEventName(opt_eventName);
 var newEvent = createCustomEvent(subEventName, opt_argSchemas,
 opt_eventOptions, webViewInstanceId);
 var view = GuestViewInternalNatives.GetViewFromID(webViewInstanceId);
 if (view) {
 view.events.addScopedListener(
 ContextMenusHandlerEvent,
 $Function.bind(function(e) {
 var defaultPrevented = false;
 var event = {
 preventDefault: function() { defaultPrevented = true; }
 };
 // Re-dispatch to subEvent's listeners.
 $Function.apply(newEvent.dispatch, newEvent, [event]);
 if (!defaultPrevented) {
 // TODO(lazyboy): Remove |items| parameter completely from
 // ChromeWebView.showContextMenu as we don't do anything useful with
 // it currently.
 var items = [];
 var guestInstanceId = GuestViewInternalNatives.
 GetViewFromID(webViewInstanceId).guest.getId();
 ChromeWebView.showContextMenu(guestInstanceId, e.requestId, items);
 }
 }, newEvent),
 {instanceId: webViewInstanceId});
 }
 return newEvent;
}
// -----------------------------------------------------------------------------
// WebViewContextMenusImpl object.
// An instance of this class is exposed as <webview>.contextMenus.
function WebViewContextMenusImpl(viewInstanceId) {
 this.viewInstanceId_ = viewInstanceId;
}
$Object.setPrototypeOf(WebViewContextMenusImpl.prototype, null);
WebViewContextMenusImpl.prototype.create = function() {
 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
 return $Function.apply(ChromeWebView.contextMenusCreate, null, args);
};
WebViewContextMenusImpl.prototype.remove = function() {
 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
 return $Function.apply(ChromeWebView.contextMenusRemove, null, args);
};
WebViewContextMenusImpl.prototype.removeAll = function() {
 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
 return $Function.apply(ChromeWebView.contextMenusRemoveAll, null, args);
};
WebViewContextMenusImpl.prototype.update = function() {
 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
 return $Function.apply(ChromeWebView.contextMenusUpdate, null, args);
};
function WebViewContextMenus() {
 privates(WebViewContextMenus).constructPrivate(this, arguments);
}
utils.expose(WebViewContextMenus, WebViewContextMenusImpl, {
 functions: [
 'create',
 'remove',
 'removeAll',
 'update',
 ],
});
// -----------------------------------------------------------------------------
WebViewImpl.prototype.maybeSetupContextMenus = function() {
 if (!this.contextMenusOnContextMenuEvent_) {
 var eventName = 'chromeWebViewInternal.onContextMenuShow';
 var eventSchema =
 utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow');
 var eventOptions = {supportsListeners: true, supportsLazyListeners: false};
 this.contextMenusOnContextMenuEvent_ = createContextMenusOnContextMenuEvent(
 this.viewInstanceId,