mandoline: Reland "Sandbox mojo:browser and mojo:omnibox."
This is a straight reland of the previous patch; as the manual usage of icu was removed in https://codereview.chromium.org/1281343003/. BUG=492524 Previous Review URL: https://codereview.chromium.org/1282903002 TBR=jam@chromium.org Review URL: https://codereview.chromium.org/1286773002 Cr-Commit-Position: refs/heads/master@{#343765}
This commit is contained in:
components/font_service/public/cpp
mandoline
app
services
ui
mojo/shell
@ -6,9 +6,25 @@
|
||||
|
||||
#include "components/font_service/public/cpp/font_service_thread.h"
|
||||
#include "mojo/application/public/cpp/application_impl.h"
|
||||
#include "mojo/application/public/cpp/connect.h"
|
||||
#include "mojo/application/public/interfaces/shell.mojom.h"
|
||||
|
||||
namespace font_service {
|
||||
|
||||
FontLoader::FontLoader(mojo::Shell* shell) {
|
||||
mojo::ServiceProviderPtr font_service_provider;
|
||||
mojo::URLRequestPtr request(mojo::URLRequest::New());
|
||||
request->url = mojo::String::From("mojo:font_service");
|
||||
FontServicePtr font_service;
|
||||
shell->ConnectToApplication(request.Pass(),
|
||||
GetProxy(&font_service_provider),
|
||||
nullptr,
|
||||
nullptr);
|
||||
mojo::ConnectToService(font_service_provider.get(), &font_service);
|
||||
|
||||
thread_ = new internal::FontServiceThread(font_service.Pass());
|
||||
}
|
||||
|
||||
FontLoader::FontLoader(mojo::ApplicationImpl* application_impl) {
|
||||
mojo::URLRequestPtr request(mojo::URLRequest::New());
|
||||
request->url = mojo::String::From("mojo:font_service");
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
namespace mojo {
|
||||
class ApplicationImpl;
|
||||
class Shell;
|
||||
}
|
||||
|
||||
namespace font_service {
|
||||
@ -32,6 +33,7 @@ class FontServiceThread;
|
||||
class FontLoader : public SkFontConfigInterface,
|
||||
public internal::MappedFontFile::Observer {
|
||||
public:
|
||||
explicit FontLoader(mojo::Shell* shell);
|
||||
explicit FontLoader(mojo::ApplicationImpl* application_impl);
|
||||
~FontLoader() override;
|
||||
|
||||
|
@ -13,7 +13,7 @@ void InitCoreServicesForContext(mojo::runner::Context* context) {
|
||||
// autogenerated from package manifests.
|
||||
mojo::shell::ApplicationManager* manager = context->application_manager();
|
||||
manager->RegisterApplicationPackageAlias(
|
||||
GURL("mojo:clipboard"), GURL("mojo:core_services"), "Sandboxed Core");
|
||||
GURL("mojo:clipboard"), GURL("mojo:core_services"), "Core");
|
||||
manager->RegisterApplicationPackageAlias(GURL("mojo:filesystem"),
|
||||
GURL("mojo:core_services"), "Files");
|
||||
#if defined(OS_LINUX) && !defined(OS_ANDROID)
|
||||
@ -28,7 +28,7 @@ void InitCoreServicesForContext(mojo::runner::Context* context) {
|
||||
manager->RegisterApplicationPackageAlias(
|
||||
GURL("mojo:network_service"), GURL("mojo:core_services"), "Network");
|
||||
manager->RegisterApplicationPackageAlias(
|
||||
GURL("mojo:resource_provider"), GURL("mojo:core_services"), "Core");
|
||||
GURL("mojo:resource_provider"), GURL("mojo:core_services"), "Files");
|
||||
#endif
|
||||
|
||||
#if defined(USE_AURA)
|
||||
@ -40,9 +40,10 @@ void InitCoreServicesForContext(mojo::runner::Context* context) {
|
||||
manager->RegisterApplicationPackageAlias(
|
||||
GURL("mojo:surfaces_service"), GURL("mojo:core_services"), "Surfaces");
|
||||
manager->RegisterApplicationPackageAlias(
|
||||
GURL("mojo:tracing"), GURL("mojo:core_services"), "Sandboxed Core");
|
||||
GURL("mojo:tracing"), GURL("mojo:core_services"), "Core");
|
||||
manager->RegisterApplicationPackageAlias(GURL("mojo:browser"),
|
||||
GURL("mojo:core_services"), "Core");
|
||||
GURL("mojo:core_services"),
|
||||
"Core");
|
||||
}
|
||||
|
||||
} // namespace mandoline
|
||||
|
@ -53,6 +53,7 @@ source_set("sources") {
|
||||
"//mojo/common:tracing_impl",
|
||||
"//mojo/message_pump",
|
||||
"//mojo/services/tracing:lib",
|
||||
"//third_party/icu",
|
||||
"//third_party/mojo/src/mojo/public/cpp/bindings",
|
||||
"//url",
|
||||
]
|
||||
|
@ -11,6 +11,7 @@
|
||||
#if defined(OS_LINUX) && !defined(OS_ANDROID)
|
||||
#include "base/rand_util.h"
|
||||
#include "base/sys_info.h"
|
||||
#include "third_party/icu/source/i18n/unicode/timezone.h"
|
||||
|
||||
// TODO(erg): Much of this was coppied from zygote_main_linux.cc
|
||||
extern "C" {
|
||||
@ -20,12 +21,13 @@ void __attribute__((visibility("default"))) MojoSandboxWarm() {
|
||||
base::SysInfo::MaxSharedMemorySize();
|
||||
base::SysInfo::NumberOfProcessors();
|
||||
|
||||
// TODO(erg): icu does timezone initialization here.
|
||||
// ICU DateFormat class (used in base/time_format.cc) needs to get the
|
||||
// Olson timezone ID by accessing the zoneinfo files on disk. After
|
||||
// TimeZone::createDefault is called once here, the timezone ID is
|
||||
// cached and there's no more need to access the file system.
|
||||
scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
|
||||
|
||||
// TODO(erg): Perform OpenSSL warmup; it wants access to /dev/urandom.
|
||||
|
||||
// TODO(erg): Initialize SkFontConfigInterface; it has its own odd IPC system
|
||||
// which probably must be ported to mojo.
|
||||
}
|
||||
}
|
||||
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
|
||||
|
@ -53,4 +53,8 @@ source_set("aura") {
|
||||
"//ui/views",
|
||||
"//ui/wm",
|
||||
]
|
||||
|
||||
if (is_linux && !is_android) {
|
||||
deps += [ "//components/font_service/public/cpp" ]
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
include_rules = [
|
||||
"+cc",
|
||||
"-cc/blink",
|
||||
"+components/font_service/public",
|
||||
"+components/gpu",
|
||||
"+components/resource_provider",
|
||||
"+components/view_manager",
|
||||
|
@ -15,6 +15,10 @@
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/base/ui_base_paths.h"
|
||||
|
||||
#if defined(OS_LINUX) && !defined(OS_ANDROID)
|
||||
#include "components/font_service/public/cpp/font_loader.h"
|
||||
#endif
|
||||
|
||||
namespace mandoline {
|
||||
|
||||
namespace {
|
||||
@ -60,6 +64,12 @@ void AuraInit::InitializeResources(mojo::Shell* shell) {
|
||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile(
|
||||
resource_loader.ReleaseFile(kResourceUIPak),
|
||||
ui::SCALE_FACTOR_100P);
|
||||
|
||||
// Initialize the skia font code to go ask fontconfig underneath.
|
||||
#if defined(OS_LINUX) && !defined(OS_ANDROID)
|
||||
SkFontConfigInterface::SetGlobal(new font_service::FontLoader(shell));
|
||||
#endif
|
||||
|
||||
// There is a bunch of static state in gfx::Font, by running this now,
|
||||
// before any other apps load, we ensure all the state is set up.
|
||||
gfx::Font();
|
||||
|
@ -381,7 +381,7 @@ void ApplicationManager::HandleFetchCallback(
|
||||
// TODO(erg): Have a better way of switching the sandbox on. For now, switch
|
||||
// it on hard coded when we're using some of the sandboxable core services.
|
||||
bool start_sandboxed = false;
|
||||
if (app_url == GURL("mojo://core_services/") && qualifier == "Sandboxed Core")
|
||||
if (app_url == GURL("mojo://core_services/") && qualifier == "Core")
|
||||
start_sandboxed = true;
|
||||
else if (app_url == GURL("mojo://html_viewer/"))
|
||||
start_sandboxed = true;
|
||||
|
Reference in New Issue
Block a user