You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
<?php |
|
declare(strict_types=1); |
|
/** |
|
* @author Lukas Reschke |
|
* @copyright 2014 Lukas Reschke lukas@owncloud.com |
|
* |
|
* This file is licensed under the Affero General Public License version 3 or |
|
* later. |
|
* See the COPYING-README file. |
|
*/ |
|
|
|
namespace OCA\Files_PdfViewer\Controller; |
|
|
|
use OCP\AppFramework\Controller; |
|
use OCP\AppFramework\Http\ContentSecurityPolicy; |
|
use OCP\AppFramework\Http\TemplateResponse; |
|
use OCP\IRequest; |
|
use OCP\IURLGenerator; |
|
|
|
class DisplayController extends Controller { |
|
|
|
/** @var IURLGenerator */ |
|
private $urlGenerator; |
|
|
|
/** |
|
* @param string $AppName |
|
* @param IRequest $request |
|
* @param IURLGenerator $urlGenerator |
|
*/ |
|
public function __construct(string $AppName, |
|
IRequest $request, |
|
IURLGenerator $urlGenerator) { |
|
parent::__construct($AppName, $request); |
|
$this->urlGenerator = $urlGenerator; |
|
} |
|
|
|
/** |
|
* @PublicPage |
|
* @NoCSRFRequired |
|
* |
|
* @param bool $minmode |
|
* @return TemplateResponse |
|
*/ |
|
public function showPdfViewer(bool $minmode = false): TemplateResponse { |
|
$params = [ |
|
'urlGenerator' => $this->urlGenerator, |
|
'minmode' => $minmode |
|
]; |
|
$response = new TemplateResponse($this->appName, 'viewer', $params, 'blank'); |
|
|
|
$policy = new ContentSecurityPolicy(); |
|
$policy->addAllowedChildSrcDomain('\'self\''); |
|
$policy->addAllowedFontDomain('data:'); |
|
$policy->addAllowedImageDomain('*'); |
|
$policy->allowEvalScript(false); |
|
$response->setContentSecurityPolicy($policy); |
|
|
|
return $response; |
|
} |
|
|
|
}
|
|
|