зеркало из https://github.com/mozilla/gecko-dev.git
Bug 795630 - Remove CapturePicker and related files. r=mbrubeck
This commit is contained in:
Родитель
35dcaf0fc3
Коммит
707c9fc63f
|
@ -89,7 +89,6 @@ let ScriptContexts = {};
|
|||
["FormHelperUI", "chrome://browser/content/helperui/FormHelperUI.js"],
|
||||
["BrowserTouchHandler", "chrome://browser/content/BrowserTouchHandler.js"],
|
||||
["AlertsHelper", "chrome://browser/content/helperui/AlertsHelper.js"],
|
||||
["CapturePickerUI", "chrome://browser/content/helperui/CapturePickerUI.js"],
|
||||
["AutofillMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
|
||||
["ContextMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
|
||||
["MenuControlUI", "chrome://browser/content/helperui/MenuUI.js"],
|
||||
|
|
|
@ -154,13 +154,6 @@ var BrowserUI = {
|
|||
Util.dumpLn("Exception in delay load module:", ex.message);
|
||||
}
|
||||
|
||||
try {
|
||||
// XXX This is currently failing
|
||||
CapturePickerUI.init();
|
||||
} catch(ex) {
|
||||
Util.dumpLn("Exception in CapturePickerUI:", ex.message);
|
||||
}
|
||||
|
||||
#ifdef MOZ_UPDATER
|
||||
// Check for updates in progress
|
||||
let updatePrompt = Cc["@mozilla.org/updates/update-prompt;1"].createInstance(Ci.nsIUpdatePrompt);
|
||||
|
|
|
@ -1,145 +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/. */
|
||||
|
||||
var CaptureDialog = {
|
||||
_video: null,
|
||||
_container: null,
|
||||
_lastOrientationEvent: null,
|
||||
|
||||
init: function() {
|
||||
document.getElementsByAttribute('command', 'cmd_ok')[0].focus();
|
||||
this._video = document.getElementById("capturepicker-video");
|
||||
this._container = document.getElementById("capturepicker-container");
|
||||
window.addEventListener("resize", this, false);
|
||||
window.addEventListener("deviceorientation", this, false);
|
||||
this.handleEvent({ type: "resize" });
|
||||
},
|
||||
|
||||
setPreviewOrientation: function(aEvent) {
|
||||
if (window.innerWidth < window.innerHeight) {
|
||||
if (aEvent.beta > 0)
|
||||
this._video.style.MozTransform = "rotate(90deg)";
|
||||
else
|
||||
this._video.style.MozTransform = "rotate(-90deg)";
|
||||
this._container.classList.add("vertical");
|
||||
}
|
||||
else {
|
||||
if (aEvent.gamma > 0)
|
||||
this._video.style.MozTransform = "rotate(180deg)";
|
||||
else
|
||||
this._video.style.MozTransform = "";
|
||||
this._container.classList.remove("vertical");
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function(aEvent) {
|
||||
if (aEvent.type == "deviceorientation") {
|
||||
if (!this._lastOrientationEvent)
|
||||
this.setPreviewOrientation(aEvent);
|
||||
this._lastOrientationEvent = aEvent;
|
||||
}
|
||||
else if (aEvent.type == "resize") {
|
||||
if (this._lastOrientationEvent)
|
||||
this.setPreviewOrientation(this._lastOrientationEvent);
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
this.doClose(false);
|
||||
},
|
||||
|
||||
capture: function() {
|
||||
this.doClose(true);
|
||||
},
|
||||
|
||||
doClose: function(aResult) {
|
||||
window.removeEventListener("resize", this, false);
|
||||
window.removeEventListener("deviceorientation", this, false);
|
||||
let dialog = document.getElementById("capturepicker-dialog");
|
||||
dialog.arguments.result = aResult;
|
||||
if (aResult)
|
||||
dialog.arguments.path = this.saveFrame();
|
||||
document.getElementById("capturepicker-video").setAttribute("src", "");
|
||||
dialog.close();
|
||||
},
|
||||
|
||||
saveFrame: function() {
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let width = 320;
|
||||
let height = 240;
|
||||
let rotation = 0;
|
||||
|
||||
if (window.innerWidth < window.innerHeight) {
|
||||
width = 240;
|
||||
height = 320;
|
||||
if (this._lastOrientationEvent.beta > 0)
|
||||
rotation = Math.PI / 2;
|
||||
else
|
||||
rotation = -Math.PI / 2;
|
||||
}
|
||||
else {
|
||||
if (this._lastOrientationEvent.gamma > 0)
|
||||
rotation = Math.PI;
|
||||
}
|
||||
|
||||
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
let ctx = canvas.getContext("2d");
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
//ctx.save();
|
||||
if (rotation != 0) {
|
||||
if (rotation == Math.PI / 2)
|
||||
ctx.translate(width, 0);
|
||||
else if (rotation == -Math.PI / 2)
|
||||
ctx.translate(-width, 0);
|
||||
else
|
||||
ctx.translate(width, height);
|
||||
ctx.rotate(rotation);
|
||||
}
|
||||
ctx.drawImage(document.getElementById("capturepicker-video"), 0, 0, 320, 240);
|
||||
//ctx.restore();
|
||||
let url = canvas.toDataURL("image/png");
|
||||
|
||||
let tmpDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
let file = tmpDir.clone();
|
||||
file.append("capture.png");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);
|
||||
|
||||
persist.persistFlags = Ci.nsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | Ci.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
|
||||
|
||||
let mDone = false;
|
||||
let mFailed = false;
|
||||
|
||||
let progressListener = {
|
||||
onProgressChange: function() {
|
||||
/* Ignore progress callback */
|
||||
},
|
||||
onStateChange: function(aProgress, aRequest, aStateFlag, aStatus) {
|
||||
if (aStateFlag & Ci.nsIWebProgressListener.STATE_STOP) {
|
||||
mDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
persist.progressListener = progressListener;
|
||||
|
||||
let source = Services.io.newURI(url, "UTF8", null);;
|
||||
persist.saveURI(source, null, null, null, null, file);
|
||||
|
||||
// don't wait more than 3 seconds for a successful save
|
||||
window.setTimeout(function() {
|
||||
mDone = true;
|
||||
mFailed = true;
|
||||
}, 3000);
|
||||
|
||||
while (!mDone)
|
||||
Services.tm.currentThread.processNextEvent(true);
|
||||
|
||||
return (mFailed ? null : file.path);
|
||||
}
|
||||
}
|
|
@ -1,26 +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/. */
|
||||
|
||||
/* appears to have something to do with capturing a camera image. tries to
|
||||
* create a dialog, which will fail. TBD. */
|
||||
var CapturePickerUI = {
|
||||
init: function() {
|
||||
this.messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
|
||||
this.messageManager.addMessageListener("CapturePicker:Show", this);
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "CapturePicker:Show":
|
||||
let params = { result: true };
|
||||
let dialog = DialogUI.importModal(null, "chrome://browser/content/prompt/CaptureDialog.xul", params);
|
||||
document.getElementById("capturepicker-title").appendChild(document.createTextNode(aMessage.json.title));
|
||||
dialog.waitForClose();
|
||||
return { value: params.result, path: params.path };
|
||||
break;
|
||||
}
|
||||
// prevents warning from the script loader
|
||||
return null;
|
||||
}
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.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/. -->
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/prompt.dtd">
|
||||
<dialog id="capturepicker-dialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="document.getElementById('capturepicker-dialog').CaptureDialog.init()"
|
||||
script="chrome://browser/content/CaptureDialog.js">
|
||||
|
||||
<keyset>
|
||||
<key keycode="VK_RETURN" command="cmd_ok"/>
|
||||
<key keycode="VK_ESCAPE" command="cmd_cancel"/>
|
||||
</keyset>
|
||||
|
||||
<commandset>
|
||||
<command id="cmd_ok" oncommand="document.getElementById('capturepicker-dialog').CaptureDialog.capture();"/>
|
||||
<command id="cmd_cancel" oncommand="document.getElementById('capturepicker-dialog').CaptureDialog.cancel();"/>
|
||||
</commandset>
|
||||
|
||||
<vbox class="prompt-inner">
|
||||
<vbox class="prompt-header" flex="1">
|
||||
<description id="capturepicker-title" class="prompt-title" crop="center" flex="1"/>
|
||||
<hbox flex="1" pack="center">
|
||||
<vbox id="capturepicker-container" pack="center">
|
||||
<video xmlns="http://www.w3.org/1999/xhtml" id="capturepicker-video"
|
||||
width="320" height="240"
|
||||
src="moz-device:?width=320&height=240&type=video/x-raw-yuv"
|
||||
autoplay="true"> </video>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<hbox id="capturepicker-buttons-box" class="prompt-buttons">
|
||||
<button class="prompt-button" label="&ok.label;" command="cmd_ok"/>
|
||||
<button class="prompt-button" label="&cancel.label;" command="cmd_cancel"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</dialog>
|
|
@ -30,7 +30,6 @@ chrome.jar:
|
|||
content/bindings/flyoutpanel.xml (content/bindings/flyoutpanel.xml)
|
||||
content/bindings/selectionoverlay.xml (content/bindings/selectionoverlay.xml)
|
||||
|
||||
content/prompt/CaptureDialog.xul (content/prompt/CaptureDialog.xul)
|
||||
content/prompt/alert.xul (content/prompt/alert.xul)
|
||||
content/prompt/confirm.xul (content/prompt/confirm.xul)
|
||||
content/prompt/prompt.xul (content/prompt/prompt.xul)
|
||||
|
@ -41,8 +40,6 @@ chrome.jar:
|
|||
content/prompt/removeMasterPassword.xul (content/prompt/removeMasterPassword.xul)
|
||||
|
||||
content/helperui/AlertsHelper.js (content/helperui/AlertsHelper.js)
|
||||
content/helperui/CaptureDialog.js (content/helperui/CaptureDialog.js)
|
||||
content/helperui/CapturePickerUI.js (content/helperui/CapturePickerUI.js)
|
||||
content/helperui/IndexedDB.js (content/helperui/IndexedDB.js)
|
||||
content/helperui/MasterPasswordUI.js (content/helperui/MasterPasswordUI.js)
|
||||
content/helperui/MenuUI.js (content/helperui/MenuUI.js)
|
||||
|
|
|
@ -93,8 +93,3 @@ category app-startup SafeBrowsing service,@mozilla.org/safebrowsing/application;
|
|||
component {88b3eb21-d072-4e3b-886d-f89d8c49fe59} UpdatePrompt.js
|
||||
contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59}
|
||||
#endif
|
||||
|
||||
# CapturePicker.js
|
||||
component {cb5a47f0-b58c-4fc3-b61a-358ee95f8238} CapturePicker.js
|
||||
contract @mozilla.org/capturepicker;1 {cb5a47f0-b58c-4fc3-b61a-358ee95f8238}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче