Skip to content

Commit

Permalink
Migrate Cloud Print utility messages to Mojo
Browse files Browse the repository at this point in the history
These are the last remaining legacy IPC messages sent to or from any
utility process.

Bug: 993189
Change-Id: If231f7eaa9986deced8149a9095b31007945ab50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2953763
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#891777}
  • Loading branch information
krockot authored and Chromium LUCI CQ committed Jun 11, 2021
1 parent 5f58fb1 commit adf0045
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 264 deletions.
24 changes: 23 additions & 1 deletion chrome/common/BUILD.gn
Expand Up @@ -395,7 +395,7 @@ static_library("common") {
}
if (is_win) {
sources += [
"chrome_utility_printing_messages.h",
"chrome_utility_printing_param_traits_macros.h",
"service_process_util_win.cc",
]

Expand Down Expand Up @@ -793,3 +793,25 @@ mojom("offline_page_auto_fetcher_mojom") {
sources = [ "offline_page_auto_fetcher.mojom" ]
public_deps = [ "//url/mojom:url_mojom_gurl" ]
}

if (enable_basic_printing && is_win) {
mojom("cloud_print_utility_mojom") {
sources = [ "cloud_print_utility.mojom" ]
cpp_typemaps = [
{
types = [
{
mojom = "chrome.mojom.PrinterCapsAndDefaults"
cpp = "::printing::PrinterCapsAndDefaults"
},
{
mojom = "chrome.mojom.PrinterSemanticCapsAndDefaults"
cpp = "::printing::PrinterSemanticCapsAndDefaults"
},
]
traits_headers = [ "chrome_utility_printing_param_traits_macros.h" ]
traits_public_deps = [ ":common" ]
},
]
}
}
105 changes: 0 additions & 105 deletions chrome/common/chrome_utility_printing_messages.h

This file was deleted.

56 changes: 56 additions & 0 deletions chrome/common/chrome_utility_printing_param_traits_macros.h
@@ -0,0 +1,56 @@
// Copyright 2014 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.

#ifndef CHROME_COMMON_CHROME_UTILITY_PRINTING_PARAM_TRAITS_MACROS_H_
#define CHROME_COMMON_CHROME_UTILITY_PRINTING_PARAM_TRAITS_MACROS_H_

#include "build/build_config.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_start.h"
#include "ipc/ipc_param_traits.h"
#include "printing/backend/print_backend.h"
#include "printing/buildflags/buildflags.h"
#include "printing/mojom/print.mojom.h"

#if defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Preview and Cloud Print messages.
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
IPC_STRUCT_TRAITS_MEMBER(printer_defaults)
IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
IPC_STRUCT_TRAITS_END()

IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::ColorModel,
printing::mojom::ColorModel::kColorModelLast)

IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
IPC_STRUCT_TRAITS_MEMBER(display_name)
IPC_STRUCT_TRAITS_MEMBER(vendor_id)
IPC_STRUCT_TRAITS_MEMBER(size_um)
IPC_STRUCT_TRAITS_END()

IPC_ENUM_TRAITS_MIN_MAX_VALUE(printing::mojom::DuplexMode,
printing::mojom::DuplexMode::kUnknownDuplexMode,
printing::mojom::DuplexMode::kShortEdge)

IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(collate_capable)
IPC_STRUCT_TRAITS_MEMBER(collate_default)
IPC_STRUCT_TRAITS_MEMBER(copies_max)
IPC_STRUCT_TRAITS_MEMBER(duplex_modes)
IPC_STRUCT_TRAITS_MEMBER(duplex_default)
IPC_STRUCT_TRAITS_MEMBER(color_changeable)
IPC_STRUCT_TRAITS_MEMBER(color_default)
IPC_STRUCT_TRAITS_MEMBER(color_model)
IPC_STRUCT_TRAITS_MEMBER(bw_model)
IPC_STRUCT_TRAITS_MEMBER(papers)
IPC_STRUCT_TRAITS_MEMBER(default_paper)
IPC_STRUCT_TRAITS_MEMBER(dpis)
IPC_STRUCT_TRAITS_MEMBER(default_dpi)
IPC_STRUCT_TRAITS_END()

#endif // defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)

#endif // CHROME_COMMON_CHROME_UTILITY_PRINTING_PARAM_TRAITS_MACROS_H_
29 changes: 29 additions & 0 deletions chrome/common/cloud_print_utility.mojom
@@ -0,0 +1,29 @@
// Copyright 2021 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.

module chrome.mojom;

// Interface implemented by the unsandboxed Cloud Print utility process (see
// src/chrome/utility/printing_handler.cc) and called by the Cloud Print service
// process, which is a special Windows service process run by the deprecated
// Cloud Print Connector tool. The purpose of the utility process is to isolate
// printer driver crashes from the service process.
interface CloudPrintUtility {
// Retrieves capabilities and defaults for the specified printer. Returns null
// on failure.
GetPrinterCapsAndDefaults(string printer_name)
=> (PrinterCapsAndDefaults? caps_and_defaults);

// Retrieves capabilities and defaults for the specified printer. Returns null
// on failure.
GetPrinterSemanticCapsAndDefaults(string printer_name)
=> (PrinterSemanticCapsAndDefaults? caps_and_defaults);
};

[Native]
struct PrinterCapsAndDefaults;

[Native]
struct PrinterSemanticCapsAndDefaults;

8 changes: 4 additions & 4 deletions chrome/common/common_message_generator.h
Expand Up @@ -14,11 +14,11 @@
#include "printing/buildflags/buildflags.h"

#if BUILDFLAG(ENABLE_PRINTING)
#undef CHROME_COMMON_CHROME_UTILITY_PRINTING_MESSAGES_H_
#include "chrome/common/chrome_utility_printing_messages.h"
#ifndef CHROME_COMMON_CHROME_UTILITY_PRINTING_MESSAGES_H_
#undef CHROME_COMMON_CHROME_UTILITY_PRINTING_PARAM_TRAITS_MACROS_H_
#include "chrome/common/chrome_utility_printing_param_traits_macros.h"
#ifndef CHROME_COMMON_CHROME_UTILITY_PRINTING_PARAM_TRAITS_MACROS_H_
#error \
"Failed to include header chrome/common/chrome_utility_printing_messages.h"
"Failed to include header chrome/common/chrome_utility_printing_param_traits_macros.h"
#endif
#endif

Expand Down
5 changes: 4 additions & 1 deletion chrome/service/BUILD.gn
Expand Up @@ -95,6 +95,9 @@ static_library("service") {
"service_utility_process_host.h",
"service_utility_process_host_receiver_bindings.cc",
]
deps += [ "//sandbox/win:sandbox" ]
deps += [
"//chrome/common:cloud_print_utility_mojom",
"//sandbox/win:sandbox",
]
}
}

0 comments on commit adf0045

Please sign in to comment.