Backed out changeset 6c4c8b4e38cf (bug 1394580)

This commit is contained in:
Sebastian Hengst 2017-09-05 21:51:30 +02:00
Родитель aead58a5ad
Коммит d7c61803f9
6 изменённых файлов: 53 добавлений и 175 удалений

Просмотреть файл

@ -1,20 +1,17 @@
# Stylesheets # Stylesheets
category agent-style-sheets browser-content-stylesheet chrome://geckoview/skin/content.css category agent-style-sheets browser-content-stylesheet chrome://geckoview/skin/content.css
# GeckoViewStartup.js
component {8e993c34-fdd6-432c-967e-f995d888777f} GeckoViewStartup.js
contract @mozilla.org/geckoview/startup;1 {8e993c34-fdd6-432c-967e-f995d888777f}
category app-startup GeckoViewStartup service,@mozilla.org/geckoview/startup;1
category profile-after-change GeckoViewStartup @mozilla.org/geckoview/startup;1 process=main
# GeckoViewPermission.js # GeckoViewPermission.js
component {42f3c238-e8e8-4015-9ca2-148723a8afcf} GeckoViewPermission.js component {42f3c238-e8e8-4015-9ca2-148723a8afcf} GeckoViewPermission.js
contract @mozilla.org/content-permission/prompt;1 {42f3c238-e8e8-4015-9ca2-148723a8afcf} contract @mozilla.org/content-permission/prompt;1 {42f3c238-e8e8-4015-9ca2-148723a8afcf}
category app-startup GeckoViewPermission service,@mozilla.org/content-permission/prompt;1
# GeckoViewPrompt.js # GeckoViewPrompt.js
component {076ac188-23c1-4390-aa08-7ef1f78ca5d9} GeckoViewPrompt.js component {076ac188-23c1-4390-aa08-7ef1f78ca5d9} GeckoViewPrompt.js
contract @mozilla.org/embedcomp/prompt-service;1 {076ac188-23c1-4390-aa08-7ef1f78ca5d9} contract @mozilla.org/embedcomp/prompt-service;1 {076ac188-23c1-4390-aa08-7ef1f78ca5d9}
contract @mozilla.org/prompter;1 {076ac188-23c1-4390-aa08-7ef1f78ca5d9} contract @mozilla.org/prompter;1 {076ac188-23c1-4390-aa08-7ef1f78ca5d9}
category app-startup GeckoViewPrompt service,@mozilla.org/prompter;1
category profile-after-change GeckoViewPrompt @mozilla.org/prompter;1 process=main
component {aa0dd6fc-73dd-4621-8385-c0b377e02cee} GeckoViewPrompt.js process=main component {aa0dd6fc-73dd-4621-8385-c0b377e02cee} GeckoViewPrompt.js process=main
contract @mozilla.org/colorpicker;1 {aa0dd6fc-73dd-4621-8385-c0b377e02cee} process=main contract @mozilla.org/colorpicker;1 {aa0dd6fc-73dd-4621-8385-c0b377e02cee} process=main
component {e4565e36-f101-4bf5-950b-4be0887785a9} GeckoViewPrompt.js process=main component {e4565e36-f101-4bf5-950b-4be0887785a9} GeckoViewPrompt.js process=main

Просмотреть файл

@ -4,12 +4,11 @@
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, { XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
EventDispatcher: "resource://gre/modules/Messaging.jsm", "resource://gre/modules/Messaging.jsm");
Services: "resource://gre/modules/Services.jsm",
});
// See: http://developer.android.com/reference/android/Manifest.permission.html // See: http://developer.android.com/reference/android/Manifest.permission.html
const PERM_ACCESS_FINE_LOCATION = "android.permission.ACCESS_FINE_LOCATION"; const PERM_ACCESS_FINE_LOCATION = "android.permission.ACCESS_FINE_LOCATION";
@ -17,7 +16,6 @@ const PERM_CAMERA = "android.permission.CAMERA";
const PERM_RECORD_AUDIO = "android.permission.RECORD_AUDIO"; const PERM_RECORD_AUDIO = "android.permission.RECORD_AUDIO";
function GeckoViewPermission() { function GeckoViewPermission() {
this.wrappedJSObject = this;
} }
GeckoViewPermission.prototype = { GeckoViewPermission.prototype = {
@ -31,6 +29,12 @@ GeckoViewPermission.prototype = {
/* ---------- nsIObserver ---------- */ /* ---------- nsIObserver ---------- */
observe: function(aSubject, aTopic, aData) { observe: function(aSubject, aTopic, aData) {
switch (aTopic) { switch (aTopic) {
case "app-startup": {
Services.obs.addObserver(this, "getUserMedia:ask-device-permission");
Services.obs.addObserver(this, "getUserMedia:request");
Services.obs.addObserver(this, "PeerConnection:request");
break;
}
case "getUserMedia:ask-device-permission": { case "getUserMedia:ask-device-permission": {
this.handleMediaAskDevicePermission(aData, aSubject); this.handleMediaAskDevicePermission(aData, aSubject);
break; break;

Просмотреть файл

@ -4,26 +4,60 @@
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, { XPCOMUtils.defineLazyModuleGetter(this, "ContentPrefServiceParent",
EventDispatcher: "resource://gre/modules/Messaging.jsm", "resource://gre/modules/ContentPrefServiceParent.jsm");
FileUtils: "resource://gre/modules/FileUtils.jsm",
Services: "resource://gre/modules/Services.jsm", XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
}); "resource://gre/modules/Messaging.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "UUIDGen", XPCOMUtils.defineLazyServiceGetter(this, "UUIDGen",
"@mozilla.org/uuid-generator;1", "nsIUUIDGenerator"); "@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
function PromptFactory() { function PromptFactory() {
this.wrappedJSObject = this;
} }
PromptFactory.prototype = { PromptFactory.prototype = {
classID: Components.ID("{076ac188-23c1-4390-aa08-7ef1f78ca5d9}"), classID: Components.ID("{076ac188-23c1-4390-aa08-7ef1f78ca5d9}"),
QueryInterface: XPCOMUtils.generateQI([ QueryInterface: XPCOMUtils.generateQI([
Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]), Ci.nsIObserver, Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
/* ---------- nsIObserver ---------- */
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "app-startup": {
Services.obs.addObserver(this, "chrome-document-global-created");
Services.obs.addObserver(this, "content-document-global-created");
break;
}
case "profile-after-change": {
// ContentPrefServiceParent is needed for e10s file picker.
ContentPrefServiceParent.init();
Services.mm.addMessageListener("GeckoView:Prompt", this);
break;
}
case "chrome-document-global-created":
case "content-document-global-created": {
let win = aSubject.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell).QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
if (win !== aSubject) {
// Only attach to top-level windows.
return;
}
win.addEventListener("click", this); // non-capture
win.addEventListener("contextmenu", this); // non-capture
break;
}
}
},
handleEvent: function(aEvent) { handleEvent: function(aEvent) {
switch (aEvent.type) { switch (aEvent.type) {

Просмотреть файл

@ -1,155 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
function GeckoViewStartup() {
}
GeckoViewStartup.prototype = {
classID: Components.ID("{8e993c34-fdd6-432c-967e-f995d888777f}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
addLazyGetter: function(aOptions) {
let {name, script, service, module, observers, ppmm, mm} = aOptions;
if (script) {
XPCOMUtils.defineLazyScriptGetter(this, name, script);
} else if (module) {
XPCOMUtils.defineLazyGetter(this, name, _ => {
let sandbox = {};
Cu.import(module, sandbox);
if (aOptions.init) {
aOptions.init.call(this, sandbox[name]);
}
return sandbox[name];
});
} else if (service) {
XPCOMUtils.defineLazyGetter(this, name, _ =>
Cc[service].getService(Ci.nsISupports).wrappedJSObject);
}
if (observers) {
let observer = (subject, topic, data) => {
Services.obs.removeObserver(observer, topic);
if (!aOptions.once) {
Services.obs.addObserver(this[name], topic);
}
this[name].observe(subject, topic, data); // Explicitly notify new observer
};
observers.forEach(topic => Services.obs.addObserver(observer, topic));
}
if (ppmm || mm) {
let target = ppmm ? Services.ppmm : Services.mm;
let listener = msg => {
target.removeMessageListener(msg.name, listener);
if (!aOptions.once) {
target.addMessageListener(msg.name, this[name]);
}
this[name].receiveMessage(msg);
};
(ppmm || mm).forEach(msg => target.addMessageListener(msg, listener));
}
},
addLazyEventListener: function(aOptions) {
let {name, target, events, options} = aOptions;
let listener = event => {
if (!options || !options.once) {
target.removeEventListener(event.type, listener, options);
target.addEventListener(event.type, this[name], options);
}
this[name].handleEvent(event);
};
events.forEach(event => target.addEventListener(event, listener, options));
},
/* ---------- nsIObserver ---------- */
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "app-startup": {
// Parent and content process.
Services.obs.addObserver(this, "chrome-document-global-created");
Services.obs.addObserver(this, "content-document-global-created");
this.addLazyGetter({
name: "GeckoViewPermission",
service: "@mozilla.org/content-permission/prompt;1",
observers: [
"getUserMedia:ask-device-permission",
"getUserMedia:request",
"PeerConnection:request",
],
});
if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {
// Content process only.
this.addLazyGetter({
name: "GeckoViewPrompt",
service: "@mozilla.org/prompter;1",
});
}
break;
}
case "profile-after-change": {
// Parent process only.
// ContentPrefServiceParent is needed for e10s file picker.
this.addLazyGetter({
name: "ContentPrefServiceParent",
module: "resource://gre/modules/ContentPrefServiceParent.jsm",
init: cpsp => cpsp.alwaysInit(),
ppmm: [
"ContentPrefs:FunctionCall",
"ContentPrefs:AddObserverForName",
"ContentPrefs:RemoveObserverForName",
],
});
this.addLazyGetter({
name: "GeckoViewPrompt",
service: "@mozilla.org/prompter;1",
mm: [
"GeckoView:Prompt",
],
});
break;
}
case "chrome-document-global-created":
case "content-document-global-created": {
let win = aSubject.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell).QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
if (win !== aSubject) {
// Only attach to top-level windows.
return;
}
this.addLazyEventListener({
name: "GeckoViewPrompt",
target: win,
events: [
"click",
"contextmenu",
],
options: {
capture: false,
mozSystemGroup: true,
},
});
break;
}
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([GeckoViewStartup]);

Просмотреть файл

@ -8,5 +8,4 @@ EXTRA_COMPONENTS += [
'GeckoView.manifest', 'GeckoView.manifest',
'GeckoViewPermission.js', 'GeckoViewPermission.js',
'GeckoViewPrompt.js', 'GeckoViewPrompt.js',
'GeckoViewStartup.js',
] ]

Просмотреть файл

@ -526,7 +526,6 @@
@BINPATH@/components/GeckoView.manifest @BINPATH@/components/GeckoView.manifest
@BINPATH@/components/GeckoViewPrompt.js @BINPATH@/components/GeckoViewPrompt.js
@BINPATH@/components/GeckoViewPermission.js @BINPATH@/components/GeckoViewPermission.js
@BINPATH@/components/GeckoViewStartup.js
#else #else
@BINPATH@/chrome/chrome@JAREXT@ @BINPATH@/chrome/chrome@JAREXT@
@BINPATH@/chrome/chrome.manifest @BINPATH@/chrome/chrome.manifest