Commit 6a3bbaed authored by Douglas Stockwell's avatar Douglas Stockwell Committed by Commit Bot

pdf: Add annotation UI entry-point and guard behind feature

R=dsinclair@chromium.org, hnakashima@chromium.org

Bug: 902646
Change-Id: I896f190feeacededc97355d575b8dc3c26b03879
Reviewed-on: https://chromium-review.googlesource.com/c/1329808Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatardsinclair <dsinclair@chromium.org>
Commit-Queue: dstockwell <dstockwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611637}
parent 37a14ff2
......@@ -64,6 +64,9 @@ void AddAdditionalDataForPdf(base::DictionaryValue* dict) {
dict->SetKey("pdfFormSaveEnabled",
base::Value(base::FeatureList::IsEnabled(
chrome_pdf::features::kSaveEditedPDFForm)));
dict->SetKey("pdfAnnotationsEnabled",
base::Value(base::FeatureList::IsEnabled(
chrome_pdf::features::kPDFAnnotations)));
#endif
}
......
......@@ -73,6 +73,7 @@
#include "extensions/test/result_catcher.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "pdf/pdf_features.h"
#include "services/network/public/cpp/features.h"
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_node.h"
......@@ -385,6 +386,19 @@ class PDFExtensionHitTestTest : public PDFExtensionTest,
base::test::ScopedFeatureList feature_list_;
};
class PDFAnnotationsTest : public PDFExtensionTest {
public:
PDFAnnotationsTest() {}
protected:
void SetUpCommandLine(base::CommandLine* command_line) override {
PDFExtensionTest::SetUpCommandLine(command_line);
feature_list_.InitAndEnableFeature(chrome_pdf::features::kPDFAnnotations);
}
base::test::ScopedFeatureList feature_list_;
};
// Disabled because it's flaky.
// See the issue for details: https://crbug.com/826055.
#if defined(MEMORY_SANITIZER) || defined(LEAK_SANITIZER) || \
......@@ -624,6 +638,13 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Beep) {
RunTestsInFile("beep_test.js", "test-beep.pdf");
}
IN_PROC_BROWSER_TEST_F(PDFAnnotationsTest, AnnotationsFeatureEnabled) {
RunTestsInFile("annotations_feature_enabled_test.js", "test.pdf");
}
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, AnnotationsFeatureDisabled) {
RunTestsInFile("annotations_feature_disabled_test.js", "test.pdf");
}
// TODO(tsepez): See https://crbug.com/696650.
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_NoBeep) {
// Block the exact query from pdf/main.js while still allowing enough
......
......@@ -11,6 +11,7 @@
<g id="add"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path></g>
<g id="bookmark"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g>
<g id="bookmark-border"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g>
<g id="create"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></g>
<g id="fullscreen-exit"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"></path></g>
<g id="remove"><path d="M19 13H5v-2h14v2z"></path></g>
<g id="rotate-right"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"></path></g>
......
......@@ -123,6 +123,13 @@
</div>
<div id="buttons" class="invisible">
<template is="dom-if" if="[[pdfAnnotationsEnabled]]">
<paper-icon-button id="annotate" icon="pdf:create"
aria-label$="{{strings.tooltipAnnotate}}"
title$="{{strings.tooltipAnnotate}}">
</paper-icon-button>
</template>
<paper-icon-button id="rotate-right" icon="pdf:rotate-right"
on-click="rotateRight"
aria-label$="{{strings.tooltipRotateCW}}"
......
......@@ -36,6 +36,11 @@ Polymer({
*/
opened: {type: Boolean, value: true},
/**
* Whether the PDF Annotations feature is enabled.
*/
pdfAnnotationsEnabled: Boolean,
strings: Object,
},
......
......@@ -654,6 +654,8 @@ PDFViewer.prototype = {
loadTimeData.data = strings;
$('toolbar').strings = strings;
$('toolbar').pdfAnnotationsEnabled =
loadTimeData.getBoolean('pdfAnnotationsEnabled');
$('zoom-toolbar').strings = strings;
$('password-screen').strings = strings;
$('error-screen').strings = strings;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.runTests([
function testAnnotationsDisabled() {
const toolbar = document.body.querySelector('#toolbar');
chrome.test.assertFalse(toolbar.pdfAnnotationsEnabled);
chrome.test.assertEq(null, toolbar.shadowRoot.querySelector('#annotate'));
chrome.test.succeed();
},
]);
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.runTests([
function testAnnotationsEnabled() {
const toolbar = document.body.querySelector('#toolbar');
chrome.test.assertTrue(toolbar.pdfAnnotationsEnabled);
chrome.test.assertTrue(
toolbar.shadowRoot.querySelector('#annotate') != null);
chrome.test.succeed();
},
]);
......@@ -10,5 +10,8 @@ namespace features {
const base::Feature kSaveEditedPDFForm{"SaveEditedPDFForm",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kPDFAnnotations{"PDFAnnotations",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
} // namespace chrome_pdf
......@@ -14,6 +14,7 @@ namespace chrome_pdf {
namespace features {
extern const base::Feature kSaveEditedPDFForm;
extern const base::Feature kPDFAnnotations;
} // namespace features
} // namespace chrome_pdf
......
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