michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include michael@0: #include michael@0: #include "sandbox/win/src/sandbox.h" michael@0: #include "sandbox/win/src/sandbox_factory.h" michael@0: #include "sandbox/win/src/broker_services.h" michael@0: #include "sandbox/win/src/target_services.h" michael@0: michael@0: namespace sandbox { michael@0: // The section for IPC and policy. michael@0: SANDBOX_INTERCEPT HANDLE g_shared_section = NULL; michael@0: michael@0: static bool s_is_broker = false; michael@0: michael@0: // GetBrokerServices: the current implementation relies on a shared section michael@0: // that is created by the broker and opened by the target. michael@0: BrokerServices* SandboxFactory::GetBrokerServices() { michael@0: // Can't be the broker if the shared section is open. michael@0: if (NULL != g_shared_section) { michael@0: return NULL; michael@0: } michael@0: // If the shared section does not exist we are the broker, then create michael@0: // the broker object. michael@0: s_is_broker = true; michael@0: return BrokerServicesBase::GetInstance(); michael@0: } michael@0: michael@0: // GetTargetServices implementation must follow the same technique as the michael@0: // GetBrokerServices, but in this case the logic is the opposite. michael@0: TargetServices* SandboxFactory::GetTargetServices() { michael@0: // Can't be the target if the section handle is not valid. michael@0: if (NULL == g_shared_section) { michael@0: return NULL; michael@0: } michael@0: // We are the target michael@0: s_is_broker = false; michael@0: // Creates and returns the target services implementation. michael@0: return TargetServicesBase::GetInstance(); michael@0: } michael@0: michael@0: } // namespace sandbox