diff --git a/BUILD.gn b/BUILD.gn index 869a6be065e189a4887b0ac2126214a347a671f2..86dae5557a15f82f18dde9e865af169118cd2967 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -126,7 +126,8 @@ if (is_win) { import("//build/config/win/console_app.gni") import("//build/config/win/manifest.gni") } - +import("//services/catalog/public/tools/catalog.gni") +import("//services/service_manager/public/service_manifest.gni") # # Verify required global arguments configured via `gn args`. @@ -744,6 +745,7 @@ static_library("libcef_static") { "//extensions/renderer", "//extensions/utility", "//gpu", + "//gpu/config", "//ipc", "//media", "//media/blink", @@ -786,6 +788,17 @@ static_library("libcef_static") { deps += [ "//third_party/widevine/cdm:widevinecdmadapter" ] } + embedded_mash_service_deps = [ + "//chrome/app/mash:chrome_mash_catalog", + "//chrome/app/mash:embedded_services", + "//mash/common", + "//mash/quick_launch/public/interfaces:constants", + "//services/ui/public/interfaces:constants", + "//chrome/app/mash:chrome_mus_catalog" + ] + + deps += embedded_mash_service_deps + if (is_win) { sources += gypi_paths2.includes_win + [ "libcef/browser/browser_main_win.cc", @@ -1995,3 +2008,131 @@ if (is_mac) { } } } + +cef_packaged_services = [ ":cef_manifest" ] + +service_manifest("cef_manifest") { + source = "cef_manifest.json" +} + +service_manifest("cef_content_packaged_services_manifest_overlay_for_mash") { + source = + "//cef/cef_content_packaged_services_manifest_overlay.json" + packaged_services = cef_packaged_services +} + +service_manifest("cef_content_packaged_services_manifest_overlay") { + source = + "//cef/cef_content_packaged_services_manifest_overlay.json" + packaged_services = cef_packaged_services + packaged_services += [ "//services/ui:manifest" ] +} + +service_manifest("cef_content_browser_manifest_overlay") { + source = "//cef/cef_content_browser_manifest_overlay.json" + packaged_services = [ + "//services/identity:manifest", + "//services/preferences:manifest", + ] +} + +service_manifest("cef_content_gpu_manifest_overlay") { + source = "//cef/cef_content_gpu_manifest_overlay.json" +} + +service_manifest("cef_content_plugin_manifest_overlay") { + source = "//cef/cef_content_plugin_manifest_overlay.json" +} + +service_manifest("cef_content_renderer_manifest_overlay") { + source = "//cef/cef_content_renderer_manifest_overlay.json" +} + +service_manifest("cef_content_utility_manifest_overlay") { + source = "//cef/cef_content_utility_manifest_overlay.json" +} + +group("cef_content_manifest_overlays") { + deps = [ + ":cef_content_browser_manifest_overlay", + ":cef_content_gpu_manifest_overlay", + ":cef_content_packaged_services_manifest_overlay", + ":cef_content_plugin_manifest_overlay", + ":cef_content_renderer_manifest_overlay", + ":cef_content_utility_manifest_overlay", + ] + + if (enable_package_mash_services) { + deps += [ ":cef_content_packaged_services_manifest_overlay_for_mash" ] + } +} + +if (use_aura) { + service_manifest("cef_content_packaged_services_manifest") { + source_manifest = "//content/public/app:packaged_services_manifest" + overlays = [ ":cef_content_packaged_services_manifest_overlay" ] + } + + service_manifest("cef_content_packaged_services_manifest_for_mash") { + source_manifest = "//content/public/app:packaged_services_manifest" + overlays = [ ":cef_content_packaged_services_manifest_overlay_for_mash" ] + } + + service_manifest("cef_content_browser_manifest") { + source_manifest = "//content/public/app:browser_manifest" + overlays = [ ":cef_content_browser_manifest_overlay" ] + } + + service_manifest("cef_content_gpu_manifest") { + source_manifest = "//content/public/app:gpu_manifest" + overlays = [ ":cef_content_gpu_manifest_overlay" ] + } + + service_manifest("cef_content_plugin_manifest") { + source_manifest = "//content/public/app:plugin_manifest" + overlays = [ ":cef_content_plugin_manifest_overlay" ] + } + + service_manifest("cef_content_renderer_manifest") { + source_manifest = "//content/public/app:renderer_manifest" + overlays = [ ":cef_content_renderer_manifest_overlay" ] + } + + service_manifest("cef_content_utility_manifest") { + source_manifest = "//content/public/app:utility_manifest" + overlays = [ ":cef_content_utility_manifest_overlay" ] + } + + group("service_manifests") { + deps = [ + ":cef_content_browser_manifest", + ":cef_content_gpu_manifest", + ":cef_content_plugin_manifest", + ":cef_content_renderer_manifest", + ":cef_content_utility_manifest", + ] + + if (enable_package_mash_services) { + deps += [ ":cef_content_packaged_services_manifest_for_mash" ] + } + } + + cef_embedded_services = [ + ":cef_content_browser_manifest", + ":cef_content_gpu_manifest", + ":cef_content_plugin_manifest", + ":cef_content_renderer_manifest", + ":cef_content_utility_manifest", + ] + + catalog("catalog") { + embedded_services = cef_embedded_services + + [ ":cef_content_packaged_services_manifest" ] + } + + catalog("catalog_for_mash") { + embedded_services = + cef_embedded_services + + [ ":cef_content_packaged_services_manifest_for_mash" ] + } +} diff --git a/cef_content_browser_manifest_overlay.json b/cef_content_browser_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..3d384b3ea8181d328a3aeff0fcac4430c0f8e275 --- /dev/null +++ b/cef_content_browser_manifest_overlay.json @@ -0,0 +1,88 @@ +{ + "name": "content_browser", + "display_name": "CEF", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "renderer": [ + "autofill::mojom::AutofillDriver", + "autofill::mojom::PasswordManagerDriver", + "blink::mojom::BudgetService", + "extensions::StashService", + "metrics::mojom::LeakDetector", + "mojom::ModuleEventSink", + "rappor::mojom::RapporRecorder", + "safe_browsing::mojom::SafeBrowsing", + "spellcheck::mojom::SpellCheckHost", + "spellcheck::mojom::SpellCheckPanelHost", + "translate::mojom::ContentTranslateDriver" + ], + "url_keyed_metrics": [ + "ukm::mojom::UkmRecorderInterface" + ], + "gpu": [ + "metrics::mojom::CallStackProfileCollector" + ], + "ime:ime_driver": [], + "memlog_client": [ + "profiling::mojom::MemlogClient" + ] + }, + "requires": { + "accessibility_autoclick": [ "ash:autoclick" ], + "ash": [ "ash", "display" ], + // Only used in classic ash case. + "ash_pref_connector": [ "pref_connector" ], + // Only used in classic ash case. + "content_browser": [ "memlog_client" ], + "device": [ "device:fingerprint" ], + "identity": [ "identity_manager" ], + "nacl_broker": [ "browser" ], + "nacl_loader": [ "browser" ], + "profiling": [ "memlog" ], + "preferences": [ "pref_client", "pref_control" ], + "ui": [ + "display_controller", + "external_window_tree_factory", + "ime_registrar", + "input_device_controller", + "window_manager", + "window_tree_host_factory_registrar" + ] + } + }, + "navigation:frame": { + "provides": { + "renderer": [ + "autofill::mojom::AutofillDriver", + "autofill::mojom::PasswordManagerDriver", + "blink::mojom::BudgetService", + "blink::mojom::InstalledAppProvider", + "blink::mojom::MediaDownloadInProductHelp", + "blink::mojom::ShareService", + "blink::mojom::TextSuggestionHost", + "bluetooth::mojom::AdapterFactory", + "contextual_search::mojom::ContextualSearchJsApiService", + "device::mojom::UsbChooserService", + "device::mojom::UsbDeviceManager", + "dom_distiller::mojom::DistillabilityService", + "dom_distiller::mojom::DistillerJavaScriptService", + "extensions::KeepAlive", + "extensions::mime_handler::MimeHandlerService", + "extensions::mojom::InlineInstall", + "media_router::mojom::MediaRouter", + "page_load_metrics::mojom::PageLoadMetrics", + "password_manager::mojom::CredentialManager", + "translate::mojom::ContentTranslateDriver", + + // TODO(beng): These should be moved to a separate capability. + "media::mojom::MediaEngagementScoreDetailsProvider", + "mojom::OmniboxPageHandler", + "mojom::PluginsPageHandler", + "mojom::SiteEngagementDetailsProvider", + "mojom::UsbInternalsPageHandler" + ] + } + } + } +} diff --git a/cef_content_gpu_manifest_overlay.json b/cef_content_gpu_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..b3ccf59eac798354ec8f8b89a1e62edbe6de1a58 --- /dev/null +++ b/cef_content_gpu_manifest_overlay.json @@ -0,0 +1,16 @@ +{ + "name": "content_gpu", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "browser": [ + "arc::mojom::VideoDecodeAccelerator", + "arc::mojom::VideoDecodeClient", + "arc::mojom::VideoEncodeAccelerator", + "arc::mojom::VideoEncodeClient", + "profiling::mojom::MemlogClient" + ] + } + } + } +} diff --git a/cef_content_packaged_services_manifest_overlay.json b/cef_content_packaged_services_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..483adbb4cd2dd30ad148d1f4872e0c85492e4be5 --- /dev/null +++ b/cef_content_packaged_services_manifest_overlay.json @@ -0,0 +1,5 @@ +{ + "name": "content_packaged_services", + "display_name": "CEF Packaged Services", + "interface_provider_specs": {} +} diff --git a/cef_content_plugin_manifest_overlay.json b/cef_content_plugin_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..c47eb05bb7ed85b101cc06cdfa312047efd83575 --- /dev/null +++ b/cef_content_plugin_manifest_overlay.json @@ -0,0 +1,11 @@ +{ + "name": "content_plugin", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "browser": [ + ] + } + } + } +} diff --git a/cef_content_renderer_manifest_overlay.json b/cef_content_renderer_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..8d440d7473f9365fc16a908c963fea8df275ce08 --- /dev/null +++ b/cef_content_renderer_manifest_overlay.json @@ -0,0 +1,28 @@ +{ + "display_name": "CEF Render Process", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "browser": [ + "spellcheck::mojom::SpellChecker", + "profiling::mojom::MemlogClient" + ] + }, + "requires": { + } + }, + "navigation:frame": { + "provides": { + "browser": [ + "autofill::mojom::AutofillAgent", + "autofill::mojom::PasswordAutofillAgent", + "autofill::mojom::PasswordGenerationAgent", + "blink::mojom::document_metadata::CopylessPaste", + "contextual_search::mojom::OverlayPageNotifierService", + "dom_distiller::mojom::DistillerPageNotifierService", + "spellcheck::mojom::SpellCheckPanel" + ] + } + } + } +} diff --git a/cef_content_utility_manifest_overlay.json b/cef_content_utility_manifest_overlay.json new file mode 100644 index 0000000000000000000000000000000000000000..b402a53565de5b31acbfe9c976c6acf455fafbbd --- /dev/null +++ b/cef_content_utility_manifest_overlay.json @@ -0,0 +1,20 @@ +{ + "name": "content_utility", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "browser": [ + "extensions::mojom::ExtensionUnpacker", + "extensions::mojom::ManifestParser", + "extensions::mojom::MediaParser", + "extensions::mojom::RemovableStorageWriter", + "extensions::mojom::WiFiCredentialsGetter", + "net::interfaces::ProxyResolverFactory", + "payments::mojom::PaymentManifestParser", + "profiling::mojom::MemlogClient", + "safe_json::mojom::SafeJsonParser" + ] + } + } + } +} diff --git a/cef_manifest.json b/cef_manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..d4dc2b056d29c83a2bf95a5298d500ad4cd79805 --- /dev/null +++ b/cef_manifest.json @@ -0,0 +1,21 @@ +{ + "name": "CEF", + "display_name": "CEF", + "interface_provider_specs": { + "service_manager:connector": { + "provides": { + "mash:launchable": [ + "mash::mojom::Launchable" + ], + "renderer": [ + "startup_metric_utils::mojom::StartupMetricHost" + ] + }, + "requires": { + "service_manager": [ + "service_manager:all_users" + ] + } + } + } +} diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index c9f165729f34cb8b0eca6d8d350e83ee063ff677..468ec861e057230a8f8ad5a878fe0d73b5ede560 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -44,9 +44,9 @@ typedef struct _XDisplay XDisplay; // Handle types. #if defined(USE_AURA) #define cef_cursor_handle_t void* -#define cef_event_handle_t XEvent* -#define cef_window_handle_t unsigned long -#elif +#define cef_event_handle_t void* +#define cef_window_handle_t int +#else #define cef_cursor_handle_t unsigned long #define cef_event_handle_t XEvent* #define cef_window_handle_t unsigned long diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index 96ea43f462b25a17c9c119b404a907e411aa31e8..53630521f2a99a64d5cba737ed3d8a031c88ce32 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -41,8 +41,13 @@ #include "ui/base/resource/resource_bundle.h" #if defined(USE_AURA) +#include "content/public/browser/browser_thread.h" +#include "content/public/common/service_manager_connection.h" +#include "services/service_manager/public/cpp/connector.h" +#include "services/service_manager/runner/common/client_util.h" #include "ui/aura/env.h" #include "ui/display/screen.h" +#include "ui/views/mus/mus_client.h" #include "ui/views/test/desktop_test_views_delegate.h" #include "ui/views/widget/desktop_aura/desktop_screen.h" #include "ui/wm/core/wm_state.h" @@ -224,3 +229,21 @@ void CefBrowserMainParts::PostDestroyThreads() { delete views::ViewsDelegate::GetInstance(); #endif } + +void CefBrowserMainParts::ServiceManagerConnectionStarted( + content::ServiceManagerConnection* connection) { + DCHECK(connection); +#if defined(USE_AURA) + if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL) + return; + + // WMState is owned as a member, so don't have MusClient create it. + const bool create_wm_state = false; + mus_client_ = base::MakeUnique<views::MusClient>( + connection->GetConnector(), service_manager::Identity(), + content::BrowserThread::GetTaskRunnerForThread( + content::BrowserThread::IO), + create_wm_state); +#endif // defined(USE_AURA) +} + diff --git a/libcef/browser/browser_main.h b/libcef/browser/browser_main.h index af9e865c91b7fe69b49f394018ca8be9fbd97094..722943cd8b5b0ce4bf3b167bbe8f138fa24af3be 100644 --- a/libcef/browser/browser_main.h +++ b/libcef/browser/browser_main.h @@ -31,6 +31,9 @@ class ExtensionsClient; } // namespace extensions #if defined(USE_AURA) +namespace views { +class MusClient; +} namespace wm { class WMState; } @@ -51,6 +54,8 @@ class CefBrowserMainParts : public content::BrowserMainParts { void PreMainMessageLoopRun() override; void PostMainMessageLoopRun() override; void PostDestroyThreads() override; + void ServiceManagerConnectionStarted( + content::ServiceManagerConnection* connection) override; CefRefPtr<CefRequestContextImpl> request_context() const { return global_request_context_; @@ -72,6 +77,7 @@ class CefBrowserMainParts : public content::BrowserMainParts { #if defined(USE_AURA) std::unique_ptr<wm::WMState> wm_state_; + std::unique_ptr<views::MusClient> mus_client_; #endif DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index a24a5a96e22eccf24a255e3c1955e666b7fffaab..49f3d470f5fe7e2dcb3a0125949fbd883635714b 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -43,6 +43,7 @@ #include "base/json/json_reader.h" #include "base/path_service.h" #include "cef/grit/cef_resources.h" +#include "chrome/browser/embedded_ui_service_info_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/spellchecker/spell_check_host_impl.h" #include "chrome/common/chrome_switches.h" @@ -81,6 +82,9 @@ #include "extensions/common/switches.h" #include "net/ssl/ssl_cert_request_info.h" #include "ppapi/host/ppapi_host.h" +#include "services/ui/common/image_cursors_set.h" +#include "services/ui/public/interfaces/constants.mojom.h" +#include "services/ui/service.h" #include "storage/browser/quota/quota_settings.h" #include "third_party/WebKit/public/web/WebWindowFeatures.h" #include "ui/base/resource/resource_bundle.h" @@ -107,6 +111,13 @@ #include "sandbox/win/src/sandbox_policy.h" #endif +#if defined(USE_AURA) +#include "services/service_manager/runner/common/client_util.h" +#include "services/ui/public/cpp/gpu/gpu.h" +#include "ui/aura/mus/window_tree_client.h" +#include "ui/views/mus/mus_client.h" +#endif + namespace { class CefQuotaCallbackImpl : public CefRequestCallback { @@ -603,12 +614,27 @@ void CefContentBrowserClient::RegisterOutOfProcessServices( std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay( base::StringPiece name) { int id = -1; + /* if (name == content::mojom::kBrowserServiceName) id = IDR_CEF_BROWSER_MANIFEST_OVERLAY; else if (name == content::mojom::kRendererServiceName) id = IDR_CEF_RENDERER_MANIFEST_OVERLAY; else if (name == content::mojom::kUtilityServiceName) id = IDR_CEF_UTILITY_MANIFEST_OVERLAY; + */ + + if (name == content::mojom::kBrowserServiceName) + id = IDR_CEF_CONTENT_BROWSER_MANIFEST_OVERLAY; + else if (name == content::mojom::kGpuServiceName) + id = IDR_CEF_CONTENT_GPU_MANIFEST_OVERLAY; + else if (name == content::mojom::kPackagedServicesServiceName) + id = IDR_CEF_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY; + else if (name == content::mojom::kPluginServiceName) + id = IDR_CEF_CONTENT_PLUGIN_MANIFEST_OVERLAY; + else if (name == content::mojom::kRendererServiceName) + id = IDR_CEF_CONTENT_RENDERER_MANIFEST_OVERLAY; + else if (name == content::mojom::kUtilityServiceName) + id = IDR_CEF_CONTENT_UTILITY_MANIFEST_OVERLAY; if (id == -1) return nullptr; @@ -893,6 +919,16 @@ void CefContentBrowserClient::DidCreatePpapiPlugin( new CefBrowserPepperHostFactory(browser_host))); } +gpu::GpuChannelEstablishFactory* +CefContentBrowserClient::GetGpuChannelEstablishFactory() { +#if defined(USE_AURA) + if (views::MusClient::Exists()) { + return views::MusClient::Get()->window_tree_client()->gpu(); + } +#endif + return nullptr; +} + content::DevToolsManagerDelegate* CefContentBrowserClient::GetDevToolsManagerDelegate() { return new CefDevToolsManagerDelegate(); @@ -992,6 +1028,14 @@ void CefContentBrowserClient::ExposeInterfacesToRenderer( } } +void CefContentBrowserClient::RegisterInProcessServices( + StaticServiceMap* services) { + image_cursors_set_ = base::MakeUnique<ui::ImageCursorsSet>(); + service_manager::EmbeddedServiceInfo info = + CreateEmbeddedUIServiceInfo(image_cursors_set_->GetWeakPtr()); + services->insert(std::make_pair(ui::mojom::kServiceName, info)); +} + void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) { // Register as a Web-safe scheme so that requests for the scheme from a // render process will be allowed in resource_dispatcher_host_impl.cc diff --git a/libcef/browser/content_browser_client.h b/libcef/browser/content_browser_client.h index 270be672f40d2d055d85c113ec8f615f1bcbf09e..864d5db9e902fe3fdf18aadf92412b297b454144 100644 --- a/libcef/browser/content_browser_client.h +++ b/libcef/browser/content_browser_client.h @@ -32,6 +32,10 @@ namespace extensions { class Extension; } +namespace ui { + class ImageCursorsSet; +} + class CefContentBrowserClient : public content::ContentBrowserClient { public: CefContentBrowserClient(); @@ -98,6 +102,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override; std::string GetDefaultDownloadName() override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; + gpu::GpuChannelEstablishFactory* GetGpuChannelEstablishFactory() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; std::vector<std::unique_ptr<content::NavigationThrottle>> CreateThrottlesForNavigation( @@ -120,6 +125,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient { content::AssociatedInterfaceRegistry* associated_registry, content::RenderProcessHost* render_process_host) override; + void RegisterInProcessServices(StaticServiceMap* services) override; + // Perform browser process registration for the custom scheme. void RegisterCustomScheme(const std::string& scheme); @@ -131,6 +138,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { const extensions::Extension* GetExtension( content::SiteInstance* site_instance); + std::unique_ptr<ui::ImageCursorsSet> image_cursors_set_; CefBrowserMainParts* browser_main_parts_; std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_; diff --git a/libcef/browser/context.cc b/libcef/browser/context.cc index d84c8a346e86e027b45211aa1ffce5382000d58f..e79c65765b4e6bf37b366105ec9d6a41998d0e74 100644 --- a/libcef/browser/context.cc +++ b/libcef/browser/context.cc @@ -30,6 +30,8 @@ #include "content/public/browser/render_process_host.h" #include "content/public/common/content_switches.h" #include "services/service_manager/embedder/main.h" +#include "services/service_manager/runner/common/client_util.h" +#include "services/service_manager/runner/common/switches.h" #include "ui/base/ui_base_switches.h" #if defined(OS_WIN) @@ -160,27 +162,22 @@ int CefExecuteProcess(const CefMainArgs& args, InitCrashReporter(); #endif - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); -#if defined(OS_WIN) - command_line.ParseFromString(::GetCommandLineW()); -#else - command_line.InitFromArgv(args.argc, args.argv); -#endif + base::CommandLine::Init(args.argc, args.argv); + const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); // Wait for the debugger as early in process initialization as possible. - if (command_line.HasSwitch(switches::kWaitForDebugger)) + if (command_line->HasSwitch(switches::kWaitForDebugger)) base::debug::WaitForDebugger(60, true); // If no process type is specified then it represents the browser process and // we do nothing. std::string process_type = - command_line.GetSwitchValueASCII(switches::kProcessType); + command_line->GetSwitchValueASCII(switches::kProcessType); if (process_type.empty()) return -1; - #if defined(OS_MACOSX) || defined(OS_WIN) if (process_type == crash_reporter::switches::kCrashpadHandler) - return RunAsCrashpadHandler(command_line); + return RunAsCrashpadHandler(*command_line); #endif CefMainDelegate main_delegate(application); @@ -204,6 +201,11 @@ int CefExecuteProcess(const CefMainArgs& args, params.argc = args.argc; params.argv = const_cast<const char**>(args.argv); +#if defined(USE_AURA) + if (command_line->HasSwitch("mus")) + params.env_mode = aura::Env::Mode::MUS; +#endif + return content::ContentMain(params); #endif } @@ -376,6 +378,13 @@ bool CefContext::Initialize(const CefMainArgs& args, params.argv = const_cast<const char**>(args.argv); #endif + auto command_line = base::CommandLine::ForCurrentProcess(); + +#if defined(USE_AURA) + if (command_line->HasSwitch("mus")) + params.env_mode = aura::Env::Mode::MUS; +#endif + sm_main_delegate_.reset( new content::ContentServiceManagerMainDelegate(params)); sm_main_params_.reset( diff --git a/libcef/browser/native/browser_platform_delegate_native_linux.cc b/libcef/browser/native/browser_platform_delegate_native_linux.cc index 80f09ae1666356f031892262e30a4d5403831b14..e49c4929af2240df3c30ae9cb1a5839be0456c31 100644 --- a/libcef/browser/native/browser_platform_delegate_native_linux.cc +++ b/libcef/browser/native/browser_platform_delegate_native_linux.cc @@ -82,6 +82,12 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() { window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect); window_info_.window = window_x11_->xwindow(); + StubPlatformWindowDelegate window_delegate_; + window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(&window_delegate_, rect); + + window_info_.window = window_delegate_.widget(); +*/ + host_window_created_ = true; // Add a reference that will be released in BrowserDestroyed(). diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 92d32707240e92180f06c073f7a4614f4dd8830b..eb4cec16de463624528959b16e616b1796f1b453 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -11,6 +11,7 @@ #include "ui/base/hit_test.h" #include "ui/views/widget/widget.h" #include "ui/views/window/native_frame_view.h" +#include "ui/views/window/custom_frame_view.h" #if defined(OS_WIN) #include "ui/display/screen.h" @@ -382,9 +383,19 @@ views::NonClientFrameView* CefWindowView::CreateNonClientFrameView( // NativeFrameView by default. Extend that type. return new NativeFrameViewEx(widget, this); } else { + // FIXME(andrunko): here it creates a window with decoration but input doesn't work + //views::CustomFrameView* custom_frame_view = new views::CustomFrameView; + //custom_frame_view->Init(widget); + //return custom_frame_view; + + // FIXME(andrunko): let's return NULL so that the default for this platform + // is created + // For /mus/ the default doesn't support window decoration - specialize it + // to support window decoration + // Widget::CreateNonClientFrameView() returns CustomFrameView by default. // Need to extend CustomFrameView on this platform. - NOTREACHED() << "Platform does not use NativeFrameView"; + //NOTREACHED() << "Platform does not use NativeFrameView"; } return nullptr; diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index 8e451b6205a51d7d3777d373d1e5bffe4790dd81..70191b6c6566ab77999554b4723c7753ae4662ad 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -31,9 +31,11 @@ #include "content/public/browser/render_process_host.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" +#include "content/public/common/service_names.mojom.h" #include "extensions/common/constants.h" #include "ipc/ipc_features.h" #include "pdf/pdf.h" +#include "services/service_manager/embedder/switches.h" #include "ui/base/layout.h" #include "ui/base/material_design/material_design_controller.h" #include "ui/base/resource/resource_bundle.h" @@ -65,6 +67,15 @@ #include "base/nix/xdg_util.h" #endif +#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) +#include "chrome/app/mash/chrome_mash_catalog.h" +#include "chrome/app/mash/embedded_services.h" +#include "mash/common/config.h" // nogncheck +#include "mash/quick_launch/public/interfaces/constants.mojom.h" // nogncheck +#include "services/ui/public/interfaces/constants.mojom.h" // nogncheck +#include "chrome/app/mash/chrome_mus_catalog.h" +#endif + namespace { #if defined(OS_MACOSX) @@ -493,6 +504,51 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) { return false; } +service_manager::ProcessType CefMainDelegate::OverrideProcessType() { + const auto& command_line = *base::CommandLine::ForCurrentProcess(); + if (command_line.GetSwitchValueASCII(switches::kProcessType) == + service_manager::switches::kProcessTypeService) { + // Don't mess with embedded service command lines. + return service_manager::ProcessType::kDefault; + } + +#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + if (command_line.HasSwitch(switches::kMash)) { + return service_manager::ProcessType::kServiceManager; + } +#endif + + return service_manager::ProcessType::kDefault; +} + +std::unique_ptr<base::Value> CefMainDelegate::CreateServiceCatalog() { +#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + const auto& command_line = *base::CommandLine::ForCurrentProcess(); +#if defined(OS_CHROMEOS) || defined(OS_LINUX) + if (command_line.HasSwitch(switches::kMus)) + return CreateChromeMusCatalog(); +#endif // defined(OS_CHROMEOS) + if (command_line.HasSwitch(switches::kMash)) + return CreateChromeMashCatalog(); +#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + return nullptr; +} + +void CefMainDelegate::AdjustServiceProcessCommandLine( + const service_manager::Identity& identity, + base::CommandLine* command_line) { + if (identity.name() == content::mojom::kPackagedServicesServiceName) { + // Ensure the browser process doesn't inherit mash or mus flags, since these + // flags would cause the process to run as a Service Manager instead. + base::CommandLine::SwitchMap switches = command_line->GetSwitches(); + switches.erase("mash"); + switches.erase("mus"); + *command_line = base::CommandLine(command_line->GetProgram()); + for (const auto& sw : switches) + command_line->AppendSwitchNative(sw.first, sw.second); + } +} + void CefMainDelegate::PreSandboxStartup() { const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -602,6 +658,46 @@ content::ContentUtilityClient* CefMainDelegate::CreateContentUtilityClient() { return utility_client_.get(); } +void CefMainDelegate::OnServiceManagerInitialized( + const base::Closure& quit_closure, + service_manager::BackgroundServiceManager* service_manager) { +/* +#if defined(OS_POSIX) + // Quit the main process in response to shutdown signals (like SIGTERM). + // These signals are used by Linux distributions to request clean shutdown. + // On Chrome OS the SIGTERM signal is sent by session_manager. + InstallShutdownSignalHandlers(quit_closure, + base::ThreadTaskRunnerHandle::Get()); +#endif +*/ + +#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + // Start services that we know we want to launch on startup (UI service, + // window manager, quick launch app). + service_manager->StartService( + service_manager::Identity(ui::mojom::kServiceName)); + service_manager->StartService( + service_manager::Identity(content::mojom::kPackagedServicesServiceName)); + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kMash)) { + service_manager->StartService( + service_manager::Identity(mash::common::GetWindowManagerServiceName())); + service_manager->StartService( + service_manager::Identity(mash::quick_launch::mojom::kServiceName)); + } +#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) +} + + +std::unique_ptr<service_manager::Service> +CefMainDelegate::CreateEmbeddedService(const std::string& service_name) { +#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + auto mash_service = CreateEmbeddedMashService(service_name); + if (mash_service) + return mash_service; +#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) + return nullptr; +} + void CefMainDelegate::ShutdownBrowser() { if (browser_runner_.get()) { browser_runner_->Shutdown(); diff --git a/libcef/common/main_delegate.h b/libcef/common/main_delegate.h index 3e188734b5a0d7ebb5e8ed5b9f9604fb1ededa60..3e4f350f76d61378e2f82d814bac565be656415b 100644 --- a/libcef/common/main_delegate.h +++ b/libcef/common/main_delegate.h @@ -32,6 +32,12 @@ class CefMainDelegate : public content::ContentMainDelegate { explicit CefMainDelegate(CefRefPtr<CefApp> application); ~CefMainDelegate() override; + service_manager::ProcessType OverrideProcessType() override; + std::unique_ptr<base::Value> CreateServiceCatalog() override; + + void AdjustServiceProcessCommandLine( + const service_manager::Identity& identity, + base::CommandLine* command_line) override; bool BasicStartupComplete(int* exit_code) override; void PreSandboxStartup() override; void SandboxInitialized(const std::string& process_type) override; @@ -46,6 +52,12 @@ class CefMainDelegate : public content::ContentMainDelegate { content::ContentRendererClient* CreateContentRendererClient() override; content::ContentUtilityClient* CreateContentUtilityClient() override; + void OnServiceManagerInitialized( + const base::Closure& quit_closure, + service_manager::BackgroundServiceManager* service_manager) override; + std::unique_ptr<service_manager::Service> CreateEmbeddedService( + const std::string& service_name) override; + // Shut down the browser runner. void ShutdownBrowser(); diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 6f29e43e20536147b260aaf5d4563856a7388852..d2c7558c2bf8b54145c20ddadeecce0f7b93e97d 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -405,6 +405,14 @@ void CefContentRendererClient::RenderThreadStarted() { blink::WebPrerenderingSupport::Initialize(new CefPrerenderingSupport()); + // Retrieve the new render thread information synchronously. + CefProcessHostMsg_GetNewRenderThreadInfo_Params params; + // FIXME(andrunko): this blocks forever when starting RendererThread + //thread->Send(new CefProcessHostMsg_GetNewRenderThreadInfo(¶ms)); + + // Cross-origin entries need to be added after WebKit is initialized. + cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries; + #if defined(OS_MACOSX) { base::ScopedCFTypeRef<CFStringRef> key( diff --git a/libcef/resources/cef_resources.grd b/libcef/resources/cef_resources.grd index 166a145d54b8d497318c1f67840294e07640788b..06fe8551dced305a1f46b4fa4c3d965e78a46ee9 100644 --- a/libcef/resources/cef_resources.grd +++ b/libcef/resources/cef_resources.grd @@ -14,10 +14,20 @@ <include name="IDR_CEF_VERSION_HTML" file="about_version.html" type="BINDATA" /> <!-- Extension features supported by CEF. --> - <include name="IDR_CEF_EXTENSION_API_FEATURES" file="..\common\extensions\api\_api_features.json" type="BINDATA" /> + <!-- <include name="IDR_CEF_BROWSER_MANIFEST_OVERLAY" file="..\common\extensions\api\browser_manifest_overlay.json" type="BINDATA" /> <include name="IDR_CEF_RENDERER_MANIFEST_OVERLAY" file="..\common\extensions\api\renderer_manifest_overlay.json" type="BINDATA" /> <include name="IDR_CEF_UTILITY_MANIFEST_OVERLAY" file="..\common\extensions\api\utility_manifest_overlay.json" type="BINDATA" /> + --> + + <include name="IDR_CEF_EXTENSION_API_FEATURES" file="..\common\extensions\api\_api_features.json" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_BROWSER_MANIFEST_OVERLAY" file="gen\cef\cef_content_browser_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_GPU_MANIFEST_OVERLAY" file="gen\cef\cef_content_gpu_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_PLUGIN_MANIFEST_OVERLAY" file="gen\cef\cef_content_plugin_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="gen\cef\cef_content_packaged_services_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_RENDERER_MANIFEST_OVERLAY" file="gen\cef\cef_content_renderer_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + <include name="IDR_CEF_CONTENT_UTILITY_MANIFEST_OVERLAY" file="gen\cef\cef_content_utility_manifest_overlay.json" use_base_dir="false" type="BINDATA" /> + </includes> </release> </grit> diff --git a/tests/cefsimple/cefsimple_linux.cc b/tests/cefsimple/cefsimple_linux.cc index cf23772fce7b375fac4648a8d30fc381f502cab9..d3d40513c2746ec6b60039f24ddfbf451957e455 100644 --- a/tests/cefsimple/cefsimple_linux.cc +++ b/tests/cefsimple/cefsimple_linux.cc @@ -34,12 +34,25 @@ int main(int argc, char* argv[]) { // Provide CEF with command-line arguments. CefMainArgs main_args(argc, argv); + std::string args; + for (int i = 0; i < argc; ++i) { + args += argv[i]; + args += " "; + } + fprintf(stderr, "Executing SimpleApp: %s\n", args.c_str()); + + // SimpleApp implements application-level callbacks for the browser process. + // It will create the first browser instance in OnContextInitialized() after + // CEF has initialized. + CefRefPtr<SimpleApp> app(new SimpleApp); + // CEF applications have multiple sub-processes (render, plugin, GPU, etc) // that share the same executable. This function checks the command-line and, // if this is a sub-process, executes the appropriate logic. - int exit_code = CefExecuteProcess(main_args, NULL, NULL); + int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0) { // The sub-process has completed so return here. + fprintf(stderr, "Early quitting SimpleApp: %s exit_code=%d\n", args.c_str(), exit_code); return exit_code; } @@ -53,14 +66,13 @@ int main(int argc, char* argv[]) { // Specify CEF global settings here. CefSettings settings; - // SimpleApp implements application-level callbacks for the browser process. - // It will create the first browser instance in OnContextInitialized() after - // CEF has initialized. - CefRefPtr<SimpleApp> app(new SimpleApp); + fprintf(stderr, "Creating SimpleApp: %s exit_code=%d\n", args.c_str(), exit_code); + fprintf(stderr, "Initializing Cef for SimpleApp: %s exit_code=%d\n", args.c_str(), exit_code); // Initialize CEF for the browser process. CefInitialize(main_args, settings, app.get(), NULL); + fprintf(stderr, "Entering mainloop for SimpleApp: %s\n", args.c_str()); // Run the CEF message loop. This will block until CefQuitMessageLoop() is // called. CefRunMessageLoop(); @@ -68,5 +80,7 @@ int main(int argc, char* argv[]) { // Shut down CEF. CefShutdown(); + fprintf(stderr, "Quitting SimpleApp: %s\n", args.c_str()); + return 0; } diff --git a/tests/cefsimple/simple_app.cc b/tests/cefsimple/simple_app.cc index 5b0a7ef541a9804908278722061780010d76ffec..e50cb78d8ab85e2756df17acfa59af35fa57ddea 100644 --- a/tests/cefsimple/simple_app.cc +++ b/tests/cefsimple/simple_app.cc @@ -85,6 +85,7 @@ void SimpleApp::OnContextInitialized() { url = "http://www.google.com"; if (use_views) { + fprintf(stderr, "Starting SimpleApp views mode for url=%s\n", url.c_str()); // Create the BrowserView. CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView( handler, url, browser_settings, NULL, NULL); @@ -94,6 +95,7 @@ void SimpleApp::OnContextInitialized() { } else { // Information used when creating the native window. CefWindowInfo window_info; + fprintf(stderr, "Starting SimpleApp browser mode for url=%s\n", url.c_str()); #if defined(OS_WIN) // On Windows we need to specify certain flags that will be passed to