Skip to content

Commit

Permalink
Make PrintBackendService::GetPrinterSemanticCapsAndDefaults() Ash-only
Browse files Browse the repository at this point in the history
This Mojo interface is only called on Chrome OS Ash.

Change-Id: I6b5e4d1ab1a6df7b8f3900446ea8c1a8d96c4cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4368541
Commit-Queue: Lei Zhang <[email protected]>
Reviewed-by: Alan Screen <[email protected]>
Reviewed-by: Will Harris <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1122047}
  • Loading branch information
leizleiz authored and Chromium LUCI CQ committed Mar 25, 2023
1 parent ab5e677 commit 3a48a1d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chrome/browser/printing/print_backend_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/printing/print_backend_service_test_impl.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
Expand Down Expand Up @@ -444,6 +445,7 @@ IN_PROC_BROWSER_TEST_F(PrintBackendBrowserTest, GetDefaultPrinterName) {
kDefaultPrinterName);
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(PrintBackendBrowserTest,
GetPrinterSemanticCapsAndDefaults) {
LaunchService();
Expand Down Expand Up @@ -493,6 +495,7 @@ IN_PROC_BROWSER_TEST_F(PrintBackendBrowserTest,
ASSERT_TRUE(printer_caps->is_result_code());
EXPECT_EQ(printer_caps->get_result_code(), mojom::ResultCode::kAccessDenied);
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

IN_PROC_BROWSER_TEST_F(PrintBackendBrowserTest, FetchCapabilities) {
LaunchService();
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/printing/print_backend_service_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
Expand Down Expand Up @@ -235,6 +236,7 @@ void PrintBackendServiceManager::GetDefaultPrinterName(
base::Unretained(this), std::move(context)));
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void PrintBackendServiceManager::GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
Expand All @@ -256,6 +258,7 @@ void PrintBackendServiceManager::GetPrinterSemanticCapsAndDefaults(
&PrintBackendServiceManager::OnDidGetPrinterSemanticCapsAndDefaults,
base::Unretained(this), std::move(context)));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

PrintBackendServiceManager::ContextId
PrintBackendServiceManager::EstablishPrintingContext(
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/printing/print_backend_service_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/unguessable_token.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
Expand Down Expand Up @@ -132,10 +133,12 @@ class PrintBackendServiceManager {
mojom::PrintBackendService::FetchCapabilitiesCallback callback);
void GetDefaultPrinterName(
mojom::PrintBackendService::GetDefaultPrinterNameCallback callback);
#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
callback);
#endif
ContextId EstablishPrintingContext(ClientId client_id,
const std::string& printer_name
#if BUILDFLAG(ENABLE_OOP_BASIC_PRINT_DIALOG)
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/printing/print_backend_service_test_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/printing/print_backend_service_manager.h"
#include "printing/backend/test_print_backend.h"

Expand Down Expand Up @@ -113,6 +115,7 @@ void PrintBackendServiceTestImpl::GetDefaultPrinterName(
PrintBackendServiceImpl::GetDefaultPrinterName(std::move(callback));
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void PrintBackendServiceTestImpl::GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
Expand All @@ -125,6 +128,7 @@ void PrintBackendServiceTestImpl::GetPrinterSemanticCapsAndDefaults(
PrintBackendServiceImpl::GetPrinterSemanticCapsAndDefaults(
printer_name, std::move(callback));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

void PrintBackendServiceTestImpl::FetchCapabilities(
const std::string& printer_name,
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/printing/print_backend_service_test_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/services/printing/print_backend_service_impl.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
Expand Down Expand Up @@ -89,10 +90,12 @@ class PrintBackendServiceTestImpl : public PrintBackendServiceImpl {
void GetDefaultPrinterName(
mojom::PrintBackendService::GetDefaultPrinterNameCallback callback)
override;
#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
callback) override;
#endif
void FetchCapabilities(
const std::string& printer_name,
mojom::PrintBackendService::FetchCapabilitiesCallback callback) override;
Expand Down
3 changes: 3 additions & 0 deletions chrome/services/printing/print_backend_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "base/threading/sequence_bound.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/printing/printing_init.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#include "components/crash/core/common/crash_keys.h"
Expand Down Expand Up @@ -501,6 +502,7 @@ void PrintBackendServiceImpl::GetDefaultPrinterName(
mojom::DefaultPrinterNameResult::NewDefaultPrinterName(default_printer));
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void PrintBackendServiceImpl::GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
Expand All @@ -522,6 +524,7 @@ void PrintBackendServiceImpl::GetPrinterSemanticCapsAndDefaults(
mojom::PrinterSemanticCapsAndDefaultsResult::NewPrinterCaps(
std::move(printer_caps)));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

void PrintBackendServiceImpl::FetchCapabilities(
const std::string& printer_name,
Expand Down
3 changes: 3 additions & 0 deletions chrome/services/printing/print_backend_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
Expand Down Expand Up @@ -151,10 +152,12 @@ class PrintBackendServiceImpl : public mojom::PrintBackendService {
void GetDefaultPrinterName(
mojom::PrintBackendService::GetDefaultPrinterNameCallback callback)
override;
#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
mojom::PrintBackendService::GetPrinterSemanticCapsAndDefaultsCallback
callback) override;
#endif
void FetchCapabilities(
const std::string& printer_name,
mojom::PrintBackendService::FetchCapabilitiesCallback callback) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ interface PrintBackendService {
=> (DefaultPrinterNameResult printer_name);

// Gets the semantic capabilities and defaults for a specific printer.
[EnableIf=is_chromeos_ash]
GetPrinterSemanticCapsAndDefaults(string printer_name)
=> (PrinterSemanticCapsAndDefaultsResult printer_caps);

Expand Down

0 comments on commit 3a48a1d

Please sign in to comment.