chore: use c++ manifests instead of json

This commit is contained in:
Heilig Benedek 2019-02-04 16:54:55 +01:00 коммит произвёл Samuel Attard
Родитель cfe8c3efd8
Коммит 4bdf7674f9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 191FEF027779CC6C
8 изменённых файлов: 93 добавлений и 58 удалений

Просмотреть файл

@ -2,7 +2,6 @@ import("//build/config/locales.gni")
import("//build/config/ui.gni")
import("//build/config/win/manifest.gni")
import("//pdf/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni")
@ -187,7 +186,6 @@ grit("resources") {
deps = [
":copy_shell_devtools_discovery_page",
":electron_content_manifest_overlays",
]
output_dir = "$target_gen_dir"
@ -236,6 +234,7 @@ static_library("electron_lib") {
":atom_js2c",
"buildflags",
"chromium_src:chrome",
"manifests",
"native_mate",
"//base",
"//base:base_static",
@ -956,26 +955,3 @@ group("electron") {
":electron_app",
]
}
group("electron_content_manifest_overlays") {
deps = [
":electron_content_browser_manifest_overlay",
":electron_content_packaged_services_manifest_overlay",
]
}
service_manifest("electron_content_packaged_services_manifest_overlay") {
source = "//electron/manifests/electron_content_packaged_services_manifest_overlay.json"
packaged_services = [ "//services/proxy_resolver:proxy_resolver_manifest" ]
if (enable_basic_printing) {
packaged_services += [
"//chrome/services/printing:manifest",
"//components/services/pdf_compositor:pdf_compositor_manifest",
]
}
}
service_manifest("electron_content_browser_manifest_overlay") {
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
}

44
atom/app/manifests.cc Normal file
Просмотреть файл

@ -0,0 +1,44 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/app/manifests.h"
#include "base/no_destructor.h"
#include "printing/buildflags/buildflags.h"
#include "services/proxy_resolver/proxy_resolver_manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/services/pdf_compositor/pdf_compositor_manifest.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/services/printing/manifest.h"
#endif
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest() {
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.WithDisplayName("Electron (browser process)")
.RequireCapability("device", "device:geolocation_control")
.RequireCapability("proxy_resolver", "factory")
.RequireCapability("chrome_printing", "converter")
.RequireCapability("pdf_compositor", "compositor")
.Build()};
return *manifest;
}
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest() {
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
proxy_resolver::GetManifest(),
#if BUILDFLAG(ENABLE_PRINTING)
pdf_compositor::GetManifest(),
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
chrome_printing::GetManifest(),
#endif
}};
return *manifests;
}

16
atom/app/manifests.h Normal file
Просмотреть файл

@ -0,0 +1,16 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_MANIFESTS_H_
#define ATOM_APP_MANIFESTS_H_
#include <vector>
#include "services/service_manager/public/cpp/manifest.h"
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest();
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest();
#endif // ATOM_APP_MANIFESTS_H_

Просмотреть файл

@ -11,6 +11,7 @@
#include <memory>
#include <utility>
#include "atom/app/manifests.h"
#include "atom/browser/api/atom_api_app.h"
#include "atom/browser/api/atom_api_protocol.h"
#include "atom/browser/api/atom_api_web_contents.h"
@ -715,19 +716,15 @@ void AtomBrowserClient::RegisterOutOfProcessServices(
base::Optional<service_manager::Manifest>
AtomBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
int id = -1;
if (name == content::mojom::kBrowserServiceName)
id = IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY;
else if (name == content::mojom::kPackagedServicesServiceName)
id = IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY;
if (name == content::mojom::kBrowserServiceName) {
return GetElectronContentBrowserOverlayManifest();
} else if (name == content::mojom::kPackagedServicesServiceName) {
service_manager::Manifest overlay;
overlay.packaged_services = GetElectronPackagedServicesOverlayManifest();
return overlay;
}
if (id == -1)
return base::nullopt;
base::StringPiece manifest_contents = rb.GetRawDataResource(id);
return service_manager::Manifest::FromValueDeprecated(
base::JSONReader::Read(manifest_contents));
return base::nullopt;
}
net::NetLog* AtomBrowserClient::GetNetLog() {

Просмотреть файл

@ -17,8 +17,6 @@
<part file="electron_strings.grdp" />
</messages>
<includes>
<include name="IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY" file="${target_gen_dir}\electron_content_browser_manifest_overlay.json" use_base_dir="false" type="BINDATA" />
<include name="IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="${target_gen_dir}\electron_content_packaged_services_manifest_overlay.json" use_base_dir="false" type="BINDATA" />
<include name="IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE" file="${target_gen_dir}\shell_devtools_discovery_page.html" use_base_dir="false" type="BINDATA" />
</includes>
</release>

23
manifests/BUILD.gn Normal file
Просмотреть файл

@ -0,0 +1,23 @@
import("//printing/buildflags/buildflags.gni")
source_set("manifests") {
sources = [
"//electron/atom/app/manifests.cc",
"//electron/atom/app/manifests.h",
]
include_dirs = [ "//electron" ]
deps = [
"//printing/buildflags",
"//services/proxy_resolver:proxy_resolver_manifest",
]
if (enable_basic_printing) {
deps += [ "//components/services/pdf_compositor:pdf_compositor_manifest" ]
}
if (enable_print_preview) {
deps += [ "//chrome/services/printing:manifest" ]
}
}

Просмотреть файл

@ -1,14 +0,0 @@
{
"name": "content_browser",
"display_name": "Electron (browser process)",
"interface_provider_specs": {
"service_manager:connector": {
"requires": {
"device": [ "device:geolocation_control" ],
"proxy_resolver": [ "factory" ],
"chrome_printing": [ "converter" ],
"pdf_compositor": [ "compositor"]
}
}
}
}

Просмотреть файл

@ -1,5 +0,0 @@
{
"name": "content_packaged_services",
"display_name": "Electron Packaged Services",
"interface_provider_specs": {}
}