summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/self_reg_work_item.h
blob: 544621cf3844918bcd03f7fe6c654fd8d04aa992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
#define CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__

#include <windows.h>
#include <string>

#include "chrome/installer/util/work_item.h"

// Registers or unregisters the DLL at the given path.
class SelfRegWorkItem : public WorkItem {
 public:
  ~SelfRegWorkItem() override;

  bool Do() override;
  void Rollback() override;

 private:
  friend class WorkItem;

  // Constructs a work item that will call upon a self-registering DLL to
  // register itself.
  // dll_path: The path to the DLL.
  // do_register: Whether this action is to register or unregister the DLL.
  // user_level_registration: If true, then the exports called
  //    "DllRegisterUserServer" and "DllUnregisterUserServer" will be called to
  //    register and unregister the DLL. If false, the default exports named
  //    "DllRegisterServer" and "DllUnregisterUserServer" will be used.
  SelfRegWorkItem(const std::wstring& dll_path, bool do_register,
                  bool user_level_registration);

  // Examines the DLL at dll_path looking for either DllRegisterServer (if
  // do_register is true) or DllUnregisterServer (if do_register is false).
  // Returns true if the DLL exports the function and it a call to it
  // succeeds, false otherwise.
  bool RegisterDll(bool do_register);

  // The path to the dll to be registered.
  std::wstring dll_path_;

  // Whether this work item will register or unregister the dll. The rollback
  // action just inverts this parameter.
  bool do_register_;

  // Whether to use alternate export names on the DLL that will perform
  // user level registration.
  bool user_level_registration_;
};

#endif  // CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__