Commit 1165a210 by André Magalhães Committed by Gustavo Noronha

MUS support

To test use 'cefsimple --mus --use-views --url=<url>'

Note that the CEF path not using ui::views/aura doesn't work (
see tests/cefsimple/simple_app.cc)
parent f069dca2
...@@ -126,7 +126,8 @@ if (is_win) { ...@@ -126,7 +126,8 @@ if (is_win) {
import("//build/config/win/console_app.gni") import("//build/config/win/console_app.gni")
import("//build/config/win/manifest.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`. # Verify required global arguments configured via `gn args`.
...@@ -744,6 +745,7 @@ static_library("libcef_static") { ...@@ -744,6 +745,7 @@ static_library("libcef_static") {
"//extensions/renderer", "//extensions/renderer",
"//extensions/utility", "//extensions/utility",
"//gpu", "//gpu",
"//gpu/config",
"//ipc", "//ipc",
"//media", "//media",
"//media/blink", "//media/blink",
...@@ -786,6 +788,17 @@ static_library("libcef_static") { ...@@ -786,6 +788,17 @@ static_library("libcef_static") {
deps += [ "//third_party/widevine/cdm:widevinecdmadapter" ] 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) { if (is_win) {
sources += gypi_paths2.includes_win + [ sources += gypi_paths2.includes_win + [
"libcef/browser/browser_main_win.cc", "libcef/browser/browser_main_win.cc",
...@@ -1995,3 +2008,131 @@ if (is_mac) { ...@@ -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" ]
}
}
{
"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"
]
}
}
}
}
{
"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"
]
}
}
}
}
{
"name": "content_packaged_services",
"display_name": "CEF Packaged Services",
"interface_provider_specs": {}
}
{
"name": "content_plugin",
"interface_provider_specs": {
"service_manager:connector": {
"provides": {
"browser": [
]
}
}
}
}
{
"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"
]
}
}
}
}
{
"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"
]
}
}
}
}
{
"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"
]
}
}
}
}
...@@ -44,9 +44,9 @@ typedef struct _XDisplay XDisplay; ...@@ -44,9 +44,9 @@ typedef struct _XDisplay XDisplay;
// Handle types. // Handle types.
#if defined(USE_AURA) #if defined(USE_AURA)
#define cef_cursor_handle_t void* #define cef_cursor_handle_t void*
#define cef_event_handle_t XEvent* #define cef_event_handle_t void*
#define cef_window_handle_t unsigned long #define cef_window_handle_t int
#elif #else
#define cef_cursor_handle_t unsigned long #define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent* #define cef_event_handle_t XEvent*
#define cef_window_handle_t unsigned long #define cef_window_handle_t unsigned long
......
...@@ -41,8 +41,13 @@ ...@@ -41,8 +41,13 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(USE_AURA) #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/aura/env.h"
#include "ui/display/screen.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/test/desktop_test_views_delegate.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h" #include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/wm/core/wm_state.h" #include "ui/wm/core/wm_state.h"
...@@ -224,3 +229,21 @@ void CefBrowserMainParts::PostDestroyThreads() { ...@@ -224,3 +229,21 @@ void CefBrowserMainParts::PostDestroyThreads() {
delete views::ViewsDelegate::GetInstance(); delete views::ViewsDelegate::GetInstance();
#endif #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)
}
...@@ -31,6 +31,9 @@ class ExtensionsClient; ...@@ -31,6 +31,9 @@ class ExtensionsClient;
} // namespace extensions } // namespace extensions
#if defined(USE_AURA) #if defined(USE_AURA)
namespace views {
class MusClient;
}
namespace wm { namespace wm {
class WMState; class WMState;
} }
...@@ -51,6 +54,8 @@ class CefBrowserMainParts : public content::BrowserMainParts { ...@@ -51,6 +54,8 @@ class CefBrowserMainParts : public content::BrowserMainParts {
void PreMainMessageLoopRun() override; void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override; void PostMainMessageLoopRun() override;
void PostDestroyThreads() override; void PostDestroyThreads() override;
void ServiceManagerConnectionStarted(
content::ServiceManagerConnection* connection) override;
CefRefPtr<CefRequestContextImpl> request_context() const { CefRefPtr<CefRequestContextImpl> request_context() const {
return global_request_context_; return global_request_context_;
...@@ -72,6 +77,7 @@ class CefBrowserMainParts : public content::BrowserMainParts { ...@@ -72,6 +77,7 @@ class CefBrowserMainParts : public content::BrowserMainParts {
#if defined(USE_AURA) #if defined(USE_AURA)
std::unique_ptr<wm::WMState> wm_state_; std::unique_ptr<wm::WMState> wm_state_;
std::unique_ptr<views::MusClient> mus_client_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "cef/grit/cef_resources.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/profiles/profile.h"
#include "chrome/browser/spellchecker/spell_check_host_impl.h" #include "chrome/browser/spellchecker/spell_check_host_impl.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -81,6 +82,9 @@ ...@@ -81,6 +82,9 @@
#include "extensions/common/switches.h" #include "extensions/common/switches.h"
#include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.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 "storage/browser/quota/quota_settings.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h" #include "third_party/WebKit/public/web/WebWindowFeatures.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
...@@ -107,6 +111,13 @@ ...@@ -107,6 +111,13 @@
#include "sandbox/win/src/sandbox_policy.h" #include "sandbox/win/src/sandbox_policy.h"
#endif #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 { namespace {
class CefQuotaCallbackImpl : public CefRequestCallback { class CefQuotaCallbackImpl : public CefRequestCallback {
...@@ -603,12 +614,27 @@ void CefContentBrowserClient::RegisterOutOfProcessServices( ...@@ -603,12 +614,27 @@ void CefContentBrowserClient::RegisterOutOfProcessServices(
std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay( std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay(
base::StringPiece name) { base::StringPiece name) {
int id = -1; int id = -1;
/*
if (name == content::mojom::kBrowserServiceName) if (name == content::mojom::kBrowserServiceName)
id = IDR_CEF_BROWSER_MANIFEST_OVERLAY; id = IDR_CEF_BROWSER_MANIFEST_OVERLAY;
else if (name == content::mojom::kRendererServiceName) else if (name == content::mojom::kRendererServiceName)
id = IDR_CEF_RENDERER_MANIFEST_OVERLAY; id = IDR_CEF_RENDERER_MANIFEST_OVERLAY;
else if (name == content::mojom::kUtilityServiceName) else if (name == content::mojom::kUtilityServiceName)
id = IDR_CEF_UTILITY_MANIFEST_OVERLAY; 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) if (id == -1)
return nullptr; return nullptr;
...@@ -893,6 +919,16 @@ void CefContentBrowserClient::DidCreatePpapiPlugin( ...@@ -893,6 +919,16 @@ void CefContentBrowserClient::DidCreatePpapiPlugin(
new CefBrowserPepperHostFactory(browser_host))); 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* content::DevToolsManagerDelegate*
CefContentBrowserClient::GetDevToolsManagerDelegate() { CefContentBrowserClient::GetDevToolsManagerDelegate() {
return new CefDevToolsManagerDelegate(); return new CefDevToolsManagerDelegate();
...@@ -992,6 +1028,14 @@ void CefContentBrowserClient::ExposeInterfacesToRenderer( ...@@ -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) { void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
// Register as a Web-safe scheme so that requests for the scheme from a // 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 // render process will be allowed in resource_dispatcher_host_impl.cc
......
...@@ -32,6 +32,10 @@ namespace extensions { ...@@ -32,6 +32,10 @@ namespace extensions {
class Extension; class Extension;
} }
namespace ui {
class ImageCursorsSet;
}
class CefContentBrowserClient : public content::ContentBrowserClient { class CefContentBrowserClient : public content::ContentBrowserClient {
public: public:
CefContentBrowserClient(); CefContentBrowserClient();
...@@ -98,6 +102,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { ...@@ -98,6 +102,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override; void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override; std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
gpu::GpuChannelEstablishFactory* GetGpuChannelEstablishFactory() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
std::vector<std::unique_ptr<content::NavigationThrottle>> std::vector<std::unique_ptr<content::NavigationThrottle>>
CreateThrottlesForNavigation( CreateThrottlesForNavigation(
...@@ -120,6 +125,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient { ...@@ -120,6 +125,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
content::AssociatedInterfaceRegistry* associated_registry, content::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override; content::RenderProcessHost* render_process_host) override;
void RegisterInProcessServices(StaticServiceMap* services) override;
// Perform browser process registration for the custom scheme. // Perform browser process registration for the custom scheme.
void RegisterCustomScheme(const std::string& scheme); void RegisterCustomScheme(const std::string& scheme);
...@@ -131,6 +138,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { ...@@ -131,6 +138,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
const extensions::Extension* GetExtension( const extensions::Extension* GetExtension(
content::SiteInstance* site_instance); content::SiteInstance* site_instance);
std::unique_ptr<ui::ImageCursorsSet> image_cursors_set_;
CefBrowserMainParts* browser_main_parts_; CefBrowserMainParts* browser_main_parts_;
std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_; std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.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" #include "ui/base/ui_base_switches.h"
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -160,27 +162,22 @@ int CefExecuteProcess(const CefMainArgs& args, ...@@ -160,27 +162,22 @@ int CefExecuteProcess(const CefMainArgs& args,
InitCrashReporter(); InitCrashReporter();
#endif #endif
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); base::CommandLine::Init(args.argc, args.argv);
#if defined(OS_WIN) const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
command_line.ParseFromString(::GetCommandLineW());
#else
command_line.InitFromArgv(args.argc, args.argv);
#endif
// Wait for the debugger as early in process initialization as possible. // 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); base::debug::WaitForDebugger(60, true);
// If no process type is specified then it represents the browser process and // If no process type is specified then it represents the browser process and
// we do nothing. // we do nothing.
std::string process_type = std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType); command_line->GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty()) if (process_type.empty())
return -1; return -1;
#if defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_MACOSX) || defined(OS_WIN)
if (process_type == crash_reporter::switches::kCrashpadHandler) if (process_type == crash_reporter::switches::kCrashpadHandler)
return RunAsCrashpadHandler(command_line); return RunAsCrashpadHandler(*command_line);
#endif #endif
CefMainDelegate main_delegate(application); CefMainDelegate main_delegate(application);
...@@ -204,6 +201,11 @@ int CefExecuteProcess(const CefMainArgs& args, ...@@ -204,6 +201,11 @@ int CefExecuteProcess(const CefMainArgs& args,
params.argc = args.argc; params.argc = args.argc;
params.argv = const_cast<const char**>(args.argv); 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); return content::ContentMain(params);
#endif #endif
} }
...@@ -376,6 +378,13 @@ bool CefContext::Initialize(const CefMainArgs& args, ...@@ -376,6 +378,13 @@ bool CefContext::Initialize(const CefMainArgs& args,
params.argv = const_cast<const char**>(args.argv); params.argv = const_cast<const char**>(args.argv);
#endif #endif
auto command_line = base::CommandLine::ForCurrentProcess();
#if defined(USE_AURA)