Commit 2073c584 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Disable printing for Chrome OS OOBE

This change hides the "print" icon while in OOBE on Chrome OS.

Bug: 977890
Test: Unitests, tested in VM
Change-Id: I3d78f0ed77a6afe8c340f07c19d85ee545ae63b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1669993
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678348}
parent a6f40e25
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
#if BUILDFLAG(ENABLE_PDF) #if BUILDFLAG(ENABLE_PDF)
#include "pdf/pdf_features.h" #include "pdf/pdf_features.h"
#endif #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(ENABLE_PDF)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
...@@ -125,7 +128,14 @@ void AddAdditionalDataForPdf(base::DictionaryValue* dict) { ...@@ -125,7 +128,14 @@ void AddAdditionalDataForPdf(base::DictionaryValue* dict) {
dict->SetKey("pdfAnnotationsEnabled", dict->SetKey("pdfAnnotationsEnabled",
base::Value(base::FeatureList::IsEnabled( base::Value(base::FeatureList::IsEnabled(
chrome_pdf::features::kPDFAnnotations))); chrome_pdf::features::kPDFAnnotations)));
#endif
bool enable_printing = true;
#if defined(OS_CHROMEOS)
// For Chrome OS, enable printing only if we are not at OOBE.
enable_printing = !chromeos::LoginDisplayHost::default_host();
#endif // defined(OS_CHROMEOS)
dict->SetKey("printingEnabled", base::Value(enable_printing));
#endif // BUILDFLAG(ENABLE_PDF)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
dict->SetKey("newPrintPreviewLayoutEnabled", dict->SetKey("newPrintPreviewLayoutEnabled",
base::Value(base::FeatureList::IsEnabled( base::Value(base::FeatureList::IsEnabled(
......
...@@ -683,9 +683,14 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Beep) { ...@@ -683,9 +683,14 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Beep) {
IN_PROC_BROWSER_TEST_F(PDFAnnotationsTest, MAYBE_AnnotationsFeatureEnabled) { IN_PROC_BROWSER_TEST_F(PDFAnnotationsTest, MAYBE_AnnotationsFeatureEnabled) {
RunTestsInFile("annotations_feature_enabled_test.js", "test.pdf"); RunTestsInFile("annotations_feature_enabled_test.js", "test.pdf");
} }
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, AnnotationsFeatureDisabled) { IN_PROC_BROWSER_TEST_F(PDFExtensionTest, AnnotationsFeatureDisabled) {
RunTestsInFile("annotations_feature_disabled_test.js", "test.pdf"); RunTestsInFile("annotations_feature_disabled_test.js", "test.pdf");
} }
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Printing) {
RunTestsInFile("printing_icon_test.js", "test.pdf");
}
#endif #endif
// TODO(tsepez): See https://crbug.com/696650. // TODO(tsepez): See https://crbug.com/696650.
......
...@@ -204,8 +204,8 @@ ...@@ -204,8 +204,8 @@
title$="{{strings.tooltipDownload}}"></cr-icon-button> title$="{{strings.tooltipDownload}}"></cr-icon-button>
<cr-icon-button id="print" iron-icon="cr:print" on-click="print" <cr-icon-button id="print" iron-icon="cr:print" on-click="print"
aria-label$="{{strings.tooltipPrint}}" hidden="[[!printingEnabled]]" title$="{{strings.tooltipPrint}}"
title$="{{strings.tooltipPrint}}"></cr-icon-button> aria-label$="{{strings.tooltipPrint}}"></cr-icon-button>
<viewer-toolbar-dropdown id="bookmarks" <viewer-toolbar-dropdown id="bookmarks"
selected selected
......
...@@ -80,6 +80,14 @@ Polymer({ ...@@ -80,6 +80,14 @@ Polymer({
value: false, value: false,
}, },
/**
* Whether the Printing feature is enabled.
*/
printingEnabled: {
type: Boolean,
value: false,
},
strings: Object, strings: Object,
}, },
......
...@@ -777,6 +777,7 @@ PDFViewer.prototype = { ...@@ -777,6 +777,7 @@ PDFViewer.prototype = {
$('toolbar').strings = strings; $('toolbar').strings = strings;
$('toolbar').pdfAnnotationsEnabled = $('toolbar').pdfAnnotationsEnabled =
loadTimeData.getBoolean('pdfAnnotationsEnabled'); loadTimeData.getBoolean('pdfAnnotationsEnabled');
$('toolbar').printingEnabled = loadTimeData.getBoolean('printingEnabled');
$('zoom-toolbar').setStrings(strings); $('zoom-toolbar').setStrings(strings);
$('password-screen').strings = strings; $('password-screen').strings = strings;
$('error-screen').strings = strings; $('error-screen').strings = strings;
......
// Copyright 2019 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 testPrintingEnabled() {
const toolbar = document.body.querySelector('#toolbar');
toolbar.printingEnabled = true;
const printIcon = toolbar.shadowRoot.querySelector('#print');
chrome.test.assertTrue(!!printIcon);
chrome.test.assertFalse(printIcon.hidden);
chrome.test.succeed();
},
function testPrintingDisabled() {
const toolbar = document.body.querySelector('#toolbar');
toolbar.printingEnabled = false;
const printIcon = toolbar.shadowRoot.querySelector('#print');
chrome.test.assertTrue(!!printIcon);
chrome.test.assertTrue(printIcon.hidden);
chrome.test.succeed();
},
]);
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