Skip to content

Commit

Permalink
[fuchsia] enable_basic_printing = true
Browse files Browse the repository at this point in the history
This just enables the code. Fuchsia does not yet support printing.

Bug: 1272828, 1272829, 1302871
Change-Id: Ie6a54ca724b775c50572d305b137414c15ed5d7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3498630
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977920}
  • Loading branch information
ddorwin authored and Chromium LUCI CQ committed Mar 5, 2022
1 parent 69d704e commit ed2ac5c
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 26 deletions.
23 changes: 12 additions & 11 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6363,6 +6363,9 @@ static_library("browser") {
if (is_linux || is_chromeos) {
sources += [ "printing/printer_manager_dialog_linux.cc" ]
}
if (is_fuchsia) {
sources += [ "printing/printer_manager_dialog_fuchsia.cc" ]
}
if (enable_oop_printing) {
sources += [
"printing/print_backend_service_manager.cc",
Expand Down Expand Up @@ -7860,17 +7863,15 @@ static_library("test_support") {
}

if (enable_oop_printing) {
if (is_win || is_mac || is_linux || is_chromeos) {
sources += [
"printing/print_backend_service_test_impl.cc",
"printing/print_backend_service_test_impl.h",
]
deps += [
"//chrome/services/printing:lib",
"//chrome/services/printing/public/mojom",
"//printing:test_support",
]
}
sources += [
"printing/print_backend_service_test_impl.cc",
"printing/print_backend_service_test_impl.h",
]
deps += [
"//chrome/services/printing:lib",
"//chrome/services/printing/public/mojom",
"//printing:test_support",
]
}

if (enable_extensions) {
Expand Down
17 changes: 17 additions & 0 deletions chrome/browser/printing/printer_manager_dialog_fuchsia.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2022 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.

#include "chrome/browser/printing/printer_manager_dialog.h"

#include <ostream>

#include "base/notreached.h"

namespace printing {

void PrinterManagerDialog::ShowPrinterManagerDialog(Profile* profile) {
NOTIMPLEMENTED() << "See https://crbug.com/1272829";
}

} // namespace printing
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ base::FilePath PdfPrinterHandler::GetFileNameForPrintJobTitle(
DCHECK(!job_title.empty());
#if BUILDFLAG(IS_WIN)
base::FilePath::StringType print_job_title(base::AsWString(job_title));
#elif BUILDFLAG(IS_POSIX)
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
base::FilePath::StringType print_job_title = base::UTF16ToUTF8(job_title);
#endif

Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ static_library("renderer") {
"printing/chrome_print_render_frame_helper_delegate.cc",
"printing/chrome_print_render_frame_helper_delegate.h",
]
if (enable_print_preview) {
if (enable_print_preview && enable_plugins) {
sources += [
"pepper/chrome_pdf_print_client.cc",
"pepper/chrome_pdf_print_client.h",
Expand Down
4 changes: 2 additions & 2 deletions chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
#include "printing/metafile_agent.h" // nogncheck
#endif

#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/renderer/pepper/chrome_pdf_print_client.h"
#include "components/pdf/renderer/pepper_pdf_host.h"
#endif
Expand Down Expand Up @@ -478,7 +478,7 @@ void ChromeContentRendererClient::RenderThreadStarted() {
WebSecurityPolicy::RegisterURLSchemeAsNotAllowingJavascriptURLs(
chrome_search_scheme);

#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && BUILDFLAG(ENABLE_PLUGINS)
pdf_print_client_ = std::make_unique<ChromePDFPrintClient>();
pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get());
#endif
Expand Down
4 changes: 2 additions & 2 deletions chrome/renderer/chrome_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#endif

class ChromeRenderThreadObserver;
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && BUILDFLAG(ENABLE_PLUGINS)
class ChromePDFPrintClient;
#endif
#if BUILDFLAG(ENABLE_SPELLCHECK)
Expand Down Expand Up @@ -277,7 +277,7 @@ class ChromeContentRendererClient
#endif
std::unique_ptr<subresource_filter::UnverifiedRulesetDealer>
subresource_filter_ruleset_dealer_;
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && BUILDFLAG(ENABLE_PLUGINS)
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
#endif
#if BUILDFLAG(ENABLE_PLUGINS)
Expand Down
3 changes: 2 additions & 1 deletion chrome/utility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static_library("utility") {
"//components/services/print_compositor/public/mojom",
]

if (is_win || is_mac || is_linux || is_chromeos) {
# TODO(crbug.com/1302871): Simplify this. Is `!is_android` sufficient?
if (is_win || is_mac || is_linux || is_chromeos || is_fuchsia) {
deps += [ "//chrome/services/printing:lib" ]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ TEST_F(PrintCompositorImplTest, NotifyUnavailableSubframe) {
testing::Mock::VerifyAndClearExpectations(&impl);
}

TEST_F(PrintCompositorImplCrashKeyTest, SetCrashKey) {
#if BUILDFLAG(IS_FUCHSIA)
// TODO(crbug.com/1186718): Enable this test once CrashKeys are supported.
#define MAYBE_SetCrashKey DISABLED_SetCrashKey
#else
#define MAYBE_SetCrashKey SetCrashKey
#endif
TEST_F(PrintCompositorImplCrashKeyTest, MAYBE_SetCrashKey) {
PrintCompositorImpl impl(mojo::NullReceiver(),
false /* initialize_environment */,
nullptr /* io_task_runner */);
Expand Down
5 changes: 5 additions & 0 deletions content/browser/child_process_launcher_helper_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "content/browser/child_process_launcher.h"
#include "content/public/browser/child_process_launcher_utils.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "printing/buildflags/buildflags.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"

namespace content {
Expand Down Expand Up @@ -43,6 +44,10 @@ const char* ProcessNameFromSandboxType(sandbox::mojom::Sandbox sandbox_type) {
return "print-compositor";
case sandbox::mojom::Sandbox::kSpeechRecognition:
return "speech-recognition";
#if BUILDFLAG(ENABLE_OOP_PRINTING)
case sandbox::mojom::Sandbox::kPrintBackend:
return "print-backend";
#endif
}
}

Expand Down
7 changes: 6 additions & 1 deletion headless/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import("//build/util/lastchange.gni")
import("//build/util/process_version.gni")
import("//headless/headless.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//pdf/features.gni")
import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//third_party/closure_compiler/compile_js.gni")
Expand Down Expand Up @@ -862,6 +863,7 @@ test("headless_browsertests") {
"//content/test:test_support",
"//gin",
"//net:test_support",
"//pdf:buildflags",
"//printing/buildflags",
"//services/device/public/cpp:test_support",
"//services/network/public/mojom",
Expand All @@ -881,9 +883,12 @@ test("headless_browsertests") {
if (enable_basic_printing) {
deps += [
"//components/printing/browser",
"//pdf",
"//printing",
]

if (enable_pdf) {
deps += [ "//pdf" ]
}
}

if (headless_use_policy) {
Expand Down
7 changes: 4 additions & 3 deletions headless/test/headless_web_contents_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "headless/public/headless_devtools_client.h"
#include "headless/public/headless_web_contents.h"
#include "headless/test/headless_browser_test.h"
#include "pdf/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -47,7 +48,7 @@
#include "ui/gfx/geometry/size_f.h"
#include "url/gurl.h"

#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PDF)
#include "base/strings/string_number_conversions.h"
#include "pdf/pdf.h"
#include "printing/pdf_render_settings.h"
Expand Down Expand Up @@ -274,7 +275,7 @@ INSTANTIATE_TEST_SUITE_P(HeadlessWebContentsScreenshotWindowPositionTests,
HeadlessWebContentsScreenshotWindowPositionTest,
::testing::Bool());

#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PDF)
class HeadlessWebContentsPDFTest : public HeadlessAsyncDevTooledBrowserTest {
public:
const double kPaperWidth = 10;
Expand Down Expand Up @@ -721,7 +722,7 @@ INSTANTIATE_TEST_SUITE_P(All,

#endif // BUILDFLAG(ENABLE_TAGGED_PDF)

#endif // BUILDFLAG(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PDF)

class HeadlessWebContentsSecurityTest
: public HeadlessAsyncDevTooledBrowserTest,
Expand Down
5 changes: 3 additions & 2 deletions printing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ component("printing") {
]
}

if (is_linux) {
# TODO(crbug.com/1272828): Determine need for Fuchsia-specific implementation.
if (is_linux || is_fuchsia) {
sources += [
"printing_context_linux.cc",
"printing_context_linux.h",
Expand Down Expand Up @@ -288,7 +289,7 @@ static_library("test_support") {
sources += [ "image_android.cc" ]
}

if (is_linux || is_chromeos) {
if (is_linux || is_chromeos || is_fuchsia) {
sources += [ "image_linux.cc" ]
}
if (is_mac) {
Expand Down
2 changes: 1 addition & 1 deletion printing/buildflags/buildflags.gni
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import("//pdf/features.gni")

declare_args() {
# Enables basic printing support and UI.
enable_basic_printing = !is_chromecast && !is_ios && !is_fuchsia
enable_basic_printing = !is_chromecast && !is_ios
}

declare_args() {
Expand Down
4 changes: 4 additions & 0 deletions sandbox/policy/fuchsia/sandbox_policy_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/threading/thread_task_runner_handle.h"
#include "printing/buildflags/buildflags.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/switches.h"

Expand Down Expand Up @@ -156,6 +157,9 @@ const SandboxConfig* GetConfigForSandboxType(sandbox::mojom::Sandbox type) {
// Remaining types receive no-access-to-anything.
case sandbox::mojom::Sandbox::kAudio:
case sandbox::mojom::Sandbox::kCdm:
#if BUILDFLAG(ENABLE_PRINTING)
case sandbox::mojom::Sandbox::kPrintBackend:
#endif
case sandbox::mojom::Sandbox::kPrintCompositor:
case sandbox::mojom::Sandbox::kService:
case sandbox::mojom::Sandbox::kSpeechRecognition:
Expand Down

0 comments on commit ed2ac5c

Please sign in to comment.