chore: add OCR scaffolding to PDF Viewer (#38127)
This commit is contained in:
parent
c548f8f59e
commit
d95f9d2c63
10 changed files with 234 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//electron/buildflags/buildflags.gni")
|
||||
import("//extensions/buildflags/buildflags.gni")
|
||||
import("//tools/json_schema_compiler/json_features.gni")
|
||||
import("//tools/json_schema_compiler/json_schema_api.gni")
|
||||
|
@ -41,6 +42,10 @@ generated_json_strings("generated_api_json_strings") {
|
|||
"tabs.json",
|
||||
]
|
||||
|
||||
if (enable_pdf_viewer) {
|
||||
sources += [ "pdf_viewer_private.idl" ]
|
||||
}
|
||||
|
||||
configs = [ "//build/config:precompiled_headers" ]
|
||||
bundle_name = "Electron"
|
||||
schema_include_rules = "extensions/common/api:extensions::api::%(namespace)s"
|
||||
|
@ -56,6 +61,11 @@ generated_types("generated_api_types") {
|
|||
"resources_private.idl",
|
||||
"tabs.json",
|
||||
]
|
||||
|
||||
if (enable_pdf_viewer) {
|
||||
sources += [ "pdf_viewer_private.idl" ]
|
||||
}
|
||||
|
||||
configs = [ "//build/config:precompiled_headers" ]
|
||||
schema_include_rules = "extensions/common/api:extensions::api::%(namespace)s"
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
"channel": "stable",
|
||||
"matches": ["<all_urls>"]
|
||||
},
|
||||
"pdfViewerPrivate": {
|
||||
"dependencies": ["permission:pdfViewerPrivate"],
|
||||
"contexts": ["blessed_extension"]
|
||||
},
|
||||
"resourcesPrivate": [{
|
||||
"dependencies": ["permission:resourcesPrivate"],
|
||||
"contexts": ["blessed_extension"]
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
],
|
||||
"location": "component"
|
||||
},
|
||||
"pdfViewerPrivate": {
|
||||
"channel": "stable",
|
||||
"extension_types": [
|
||||
"extension"
|
||||
],
|
||||
"allowlist": [
|
||||
"CBCC42ABED43A4B58FE3810E62AFFA010EB0349F"
|
||||
]
|
||||
},
|
||||
"management": {
|
||||
"channel": "stable",
|
||||
"extension_types": [
|
||||
|
|
39
shell/common/extensions/api/pdf_viewer_private.idl
Normal file
39
shell/common/extensions/api/pdf_viewer_private.idl
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2022 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Use the <code>chrome.pdfViewerPrivate</code> API for specific browser
|
||||
// functionality that the PDF Viewer needs from outside the PDF plugin. This API
|
||||
// is exclusively for the PDF Viewer.
|
||||
namespace pdfViewerPrivate {
|
||||
callback IsAllowedLocalFileAccessCallback = void(boolean result);
|
||||
callback IsPdfOcrAlwaysActiveCallback = void(boolean result);
|
||||
callback OnPdfOcrPrefSetCallback = void(boolean result);
|
||||
|
||||
interface Functions {
|
||||
// Determines if the given URL should be allowed to access local files from
|
||||
// the PDF Viewer. |callback|: Called with true if URL should be allowed to
|
||||
// access local files from the PDF Viewer, false otherwise.
|
||||
[supportsPromises] static void isAllowedLocalFileAccess(
|
||||
DOMString url,
|
||||
IsAllowedLocalFileAccessCallback callback);
|
||||
|
||||
// Determines if the preference for PDF OCR is set to run PDF OCR always.
|
||||
// |callback|: Called with true if PDF OCR is set to be always active;
|
||||
// false otherwise.
|
||||
[supportsPromises] static void isPdfOcrAlwaysActive(
|
||||
IsPdfOcrAlwaysActiveCallback callback);
|
||||
|
||||
// Sets a pref value for PDF OCR.
|
||||
// |value|: The new value of the pref.
|
||||
// |callback|: The callback for whether the pref was set or not.
|
||||
[supportsPromises] static void setPdfOcrPref(
|
||||
boolean value, OnPdfOcrPrefSetCallback callback);
|
||||
};
|
||||
|
||||
interface Events {
|
||||
// Fired when a pref value for PDF OCR has changed.
|
||||
// |value| The pref value that changed.
|
||||
static void onPdfOcrPrefChanged(boolean value);
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue