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: #ifndef SANDBOX_SRC_SANDBOX_FACTORY_H__ michael@0: #define SANDBOX_SRC_SANDBOX_FACTORY_H__ michael@0: michael@0: #include "sandbox/win/src/sandbox.h" michael@0: michael@0: // SandboxFactory is a set of static methods to get access to the broker michael@0: // or target services object. Only one of the two methods (GetBrokerServices, michael@0: // GetTargetServices) will return a non-null pointer and that should be used michael@0: // as the indication that the process is the broker or the target: michael@0: // michael@0: // BrokerServices* broker_services = SandboxFactory::GetBrokerServices(); michael@0: // if (NULL != broker_services) { michael@0: // //we are the broker, call broker api here michael@0: // broker_services->Init(); michael@0: // } else { michael@0: // TargetServices* target_services = SandboxFactory::GetTargetServices(); michael@0: // if (NULL != target_services) { michael@0: // //we are the target, call target api here michael@0: // target_services->Init(); michael@0: // } michael@0: // michael@0: // The methods in this class are expected to be called from a single thread michael@0: // michael@0: // The Sandbox library needs to be linked against the main executable, but michael@0: // sometimes the API calls are issued from a DLL that loads into the exe michael@0: // process. These factory methods then need to be called from the main michael@0: // exe and the interface pointers then can be safely passed to the DLL where michael@0: // the Sandbox API calls are made. michael@0: namespace sandbox { michael@0: michael@0: class SandboxFactory { michael@0: public: michael@0: // Returns the Broker API interface, returns NULL if this process is the michael@0: // target. michael@0: static BrokerServices* GetBrokerServices(); michael@0: michael@0: // Returns the Target API interface, returns NULL if this process is the michael@0: // broker. michael@0: static TargetServices* GetTargetServices(); michael@0: private: michael@0: DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxFactory); michael@0: }; michael@0: michael@0: } // namespace sandbox michael@0: michael@0: #endif // SANDBOX_SRC_SANDBOX_FACTORY_H__