0

Relocate printer capabilities

Printer capabilities have been located under //components since
r540621, when they were moved here in anticipation of the upcoming
printing backend service.  However, once it came time to introduce the
service it landed under //chrome, because of the guidelines required to
add it to //components were not satisfied. [1]

One ripple effect of the service landing under //chrome is that printer
capabilities need to also be moved out from //components.  Its presence
under //components results in a dependencies conflict for Mac because
it ends up causing a dependency on //content/browser, which is not
allowed. [2]

Since printer capabilities are referenced by only one space, [3]
resolve this by moving printer capabilities code out of //components
and into a home under //chrome like where the service is.

[1] https://source.chromium.org/chromium/chromium/src/+/master:components/README.md
[2] https://source.chromium.org/chromium/chromium/src/+/master:chrome/BUILD.gn;drc=98fd3773af40462359d2cef844f946526e99b1fe;l=1301-1305
[3] https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/ui/webui/print_preview/

Bug: 809738
Change-Id: I50d76e18f6e86f6bf483883c1d0654c8fc0724d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592628
Commit-Queue: Alan Screen <awscreen@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839188}
This commit is contained in:
Alan Screen
2020-12-23 22:00:37 +00:00
committed by Chromium LUCI CQ
parent 2c41324f0b
commit cfbec794ae
29 changed files with 142 additions and 116 deletions

@ -2028,6 +2028,7 @@ static_library("browser") {
"//chrome/common:version_header",
"//chrome/common/net",
"//chrome/common/performance_manager/mojom",
"//chrome/common/printing:printing",
"//chrome/installer/util:with_no_strings",
"//chrome/services/machine_learning/public/cpp",
"//chrome/services/machine_learning/public/mojom",

@ -286,7 +286,7 @@
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && defined(OS_WIN)
#include "components/printing/browser/printer_capabilities.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "printing/backend/win_helper.h"
#endif

@ -4568,6 +4568,7 @@ static_library("ui") {
"webui/print_preview/printer_handler.h",
]
deps += [
"//chrome/common/printing:printing",
"//components/printing/common:mojo_interfaces",
"//printing/mojom",
"//services/device/public/cpp/usb",

@ -26,12 +26,12 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "chromeos/printing/printer_configuration.h"
#include "chromeos/printing/printer_translator.h"
#include "components/prefs/pref_service.h"
#include "components/printing/browser/printer_capabilities.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "printing/backend/print_backend_consts.h"

@ -18,9 +18,9 @@
#include "chrome/browser/chromeos/printing/test_printer_configurer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/printing/ppd_provider.h"
#include "components/printing/browser/printer_capabilities.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "printing/backend/print_backend.h"

@ -17,12 +17,12 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "components/printing/browser/printer_capabilities.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#if defined(OS_MAC)
#include "components/printing/browser/printer_capabilities_mac.h"
#include "chrome/common/printing/printer_capabilities_mac.h"
#endif
#if defined(OS_WIN)

@ -47,7 +47,7 @@
#include "url/gurl.h"
#if defined(OS_MAC)
#include "components/printing/browser/printer_capabilities_mac.h"
#include "chrome/common/printing/printer_capabilities_mac.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)

@ -17,7 +17,7 @@
#include "url/gurl.h"
#if defined(OS_MAC)
#include "components/printing/browser/printer_capabilities_mac.h"
#include "chrome/common/printing/printer_capabilities_mac.h"
#include "printing/backend/print_backend.h"
#include "ui/gfx/geometry/size.h"
#endif

@ -54,12 +54,12 @@
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "chrome/common/webui_url_constants.h"
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/cloud_devices/common/printer_description.h"
#include "components/prefs/pref_service.h"
#include "components/printing/browser/printer_capabilities.h"
#include "components/printing/common/cloud_print_cdd_conversion.h"
#include "components/signin/public/identity_manager/accounts_in_cookie_jar_info.h"
#include "components/signin/public/identity_manager/primary_account_access_token_fetcher.h"

@ -27,10 +27,10 @@
#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/printing/printer_configuration.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/printing/browser/printer_capabilities.h"
#include "components/signin/public/identity_manager/scope_set.h"
#include "content/public/browser/web_ui.h"

@ -22,8 +22,8 @@
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "components/crash/core/common/crash_keys.h"
#include "components/printing/browser/printer_capabilities.h"
#include "content/public/browser/render_frame_host.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/page_range.h"

@ -0,0 +1,97 @@
# Copyright 2020 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.
import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
if (is_chromeos_ash) {
import("//printing/backend/tools/code_generator.gni")
}
declare_args() {
# Enable print media localization only on the platforms that support CUPS IPP
# (ChromeOS and macOS for now). The localization expects media vendor IDs
# uniquely generated by CUPS IPP.
enable_print_media_l10n = is_chromeos_ash || is_mac
}
buildflag_header("printing_buildflags") {
header = "printing_buildflags.h"
flags = [ "PRINT_MEDIA_L10N_ENABLED=$enable_print_media_l10n" ]
}
if (is_chromeos_ash) {
localization_map_path = "$target_gen_dir/ipp_l10n.cc"
ipp_code_generate("ipp_l10n_generate") {
outputs = [ localization_map_path ]
args = [ "--localization-map=" +
rebase_path(localization_map_path, root_build_dir) ]
}
}
source_set("printing") {
sources = [
"printer_capabilities.cc",
"printer_capabilities.h",
]
public_deps = [ ":printing_buildflags" ]
deps = [
"//base",
"//build:chromeos_buildflags",
"//components/crash/core/common",
"//components/printing/common",
"//components/strings:components_strings_grit",
"//printing",
"//ui/base",
]
if (is_mac) {
sources += [
"printer_capabilities_mac.h",
"printer_capabilities_mac.mm",
]
}
if (is_chromeos_ash) {
deps += [ ":ipp_l10n_generate" ]
sources += [
"ipp_l10n.h",
localization_map_path,
]
}
if (enable_print_media_l10n) {
sources += [
"print_media_l10n.cc",
"print_media_l10n.h",
]
}
}
source_set("unit_tests") {
testonly = true
sources = [ "printer_capabilities_unittest.cc" ]
deps = [
"//base",
"//build:chromeos_buildflags",
"//chrome/common/printing",
"//components/printing/browser",
"//content/test:test_support",
"//printing:test_support",
"//testing/gtest",
]
if (is_mac) {
sources += [ "printer_capabilities_mac_unittest.mm" ]
}
if (enable_print_media_l10n) {
sources += [ "print_media_l10n_unittest.cc" ]
}
}

@ -0,0 +1,3 @@
monorail: {
component: "Internals>Printing"
}

@ -0,0 +1 @@
file://printing/OWNERS

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PRINTING_BROWSER_IPP_L10N_H_
#define COMPONENTS_PRINTING_BROWSER_IPP_L10N_H_
#ifndef CHROME_COMMON_PRINTING_IPP_L10N_H_
#define CHROME_COMMON_PRINTING_IPP_L10N_H_
#include <map>
@ -11,4 +11,4 @@
const std::map<base::StringPiece, int>& CapabilityLocalizationMap();
#endif // COMPONENTS_PRINTING_BROWSER_IPP_L10N_H_
#endif // CHROME_COMMON_PRINTING_IPP_L10N_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/printing/browser/print_media_l10n.h"
#include "chrome/common/printing/print_media_l10n.h"
#include <map>

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PRINTING_BROWSER_PRINT_MEDIA_L10N_H_
#define COMPONENTS_PRINTING_BROWSER_PRINT_MEDIA_L10N_H_
#ifndef CHROME_COMMON_PRINTING_PRINT_MEDIA_L10N_H_
#define CHROME_COMMON_PRINTING_PRINT_MEDIA_L10N_H_
#include <string>
@ -15,4 +15,4 @@ std::string LocalizePaperDisplayName(const std::string& vendor_id);
} // namespace printing
#endif // COMPONENTS_PRINTING_BROWSER_PRINT_MEDIA_L10N_H_
#endif // CHROME_COMMON_PRINTING_PRINT_MEDIA_L10N_H_

@ -8,7 +8,7 @@
#include <string>
#include <vector>
#include "components/printing/browser/print_media_l10n.h"
#include "chrome/common/printing/print_media_l10n.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/printing/browser/printer_capabilities.h"
#include "chrome/common/printing/printer_capabilities.h"
#include <memory>
#include <string>
@ -18,8 +18,8 @@
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/printing/printing_buildflags.h"
#include "components/crash/core/common/crash_keys.h"
#include "components/printing/browser/printing_buildflags.h"
#include "components/printing/common/cloud_print_cdd_conversion.h"
#include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_consts.h"
@ -34,17 +34,17 @@
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/feature_list.h"
#include "components/printing/browser/ipp_l10n.h"
#include "chrome/common/printing/ipp_l10n.h"
#include "components/strings/grit/components_strings.h"
#include "printing/printing_features.h"
#include "ui/base/l10n/l10n_util.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(PRINT_MEDIA_L10N_ENABLED)
#include "components/printing/browser/print_media_l10n.h"
#if defined(OS_APPLE)
#include "chrome/common/printing/print_media_l10n.h"
#if defined(OS_MAC)
#include "printing/printing_features.h"
#endif // defined(OS_APPLE)
#endif // defined(OS_MAC)
#endif // BUILDFLAG(PRINT_MEDIA_L10N_ENABLED)
namespace printing {
@ -116,7 +116,7 @@ base::Value GetPrinterCapabilitiesOnBlockingTaskRunner(
#if BUILDFLAG(PRINT_MEDIA_L10N_ENABLED)
bool populate_paper_display_names = true;
#if defined(OS_APPLE)
#if defined(OS_MAC)
// Paper display name localization requires standardized vendor ID names
// populated by CUPS IPP. If the CUPS IPP backend is not enabled, localization
// will not properly occur.

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_H_
#define COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_H_
#ifndef CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_H_
#define CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_H_
#include <memory>
#include <string>
@ -44,4 +44,4 @@ base::Value GetSettingsOnBlockingTaskRunner(
} // namespace printing
#endif // COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_H_
#endif // CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_H_

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_MAC_H_
#define COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_MAC_H_
#ifndef CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_MAC_H_
#define CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_MAC_H_
#include "printing/backend/print_backend.h"
@ -31,4 +31,4 @@ PrinterSemanticCapsAndDefaults::Papers GetMacCustomPaperSizesFromFile(
} // namespace printing
#endif // COMPONENTS_PRINTING_BROWSER_PRINTER_CAPABILITIES_MAC_H_
#endif // CHROME_COMMON_PRINTING_PRINTER_CAPABILITIES_MAC_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/printing/browser/printer_capabilities_mac.h"
#include "chrome/common/printing/printer_capabilities_mac.h"
#import <AppKit/AppKit.h>

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/printing/browser/printer_capabilities_mac.h"
#include "chrome/common/printing/printer_capabilities_mac.h"
#include "base/files/scoped_temp_dir.h"
#include "base/mac/foundation_util.h"

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/printing/browser/printer_capabilities.h"
#include "chrome/common/printing/printer_capabilities.h"
#include <memory>

@ -66,6 +66,7 @@ source_set("lib") {
"print_backend_service_impl.cc",
"print_backend_service_impl.h",
]
deps += [ "//chrome/common/printing" ]
}
}

@ -33,6 +33,7 @@ import("//extensions/buildflags/buildflags.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//net/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//rlz/buildflags/buildflags.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
@ -5787,6 +5788,7 @@ test("unit_tests") {
]
deps += [
"//chrome/common/printing:unit_tests",
"//printing",
"//printing:test_support",
"//printing/mojom",

@ -439,7 +439,6 @@ test("components_unittests") {
if (enable_basic_printing) {
deps += [
"//components/printing/browser:unit_tests",
"//components/printing/common:unit_tests",
"//components/services/print_compositor:unit_tests",
]

@ -2,35 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
if (is_chromeos_ash) {
import("//printing/backend/tools/code_generator.gni")
}
declare_args() {
# Enable print media localization only on the platforms that support CUPS IPP
# (ChromeOS and macOS for now). The localization expects media vendor IDs
# uniquely generated by CUPS IPP.
enable_print_media_l10n = is_chromeos_ash || is_mac
}
buildflag_header("printing_buildflags") {
header = "printing_buildflags.h"
flags = [ "PRINT_MEDIA_L10N_ENABLED=$enable_print_media_l10n" ]
}
if (is_chromeos_ash) {
localization_map_path = "$target_gen_dir/ipp_l10n.cc"
ipp_code_generate("ipp_l10n_generate") {
outputs = [ localization_map_path ]
args = [ "--localization-map=" +
rebase_path(localization_map_path, root_build_dir) ]
}
}
static_library("browser") {
sources = [
"print_composite_client.cc",
@ -39,15 +10,10 @@ static_library("browser") {
"print_manager.h",
"print_manager_utils.cc",
"print_manager_utils.h",
"printer_capabilities.cc",
"printer_capabilities.h",
"service_sandbox_type.h",
]
public_deps = [
":printing_buildflags",
"//content/public/browser",
]
public_deps = [ "//content/public/browser" ]
deps = [
"//base",
@ -65,49 +31,4 @@ static_library("browser") {
"//ui/base",
"//ui/gfx/geometry",
]
if (is_mac) {
sources += [
"printer_capabilities_mac.h",
"printer_capabilities_mac.mm",
]
}
if (is_chromeos_ash) {
deps += [ ":ipp_l10n_generate" ]
sources += [
"ipp_l10n.h",
localization_map_path,
]
}
if (enable_print_media_l10n) {
sources += [
"print_media_l10n.cc",
"print_media_l10n.h",
]
}
}
source_set("unit_tests") {
testonly = true
sources = [ "printer_capabilities_unittest.cc" ]
deps = [
"//base",
"//build:chromeos_buildflags",
"//components/printing/browser",
"//content/test:test_support",
"//printing:test_support",
"//testing/gtest",
]
if (is_mac) {
sources += [ "printer_capabilities_mac_unittest.mm" ]
}
if (enable_print_media_l10n) {
sources += [ "print_media_l10n_unittest.cc" ]
}
}

@ -58,7 +58,7 @@ HANDLER_FOOTER = """ return result;
L10N_HEADER = """// DO NOT MODIFY
// Generated by printing/backend/tools/code_generator.py
#include "components/printing/browser/ipp_l10n.h"
#include "chrome/common/printing/ipp_l10n.h"
#include "base/no_destructor.h"
#include "components/strings/grit/components_strings.h"