fix: add missed enum SaveRequestType
to PdfViewerPrivate function (#48409)
fix: add missed SaveRequestType enum to PdfViewerPrivate function Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
This commit is contained in:
parent
074d0e19fb
commit
6dc3923b93
4 changed files with 58 additions and 0 deletions
|
@ -72,3 +72,6 @@ enterprise_cloud_content_analysis = false
|
||||||
|
|
||||||
# We don't use anything from here, and it causes target collisions
|
# We don't use anything from here, and it causes target collisions
|
||||||
enable_linux_installer = false
|
enable_linux_installer = false
|
||||||
|
|
||||||
|
# Disable "Save to Drive" feature in PDF viewer
|
||||||
|
enable_pdf_save_to_drive = false
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "components/pdf/common/constants.h"
|
#include "components/pdf/common/constants.h"
|
||||||
#include "components/prefs/pref_service.h"
|
#include "components/prefs/pref_service.h"
|
||||||
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
||||||
|
#include "pdf/buildflags.h"
|
||||||
#include "url/url_constants.h"
|
#include "url/url_constants.h"
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
@ -25,6 +26,8 @@ namespace {
|
||||||
namespace IsAllowedLocalFileAccess =
|
namespace IsAllowedLocalFileAccess =
|
||||||
api::pdf_viewer_private::IsAllowedLocalFileAccess;
|
api::pdf_viewer_private::IsAllowedLocalFileAccess;
|
||||||
|
|
||||||
|
namespace SaveToDrive = api::pdf_viewer_private::SaveToDrive;
|
||||||
|
|
||||||
namespace SetPdfPluginAttributes =
|
namespace SetPdfPluginAttributes =
|
||||||
api::pdf_viewer_private::SetPdfPluginAttributes;
|
api::pdf_viewer_private::SetPdfPluginAttributes;
|
||||||
|
|
||||||
|
@ -107,6 +110,24 @@ PdfViewerPrivateIsAllowedLocalFileAccessFunction::Run() {
|
||||||
IsUrlAllowedToEmbedLocalFiles(GURL(params->url), base::Value::List())));
|
IsUrlAllowedToEmbedLocalFiles(GURL(params->url), base::Value::List())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PdfViewerPrivateSaveToDriveFunction::PdfViewerPrivateSaveToDriveFunction() =
|
||||||
|
default;
|
||||||
|
|
||||||
|
PdfViewerPrivateSaveToDriveFunction::~PdfViewerPrivateSaveToDriveFunction() =
|
||||||
|
default;
|
||||||
|
|
||||||
|
ExtensionFunction::ResponseAction PdfViewerPrivateSaveToDriveFunction::Run() {
|
||||||
|
#if BUILDFLAG(ENABLE_PDF_SAVE_TO_DRIVE)
|
||||||
|
std::optional<SaveToDrive::Params> params =
|
||||||
|
SaveToDrive::Params::Create(args());
|
||||||
|
EXTENSION_FUNCTION_VALIDATE(params);
|
||||||
|
// TODO(crbug.com/424208776): Start the save to drive flow.
|
||||||
|
return RespondNow(NoArguments());
|
||||||
|
#else
|
||||||
|
return RespondNow(Error("Not supported"));
|
||||||
|
#endif // BUILDFLAG(ENABLE_PDF_SAVE_TO_DRIVE)
|
||||||
|
}
|
||||||
|
|
||||||
PdfViewerPrivateSetPdfDocumentTitleFunction::
|
PdfViewerPrivateSetPdfDocumentTitleFunction::
|
||||||
PdfViewerPrivateSetPdfDocumentTitleFunction() = default;
|
PdfViewerPrivateSetPdfDocumentTitleFunction() = default;
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,24 @@ class PdfViewerPrivateIsAllowedLocalFileAccessFunction
|
||||||
ResponseAction Run() override;
|
ResponseAction Run() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PdfViewerPrivateSaveToDriveFunction : public ExtensionFunction {
|
||||||
|
public:
|
||||||
|
DECLARE_EXTENSION_FUNCTION("pdfViewerPrivate.saveToDrive",
|
||||||
|
PDFVIEWERPRIVATE_SAVETODRIVE)
|
||||||
|
|
||||||
|
PdfViewerPrivateSaveToDriveFunction();
|
||||||
|
PdfViewerPrivateSaveToDriveFunction(
|
||||||
|
const PdfViewerPrivateSaveToDriveFunction&) = delete;
|
||||||
|
PdfViewerPrivateSaveToDriveFunction& operator=(
|
||||||
|
const PdfViewerPrivateSaveToDriveFunction&) = delete;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~PdfViewerPrivateSaveToDriveFunction() override;
|
||||||
|
|
||||||
|
// Override from ExtensionFunction:
|
||||||
|
ResponseAction Run() override;
|
||||||
|
};
|
||||||
|
|
||||||
class PdfViewerPrivateSetPdfDocumentTitleFunction : public ExtensionFunction {
|
class PdfViewerPrivateSetPdfDocumentTitleFunction : public ExtensionFunction {
|
||||||
public:
|
public:
|
||||||
DECLARE_EXTENSION_FUNCTION("pdfViewerPrivate.setPdfDocumentTitle",
|
DECLARE_EXTENSION_FUNCTION("pdfViewerPrivate.setPdfDocumentTitle",
|
||||||
|
|
|
@ -6,6 +6,15 @@
|
||||||
// functionality that the PDF Viewer needs from outside the PDF plugin. This API
|
// functionality that the PDF Viewer needs from outside the PDF plugin. This API
|
||||||
// is exclusively for the PDF Viewer.
|
// is exclusively for the PDF Viewer.
|
||||||
namespace pdfViewerPrivate {
|
namespace pdfViewerPrivate {
|
||||||
|
// Must match `SaveRequestType` in `pdf/mojom/pdf.mojom` and
|
||||||
|
// `tools/typescript/definitions/pdf_viewer_private.d.ts`.
|
||||||
|
enum SaveRequestType {
|
||||||
|
ANNOTATION,
|
||||||
|
ORIGINAL,
|
||||||
|
EDITED,
|
||||||
|
SEARCHIFIED
|
||||||
|
};
|
||||||
|
|
||||||
// Nearly identical to mimeHandlerPrivate.StreamInfo, but without a mime type
|
// Nearly identical to mimeHandlerPrivate.StreamInfo, but without a mime type
|
||||||
// nor a response header field. Those fields are unused by the PDF viewer.
|
// nor a response header field. Those fields are unused by the PDF viewer.
|
||||||
dictionary StreamInfo {
|
dictionary StreamInfo {
|
||||||
|
@ -52,6 +61,13 @@ namespace pdfViewerPrivate {
|
||||||
DOMString url,
|
DOMString url,
|
||||||
IsAllowedLocalFileAccessCallback callback);
|
IsAllowedLocalFileAccessCallback callback);
|
||||||
|
|
||||||
|
// Sends a request to save the PDF to Google Drive if `saveRequestType` is
|
||||||
|
// set. Otherwise, if `saveRequestType` is not set, the default action is
|
||||||
|
// to cancel the existing upload.
|
||||||
|
static void saveToDrive(
|
||||||
|
optional SaveRequestType saveRequestType,
|
||||||
|
optional VoidCallback callback);
|
||||||
|
|
||||||
// Sets the current tab title to `title` for a full-page PDF.
|
// Sets the current tab title to `title` for a full-page PDF.
|
||||||
static void setPdfDocumentTitle(
|
static void setPdfDocumentTitle(
|
||||||
DOMString title,
|
DOMString title,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue