mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 776792 - Fire an Activity for application/pdf document. r=gal
This commit is contained in:
parent
5af02ff319
commit
8b28c97d89
@ -601,3 +601,15 @@ window.addEventListener('ContentStart', function ss_onContentStart() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Services.obs.addObserver(function ContentHandler(subject, topic, data) {
|
||||
let handler = JSON.parse(data);
|
||||
new MozActivity({
|
||||
name: 'view',
|
||||
data: {
|
||||
type: handler.type,
|
||||
url: handler.url
|
||||
}
|
||||
});
|
||||
}, 'content-handler', false);
|
||||
|
||||
|
@ -38,3 +38,8 @@ contract @mozilla.org/dom/activities/ui-glue;1 {70a83123-7467-4389-a309-3e81c74a
|
||||
component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js
|
||||
contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28}
|
||||
category app-startup ProcessGlobal service,@mozilla.org/b2g-process-global;1
|
||||
|
||||
# ContentHandler.js
|
||||
component {d18d0216-d50c-11e1-ba54-efb18d0ef0ac} ContentHandler.js
|
||||
contract @mozilla.org/uriloader/content-handler;1?type=application/pdf {d18d0216-d50c-11e1-ba54-efb18d0ef0ac}
|
||||
|
||||
|
48
b2g/components/ContentHandler.js
Normal file
48
b2g/components/ContentHandler.js
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
|
||||
const PDF_CONTENT_TYPE = "application/pdf";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function log(aMsg) {
|
||||
let msg = "ContentHandler.js: " + (aMsg.join ? aMsg.join("") : aMsg);
|
||||
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
|
||||
.logStringMessage(msg);
|
||||
dump(msg + "\n");
|
||||
}
|
||||
|
||||
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
||||
function ContentHandler() {
|
||||
}
|
||||
|
||||
ContentHandler.prototype = {
|
||||
handleContent: function handleContent(aMimetype, aContext, aRequest) {
|
||||
if (aMimetype != PDF_CONTENT_TYPE)
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
|
||||
if (!(aRequest instanceof Ci.nsIChannel))
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
|
||||
let detail = {
|
||||
"type": aMimetype,
|
||||
"url": aRequest.URI.spec
|
||||
};
|
||||
Services.obs.notifyObservers(this, "content-handler", JSON.stringify(detail));
|
||||
|
||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
classID: Components.ID("{d18d0216-d50c-11e1-ba54-efb18d0ef0ac}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler])
|
||||
};
|
||||
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentHandler]);
|
@ -17,14 +17,15 @@ XPIDLSRCS = \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
ActivitiesGlue.js \
|
||||
AlertsService.js \
|
||||
B2GComponents.manifest \
|
||||
CameraContent.js \
|
||||
ContentHandler.js \
|
||||
ContentPermissionPrompt.js \
|
||||
DirectoryProvider.js \
|
||||
MozKeyboard.js \
|
||||
ProcessGlobal.js \
|
||||
ActivitiesGlue.js \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_UPDATER
|
||||
|
@ -684,3 +684,4 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
|
||||
@BINPATH@/components/DirectoryProvider.js
|
||||
@BINPATH@/components/ActivitiesGlue.js
|
||||
@BINPATH@/components/ProcessGlobal.js
|
||||
@BINPATH@/components/ContentHandler.js
|
||||
|
Loading…
Reference in New Issue
Block a user