forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDoc: go/cups-plugin This sets up the CupsProxy Chrome Service. This service is a singleton, managed by the ServiceManager and lives in the browser process. The service is currently started with the Profile; there will be future work to lazily initiate it on first printing request. Service implementation (ProxyManager) landing in following CL. Bug: chromium:945409 Test: Builds succeed + service unused so far. Unittests + tast tests landing in future CLs. Change-Id: I1257f32dbff8a3bdbd5690651b7ccba9e693eb23 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1547813 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Ken Rockot <rockot@google.com> Commit-Queue: Luum Habtemariam <luum@chromium.org> Cr-Commit-Position: refs/heads/master@{#653723}
- Loading branch information
Luum Habtemariam
authored and
Commit Bot
committed
Apr 24, 2019
1 parent
5f9118b
commit c295b4e
Showing
17 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 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. | ||
|
||
import("//build/config/features.gni") | ||
import("//printing/buildflags/buildflags.gni") | ||
|
||
assert(is_chromeos, | ||
"Non-Chrome-OS builds must not depend on //chrome/services/cups_proxy") | ||
|
||
source_set("cups_proxy") { | ||
sources = [ | ||
"cups_proxy_service.cpp", | ||
"cups_proxy_service.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//chrome/services/cups_proxy/public/mojom", | ||
"//chromeos/dbus", | ||
"//net", | ||
"//services/service_manager/public/cpp", | ||
"//services/service_manager/public/mojom", | ||
] | ||
|
||
# We stub this service if libCUPS is not present. | ||
if (use_cups) { | ||
configs += [ "//printing:cups" ] | ||
} | ||
|
||
public_deps = [ | ||
"//printing", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
luum@chromium.org | ||
skau@chromium.org | ||
|
||
per-file manifest.cc=set noparent | ||
per-file manifest.cc=file://ipc/SECURITY_OWNERS | ||
per-file manifest.h=set noparent | ||
per-file manifest.h=file://ipc/SECURITY_OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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. | ||
|
||
#include "chrome/services/cups_proxy/cups_proxy_service.h" | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace chromeos { | ||
namespace printing { | ||
|
||
CupsProxyService::CupsProxyService( | ||
service_manager::mojom::ServiceRequest request) | ||
: service_binding_(this, std::move(request)) {} | ||
|
||
CupsProxyService::~CupsProxyService() = default; | ||
|
||
void CupsProxyService::OnStart() { | ||
BindToCupsProxyDaemon(); | ||
} | ||
|
||
void CupsProxyService::OnConnect( | ||
const service_manager::BindSourceInfo& source_info, | ||
const std::string& interface_name, | ||
mojo::ScopedMessagePipeHandle interface_pipe) { | ||
DLOG(WARNING) << "CupsProxyService incorrectly received interface_request"; | ||
} | ||
|
||
void CupsProxyService::BindToCupsProxyDaemon() { | ||
// TODO(crbug.com/945409): Implement this. | ||
} | ||
|
||
void CupsProxyService::OnBindToCupsProxyDaemon(const bool success) { | ||
if (!success) { | ||
DLOG(WARNING) << "CupsProxyDaemonConnection bootstrap failed"; | ||
} | ||
} | ||
|
||
} // namespace printing | ||
} // namespace chromeos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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. | ||
|
||
#ifndef CHROME_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_ | ||
#define CHROME_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "mojo/public/cpp/bindings/binding_set.h" | ||
#include "services/service_manager/public/cpp/binder_registry.h" | ||
#include "services/service_manager/public/cpp/service.h" | ||
#include "services/service_manager/public/cpp/service_binding.h" | ||
#include "services/service_manager/public/mojom/service.mojom.h" | ||
|
||
namespace chromeos { | ||
namespace printing { | ||
|
||
// CupsProxy Service Implementation. | ||
// | ||
// Singleton Chrome Service managed by the ServiceManager and lives in the | ||
// browser process. Lazily initializes mojom::CupsProxier handler, | ||
// |proxy_manager_|, and handles binding all incoming | ||
// mojom::CupsProxierRequest's to it. | ||
// | ||
// Note: Service lifetime is the same as Profile; there will be future work to | ||
// lazily intiate it on first use. | ||
class CupsProxyService : public service_manager::Service { | ||
public: | ||
explicit CupsProxyService(service_manager::mojom::ServiceRequest request); | ||
~CupsProxyService() override; | ||
|
||
private: | ||
// service_manager::Service override. | ||
void OnStart() override; | ||
|
||
// This method is stubbed since the only expected consumer of this service is | ||
// a ChromeOS daemon; this connection is bootstrapped over D-Bus by the | ||
// below binding methods. | ||
void OnConnect(const service_manager::BindSourceInfo& source_info, | ||
const std::string& interface_name, | ||
mojo::ScopedMessagePipeHandle interface_pipe) override; | ||
|
||
// Binds |proxy_manager| to a CupsProxierPtr and passes it to the | ||
// CupsProxyDaemon. The binding is accomplished via D-Bus bootstrap. | ||
void BindToCupsProxyDaemon(); | ||
void OnBindToCupsProxyDaemon(const bool success); | ||
|
||
service_manager::ServiceBinding service_binding_; | ||
service_manager::BinderRegistry binder_registry_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(CupsProxyService); | ||
}; | ||
|
||
} // namespace printing | ||
} // namespace chromeos | ||
|
||
#endif // CHROME_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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. | ||
|
||
import("//build/config/features.gni") | ||
import("//printing/buildflags/buildflags.gni") | ||
|
||
assert(is_chromeos, "Non-Chrome-OS builds must not depend on this") | ||
|
||
source_set("manifest") { | ||
sources = [ | ||
"manifest.cc", | ||
"manifest.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//chrome/services/cups_proxy/public/mojom", | ||
"//services/service_manager/public/cpp", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
per-file manifest.cc=set noparent | ||
per-file manifest.cc=file://ipc/SECURITY_OWNERS | ||
per-file manifest.h=set noparent | ||
per-file manifest.h=file://ipc/SECURITY_OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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. | ||
|
||
#include "chrome/services/cups_proxy/public/cpp/manifest.h" | ||
|
||
#include "base/no_destructor.h" | ||
#include "chrome/services/cups_proxy/public/mojom/constants.mojom.h" | ||
#include "services/service_manager/public/cpp/manifest_builder.h" | ||
|
||
namespace chromeos { | ||
namespace printing { | ||
|
||
const service_manager::Manifest& GetCupsProxyManifest() { | ||
static base::NoDestructor<service_manager::Manifest> manifest{ | ||
service_manager::ManifestBuilder() | ||
.WithServiceName(mojom::kCupsProxyServiceName) | ||
.WithDisplayName("CupsProxyService") | ||
.WithOptions(service_manager::ManifestOptionsBuilder() | ||
.WithSandboxType("utility") | ||
.WithInstanceSharingPolicy( | ||
service_manager::Manifest:: | ||
InstanceSharingPolicy::kSingleton) | ||
.Build()) | ||
.ExposeCapability(mojom::kCupsProxierCapability, | ||
service_manager::Manifest::InterfaceList<>()) | ||
.Build()}; | ||
return *manifest; | ||
} | ||
|
||
} // namespace printing | ||
} // namespace chromeos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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. | ||
|
||
#ifndef CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_MANIFEST_H_ | ||
#define CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_MANIFEST_H_ | ||
|
||
#include "services/service_manager/public/cpp/manifest.h" | ||
|
||
namespace chromeos { | ||
namespace printing { | ||
|
||
const service_manager::Manifest& GetCupsProxyManifest(); | ||
|
||
} // namespace printing | ||
} // namespace chromeos | ||
|
||
#endif // CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_MANIFEST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. | ||
|
||
import("//build/config/features.gni") | ||
import("//mojo/public/tools/bindings/mojom.gni") | ||
|
||
mojom("mojom") { | ||
sources = [ | ||
"constants.mojom", | ||
] | ||
|
||
public_deps = [ | ||
"//mojo/public/mojom/base", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
per-file *.mojom=set noparent | ||
per-file *.mojom=file://ipc/SECURITY_OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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. | ||
|
||
module chromeos.printing.mojom; | ||
|
||
// Service id. | ||
const string kCupsProxyServiceName = "cups_proxy"; | ||
|
||
// IppProxier capability id. | ||
const string kCupsProxierCapability = "cups_proxier"; |