Bug 1450344 - 1. Use frame script to handle input prompts; r?esawin
Use a frame script to handle <select> and <input type="date/time">
prompts, in order to support e10s iframes.
MozReview-Commit-ID: AE0KGu8QwUf
new file mode 100644
--- /dev/null
+++ b/mobile/android/chrome/geckoview/GeckoViewPromptContent.js
@@ -0,0 +1,15 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* 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/. */
+
+ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
+
+GeckoViewUtils.addLazyEventListener(this, ["click", "contextmenu"], {
+ handler: _ =>
+ Cc["@mozilla.org/prompter;1"].getService(Ci.nsIDOMEventListener),
+ options: {
+ capture: false,
+ mozSystemGroup: true,
+ },
+});
--- a/mobile/android/chrome/geckoview/jar.mn
+++ b/mobile/android/chrome/geckoview/jar.mn
@@ -6,10 +6,11 @@ geckoview.jar:
% content geckoview %content/
content/ErrorPageEventHandler.js
content/geckoview.xul
content/geckoview.js
content/GeckoViewContent.js
content/GeckoViewContentSettings.js
content/GeckoViewNavigationContent.js
+ content/GeckoViewPromptContent.js
content/GeckoViewScrollContent.js
content/GeckoViewSelectionActionContent.js
--- a/mobile/android/components/geckoview/GeckoViewStartup.js
+++ b/mobile/android/components/geckoview/GeckoViewStartup.js
@@ -33,37 +33,31 @@ GeckoViewStartup.prototype = {
protocolHandler.setSubstitution("android", Services.io.newURI(url));
},
/* ---------- 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");
-
GeckoViewUtils.addLazyGetter(this, "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) {
// Parent process only.
this.setResourceSubstitutions();
- } else {
- // Content process only.
- GeckoViewUtils.addLazyGetter(this, "GeckoViewPrompt", {
- service: "@mozilla.org/prompter;1",
- });
+ Services.mm.loadFrameScript(
+ "chrome://geckoview/content/GeckoViewPromptContent.js", true);
}
break;
}
case "profile-after-change": {
// Parent process only.
// ContentPrefServiceParent is needed for e10s file picker.
GeckoViewUtils.addLazyGetter(this, "ContentPrefServiceParent", {
@@ -79,31 +73,13 @@ GeckoViewStartup.prototype = {
GeckoViewUtils.addLazyGetter(this, "GeckoViewPrompt", {
service: "@mozilla.org/prompter;1",
mm: [
"GeckoView:Prompt",
],
});
break;
}
-
- case "chrome-document-global-created":
- case "content-document-global-created": {
- let win = GeckoViewUtils.getChromeWindow(aSubject);
- if (win !== aSubject) {
- // Only attach to top-level windows.
- return;
- }
-
- GeckoViewUtils.addLazyEventListener(win, ["click", "contextmenu"], {
- handler: _ => this.GeckoViewPrompt,
- options: {
- capture: false,
- mozSystemGroup: true,
- },
- });
- break;
- }
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([GeckoViewStartup]);