Implement loading cid: scheme resources in ClientWebView.
* src/client/application/geary-controller.vala (GearyController::open_async): Register a handler for the 'cid' scheme. * src/client/components/client-web-view.vala (ClientWebView::handle_cid_request): Hook up requests for cid URIs using attachment files.
This commit is contained in:
parent
d2fac49e18
commit
0dbf925a86
2 changed files with 24 additions and 0 deletions
|
|
@ -192,6 +192,12 @@ public class GearyController : Geary.BaseObject {
|
|||
WebKit.WebContext context = WebKit.WebContext.get_default();
|
||||
context.set_process_model(WebKit.ProcessModel.SHARED_SECONDARY_PROCESS);
|
||||
context.set_cache_model(WebKit.CacheModel.DOCUMENT_BROWSER);
|
||||
context.register_uri_scheme("cid", (req) => {
|
||||
ClientWebView? view = req.get_web_view() as ClientWebView;
|
||||
if (view != null) {
|
||||
view.handle_cid_request(req);
|
||||
}
|
||||
});
|
||||
context.initialize_web_extensions.connect((context) => {
|
||||
context.set_web_extensions_directory(
|
||||
this.application.get_web_extensions_dir().get_path()
|
||||
|
|
|
|||
|
|
@ -130,6 +130,24 @@ public class ClientWebView : WebKit.WebView {
|
|||
this.zoom_level -= (this.zoom_level * ZOOM_FACTOR);
|
||||
}
|
||||
|
||||
internal void handle_cid_request(WebKit.URISchemeRequest request) {
|
||||
const string CID_PREFIX = "cid:";
|
||||
|
||||
string cid = request.get_uri().substring(CID_PREFIX.length);
|
||||
File? file = this.cid_resources[cid];
|
||||
if (file != null) {
|
||||
try {
|
||||
request.finish(file.read(), -1, null);
|
||||
} catch (Error err) {
|
||||
request.finish_error(err);
|
||||
}
|
||||
} else {
|
||||
request.finish_error(
|
||||
new FileError.NOENT("Unknown CID: %s".printf(cid))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Only allow string-based page loads, and notify but ignore if
|
||||
// the user attempts to click on a link. Deny everything else.
|
||||
private bool on_decide_policy(WebKit.WebView view,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue