0

PDF Viewer: Put presentation mode behind a flag and disable by default.

Presentation mode needs more work, as it's not supposed to be simply a
full screen version of the main content area of the PDF Viewer. Putting
it behind PdfViewerPresentationMode flag to facilitate further work on
that feature.

Fixed: 1147518
Change-Id: I7e81b7f3f26497c19ac490a82c90c2be2b647fe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531896
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826344}
This commit is contained in:
dpapad
2020-11-11 18:13:32 +00:00
committed by Commit Bot
parent d68b9ba4fd
commit ac665d183d
10 changed files with 67 additions and 16 deletions

@ -378,22 +378,33 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
// Hooks to set up feature flags. Defaults to setting the kPDFViewerUpdate
// flag based on the value returned by ShouldEnablePDFViewerUpdate().
virtual const std::vector<base::Feature> GetEnabledFeatures() const {
std::vector<base::Feature> enabled;
if (ShouldEnablePDFViewerUpdate()) {
return {chrome_pdf::features::kPDFViewerUpdate};
enabled.push_back(chrome_pdf::features::kPDFViewerUpdate);
}
return {};
if (ShouldEnablePdfViewerPresentationMode()) {
enabled.push_back(chrome_pdf::features::kPdfViewerPresentationMode);
}
return enabled;
}
virtual const std::vector<base::Feature> GetDisabledFeatures() const {
if (ShouldEnablePDFViewerUpdate()) {
return {};
std::vector<base::Feature> disabled;
if (!ShouldEnablePDFViewerUpdate()) {
disabled.push_back(chrome_pdf::features::kPDFViewerUpdate);
}
return {chrome_pdf::features::kPDFViewerUpdate};
if (!ShouldEnablePdfViewerPresentationMode()) {
disabled.push_back(chrome_pdf::features::kPdfViewerPresentationMode);
}
return disabled;
}
// Hook to set up whether the PDFViewerUpdate feature is enabled.
virtual bool ShouldEnablePDFViewerUpdate() const { return false; }
// Hook to set up whether the PdfViewerPresentationMode feature is enabled.
virtual bool ShouldEnablePdfViewerPresentationMode() const { return false; }
private:
WebContents* LoadPdfGetGuestContentsHelper(const GURL& url, bool new_tab) {
if (new_tab) {
@ -912,7 +923,16 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionJSUpdatesEnabledTest, ViewerThumbnail) {
RunTestsInJsModule("viewer_thumbnail_test.js", "test.pdf");
}
IN_PROC_BROWSER_TEST_F(PDFExtensionJSUpdatesEnabledTest, Fullscreen) {
class PDFExtensionPresentationModeEnabledTest : public PDFExtensionJSTestBase {
public:
~PDFExtensionPresentationModeEnabledTest() override = default;
protected:
bool ShouldEnablePDFViewerUpdate() const override { return true; }
bool ShouldEnablePdfViewerPresentationMode() const override { return true; }
};
IN_PROC_BROWSER_TEST_F(PDFExtensionPresentationModeEnabledTest, Fullscreen) {
// Although this test file does not require a PDF to be loaded, loading the
// elements without loading a PDF is difficult.
RunTestsInJsModule("fullscreen_test.js", "test.pdf");

@ -179,6 +179,9 @@ void AddAdditionalData(base::Value* dict) {
base::FeatureList::IsEnabled(chrome_pdf::features::kPDFViewerUpdate)
? "pdf-viewer-update-enabled"
: "");
dict->SetKey("presentationModeEnabled",
base::Value(base::FeatureList::IsEnabled(
chrome_pdf::features::kPdfViewerPresentationMode)));
bool enable_printing = true;
bool enable_annotations = false;

@ -146,6 +146,7 @@ js_library("viewer-pdf-toolbar-new") {
":viewer-download-controls",
"..:metrics",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
]
}

@ -272,12 +272,14 @@
$i18n{annotationsShowToggle}
</button>
<hr>
<button id="fullscreen-button" class="dropdown-item"
on-click="onFullscreenClick_">
<span class="check-container" aria-hidden="true"></span>
$i18n{fullscreen}
</button>
<template is="dom-if" if="[[presentationModeEnabled]]">
<hr>
<button id="fullscreen-button" class="dropdown-item"
on-click="onFullscreenClick_">
<span class="check-container" aria-hidden="true"></span>
$i18n{fullscreen}
</button>
</template>
</cr-action-menu>
<if expr="chromeos">

@ -17,6 +17,7 @@ import './shared-css.js';
import './shared-vars.js';
import {AnchorAlignment} from 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {FittingType} from '../constants.js';
@ -70,6 +71,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
pageNo: Number,
pdfAnnotationsEnabled: Boolean,
pdfFormSaveEnabled: Boolean,
presentationModeEnabled: Boolean,
printingEnabled: Boolean,
rotated: Boolean,
viewportZoom: Number,
@ -225,6 +227,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private */
onFullscreenClick_() {
assert(this.presentationModeEnabled);
this.getMenu_().close();
this.dispatchEvent(new CustomEvent('fullscreen-click'));
}

@ -156,6 +156,7 @@
load-progress="[[loadProgress_]]" has-edits="[[hasEdits_]]"
has-entered-annotation-mode="[[hasEnteredAnnotationMode_]]"
pdf-form-save-enabled="[[pdfFormSaveEnabled_]]"
presentation-mode-enabled="[[presentationModeEnabled_]]"
printing-enabled="[[printingEnabled_]]"
rotated="[[isRotated_(clockwiseRotations_)]]"
is-form-field-focused="[[isFormFieldFocused_]]"

@ -224,6 +224,12 @@ export class PDFViewerElement extends PDFViewerBaseElement {
value: false,
},
/** @private */
presentationModeEnabled_: {
type: Boolean,
value: false,
},
/** @private */
pdfViewerUpdateEnabled_: Boolean,
@ -681,6 +687,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
/** @private */
onFullscreenClick_() {
assert(this.presentationModeEnabled_);
this.shadowRoot.querySelector('#main').requestFullscreen();
}
@ -777,6 +784,8 @@ export class PDFViewerElement extends PDFViewerBaseElement {
this.pdfAnnotationsEnabled_ =
loadTimeData.getBoolean('pdfAnnotationsEnabled');
this.pdfFormSaveEnabled_ = loadTimeData.getBoolean('pdfFormSaveEnabled');
this.presentationModeEnabled_ =
loadTimeData.getBoolean('presentationModeEnabled');
this.printingEnabled_ = loadTimeData.getBoolean('printingEnabled');
const presetZoomFactors = this.viewport.presetZoomFactors;
this.zoomBounds_.min = Math.round(presetZoomFactors[0] * 100);

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {eventToPromise} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/_test_resources/webui/test_util.m.js';
import {eventToPromise, flushTasks} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/_test_resources/webui/test_util.m.js';
import {FittingType} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/constants.js';
import {ViewerPdfToolbarNewElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/elements/viewer-pdf-toolbar-new.js';
@ -298,12 +298,20 @@ const tests = [
toggleButton.click();
},
function testEnterFullscreenButton() {
async function testEnterFullscreenButton() {
const toolbar = createToolbar();
const button = toolbar.shadowRoot.querySelector('#fullscreen-button');
let button = toolbar.shadowRoot.querySelector('#fullscreen-button');
chrome.test.assertEq(null, button);
toolbar.presentationModeEnabled = true;
await flushTasks();
button = toolbar.shadowRoot.querySelector('#fullscreen-button');
chrome.test.assertTrue(button !== null);
const whenFired = eventToPromise('fullscreen-click', toolbar);
button.click();
whenFired.then(() => chrome.test.succeed());
await whenFired;
chrome.test.succeed();
},
];

@ -28,6 +28,9 @@ const base::Feature kPdfPartialLoading = {"PdfPartialLoading",
const base::Feature kPDFViewerUpdate = {"PDFViewerUpdate",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kPdfViewerPresentationMode = {
"PdfViewerPresentationMode", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSaveEditedPDFForm = {"SaveEditedPDFForm",
#if BUILDFLAG(IS_ASH)
base::FEATURE_ENABLED_BY_DEFAULT

@ -17,6 +17,7 @@ extern const base::Feature kAccessiblePDFForm;
extern const base::Feature kPdfHonorJsContentSettings;
extern const base::Feature kPdfIncrementalLoading;
extern const base::Feature kPdfPartialLoading;
extern const base::Feature kPdfViewerPresentationMode;
extern const base::Feature kPDFViewerUpdate;
extern const base::Feature kSaveEditedPDFForm;
extern const base::Feature kTabAcrossPDFAnnotations;