Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / sandbox / win / src / sandbox.cc
blobeaa89631a73b8ed3abd06a697ac79a85a4bb06c9
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <stdio.h>
6 #include <windows.h>
7 #include "sandbox/win/src/sandbox.h"
8 #include "sandbox/win/src/sandbox_factory.h"
9 #include "sandbox/win/src/broker_services.h"
10 #include "sandbox/win/src/target_services.h"
12 #if defined(_WIN64) && !defined(NACL_WIN64)
13 // We allow building this code for Win64 as part of NaCl to enable development
14 #pragma message("Sandbox code was not fully tested on 64-bit Windows.\
15 crbug.com/168414 ")
16 #endif
19 namespace sandbox {
20 // The section for IPC and policy.
21 SANDBOX_INTERCEPT HANDLE g_shared_section = NULL;
23 static bool s_is_broker = false;
25 // GetBrokerServices: the current implementation relies on a shared section
26 // that is created by the broker and opened by the target.
27 BrokerServices* SandboxFactory::GetBrokerServices() {
28 // Can't be the broker if the shared section is open.
29 if (NULL != g_shared_section) {
30 return NULL;
32 // If the shared section does not exist we are the broker, then create
33 // the broker object.
34 s_is_broker = true;
35 return BrokerServicesBase::GetInstance();
38 // GetTargetServices implementation must follow the same technique as the
39 // GetBrokerServices, but in this case the logic is the opposite.
40 TargetServices* SandboxFactory::GetTargetServices() {
41 // Can't be the target if the section handle is not valid.
42 if (NULL == g_shared_section) {
43 return NULL;
45 // We are the target
46 s_is_broker = false;
47 // Creates and returns the target services implementation.
48 return TargetServicesBase::GetInstance();
51 } // namespace sandbox