Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / sandbox / win / src / job.h
blob4b7cb72e164d8eba9c2945de70e46939ec952739
1 // Copyright (c) 2010 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 #ifndef SANDBOX_SRC_JOB_H_
6 #define SANDBOX_SRC_JOB_H_
8 #include "base/basictypes.h"
9 #include "base/win/scoped_handle.h"
10 #include "sandbox/win/src/restricted_token_utils.h"
12 namespace sandbox {
14 // Handles the creation of job objects based on a security profile.
15 // Sample usage:
16 // Job job;
17 // job.Init(JOB_LOCKDOWN, NULL); //no job name
18 // job.AssignProcessToJob(process_handle);
19 class Job {
20 public:
21 Job();
23 ~Job();
25 // Initializes and creates the job object. The security of the job is based
26 // on the security_level parameter.
27 // job_name can be NULL if the job is unnamed.
28 // If the chosen profile has too many ui restrictions, you can disable some
29 // by specifying them in the ui_exceptions parameters.
30 // If the function succeeds, the return value is ERROR_SUCCESS. If the
31 // function fails, the return value is the win32 error code corresponding to
32 // the error.
33 DWORD Init(JobLevel security_level,
34 const wchar_t* job_name,
35 DWORD ui_exceptions,
36 size_t memory_limit);
38 // Assigns the process referenced by process_handle to the job.
39 // If the function succeeds, the return value is ERROR_SUCCESS. If the
40 // function fails, the return value is the win32 error code corresponding to
41 // the error.
42 DWORD AssignProcessToJob(HANDLE process_handle);
44 // Grants access to "handle" to the job. All processes in the job can
45 // subsequently recognize and use the handle.
46 // If the function succeeds, the return value is ERROR_SUCCESS. If the
47 // function fails, the return value is the win32 error code corresponding to
48 // the error.
49 DWORD UserHandleGrantAccess(HANDLE handle);
51 // Revokes ownership to the job handle and returns it.
52 // If the object is not yet initialized, it returns an invalid handle.
53 base::win::ScopedHandle Take();
55 private:
56 // Handle to the job referenced by the object.
57 base::win::ScopedHandle job_handle_;
59 DISALLOW_COPY_AND_ASSIGN(Job);
62 } // namespace sandbox
65 #endif // SANDBOX_SRC_JOB_H_