// Copyright © 2013 The CefSharp Project. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include #include #include "Common.h" #include "JavascriptProxyService.h" using namespace CefSharp::Internals::JavascriptBinding; using namespace CefSharp::BrowserSubprocess; using namespace System; using namespace System::ServiceModel; using namespace System::ServiceModel::Description; using namespace System::Threading; JavascriptProxyService::JavascriptProxyService(int browserIdentifier) { _browserIdentifier = browserIdentifier; } void JavascriptProxyService::CreateJavascriptProxyServiceHost() { auto uris = gcnew array(1); uris[0] = gcnew Uri(JavascriptProxy::BaseAddress); auto host = gcnew ServiceHost(JavascriptProxy::typeid, uris); AddDebugBehavior(host); // TODO: Include the name of the "parent process" here also, and perhaps then also clean out the debug stuff... auto serviceName = JavascriptProxy::ServiceName + "_" + _browserIdentifier; auto log = "Setting up JavascriptProxy listener at " + serviceName; pin_ptr serviceNameUnmanagedStr = PtrToStringChars(log); OutputDebugString(serviceNameUnmanagedStr); host->AddServiceEndpoint( IJavascriptProxy::typeid, gcnew NetNamedPipeBinding(), serviceName ); host->Open(); } void JavascriptProxyService::AddDebugBehavior(ServiceHost^ host) { auto serviceDebugBehavior = host->Description->Behaviors->Find(); if (serviceDebugBehavior == nullptr) { serviceDebugBehavior = gcnew ServiceDebugBehavior(); serviceDebugBehavior->IncludeExceptionDetailInFaults = true; host->Description->Behaviors->Add(serviceDebugBehavior); } else { serviceDebugBehavior->IncludeExceptionDetailInFaults = true; } }