Commit 048aed00 authored by dstockwell's avatar dstockwell Committed by Commit Bot

pdf: Disable annotation if password protected or large

Bug: 902646
Change-Id: If6f594535a1d1cdff19e441d0995d1ef57e22885
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504670
Commit-Queue: dstockwell <dstockwell@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638070}
parent 995aa163
...@@ -136,6 +136,12 @@ function PDFViewer(browserApi) { ...@@ -136,6 +136,12 @@ function PDFViewer(browserApi) {
/** @private {boolean} */ /** @private {boolean} */
this.hasEnteredAnnotationMode_ = false; this.hasEnteredAnnotationMode_ = false;
/** @private {boolean} */
this.hadPassword_ = false;
/** @private {boolean} */
this.canSerializeDocument_ = false;
PDFMetrics.record(PDFMetrics.UserAction.DOCUMENT_OPENED); PDFMetrics.record(PDFMetrics.UserAction.DOCUMENT_OPENED);
// Parse open pdf parameters. // Parse open pdf parameters.
...@@ -1074,6 +1080,8 @@ PDFViewer.prototype = { ...@@ -1074,6 +1080,8 @@ PDFViewer.prototype = {
// If the password screen isn't up, put it up. Otherwise we're // If the password screen isn't up, put it up. Otherwise we're
// responding to an incorrect password so deny it. // responding to an incorrect password so deny it.
if (!this.passwordScreen_.active) { if (!this.passwordScreen_.active) {
this.hadPassword_ = true;
this.updateAnnotationAvailable_();
this.passwordScreen_.show(); this.passwordScreen_.show();
} else { } else {
this.passwordScreen_.deny(); this.passwordScreen_.deny();
...@@ -1119,8 +1127,9 @@ PDFViewer.prototype = { ...@@ -1119,8 +1127,9 @@ PDFViewer.prototype = {
* Sets document metadata from the current controller. * Sets document metadata from the current controller.
* @param {string} title * @param {string} title
* @param {Array} bookmarks * @param {Array} bookmarks
* @param {boolean} canSerializeDocument
*/ */
setDocumentMetadata: function(title, bookmarks) { setDocumentMetadata: function(title, bookmarks, canSerializeDocument) {
if (title) { if (title) {
document.title = title; document.title = title;
} else { } else {
...@@ -1131,6 +1140,8 @@ PDFViewer.prototype = { ...@@ -1131,6 +1140,8 @@ PDFViewer.prototype = {
this.toolbar_.docTitle = document.title; this.toolbar_.docTitle = document.title;
this.toolbar_.bookmarks = this.bookmarks; this.toolbar_.bookmarks = this.bookmarks;
} }
this.canSerializeDocument_ = canSerializeDocument;
this.updateAnnotationAvailable_();
}, },
/** /**
...@@ -1227,6 +1238,12 @@ PDFViewer.prototype = { ...@@ -1227,6 +1238,12 @@ PDFViewer.prototype = {
if (this.viewport_.getClockwiseRotations() != 0) { if (this.viewport_.getClockwiseRotations() != 0) {
annotationAvailable = false; annotationAvailable = false;
} }
if (this.hadPassword_) {
annotationAvailable = false;
}
if (!this.canSerializeDocument_) {
annotationAvailable = false;
}
this.toolbar_.annotationAvailable = annotationAvailable; this.toolbar_.annotationAvailable = annotationAvailable;
}, },
...@@ -1563,7 +1580,8 @@ class PluginController extends ContentController { ...@@ -1563,7 +1580,8 @@ class PluginController extends ContentController {
break; break;
case 'metadata': case 'metadata':
this.viewer_.setDocumentMetadata( this.viewer_.setDocumentMetadata(
message.data.title, message.data.bookmarks); message.data.title, message.data.bookmarks,
message.data.canSerializeDocument);
break; break;
case 'setIsSelecting': case 'setIsSelecting':
this.viewer_.setIsSelecting(message.data.isSelecting); this.viewer_.setIsSelecting(message.data.isSelecting);
......
...@@ -91,6 +91,7 @@ constexpr char kJSPreviewLoadedType[] = "printPreviewLoaded"; ...@@ -91,6 +91,7 @@ constexpr char kJSPreviewLoadedType[] = "printPreviewLoaded";
constexpr char kJSMetadataType[] = "metadata"; constexpr char kJSMetadataType[] = "metadata";
constexpr char kJSBookmarks[] = "bookmarks"; constexpr char kJSBookmarks[] = "bookmarks";
constexpr char kJSTitle[] = "title"; constexpr char kJSTitle[] = "title";
constexpr char kJSCanSerializeDocument[] = "canSerializeDocument";
// Get password (Plugin -> Page) // Get password (Plugin -> Page)
constexpr char kJSGetPasswordType[] = "getPassword"; constexpr char kJSGetPasswordType[] = "getPassword";
// Get password complete arguments (Page -> Plugin) // Get password complete arguments (Page -> Plugin)
...@@ -1654,6 +1655,9 @@ void OutOfProcessInstance::DocumentLoadComplete( ...@@ -1654,6 +1655,9 @@ void OutOfProcessInstance::DocumentLoadComplete(
metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); metadata_message.Set(pp::Var(kJSTitle), pp::Var(title));
HistogramEnumeration("PDF.DocumentFeature", HAS_TITLE, FEATURES_COUNT); HistogramEnumeration("PDF.DocumentFeature", HAS_TITLE, FEATURES_COUNT);
} }
metadata_message.Set(
pp::Var(kJSCanSerializeDocument),
pp::Var(engine_->GetLoadedByteSize() <= kMaximumSavedFileSize));
pp::VarArray bookmarks = engine_->GetBookmarks(); pp::VarArray bookmarks = engine_->GetBookmarks();
metadata_message.Set(pp::Var(kJSBookmarks), bookmarks); metadata_message.Set(pp::Var(kJSBookmarks), bookmarks);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment