summaryrefslogtreecommitdiffstats
path: root/ceee/common/install_utils.cc
blob: e6870f72f80fea115c12b78c5b5a99298ae264e2 (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
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2010 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.
//
// Utilities related to installation of the CEEE.

#include "ceee/common/install_utils.h"

#include <windows.h>

#include "base/command_line.h"
#include "base/file_path.h"
#include "base/path_service.h"
#include "chrome/installer/util/util_constants.h"

namespace installer {
  namespace switches {
    // TODO(joi): Move to chrome/installer/util_constants.h
    // when we refactor this logic to be in the installer rather than
    // on the registration entrypoints.
    const char kEnableCeee[] = "ceee";
    // TODO(joi): The installer supports only "ceee".
    const char kEnableFfCeee[] = "enable-ff-ceee";
  }
}

namespace ceee_install_utils {

bool ShouldRegisterImpl(bool check_firefox) {
  // First check if it's a developer running us explicitly.
  FilePath exe_path;
  if (PathService::Get(base::FILE_EXE, &exe_path)) {
    if (exe_path.BaseName() == FilePath(L"regsvr32.exe")) {
      return true;
    }
  }

  // Failing that, it's some kind of install scenario, so the
  // --ceee flag must be provided. It should be ignored
  // unless --chrome-frame is also specified, so we check for
  // both.
  //
  // If check_firefox is true, the --enable-ff-ceee flag must
  // also be provided.
  CommandLine current_command_line(CommandLine::NO_PROGRAM);
  current_command_line.ParseFromString(::GetCommandLine());
  if (current_command_line.HasSwitch(installer::switches::kEnableCeee) &&
      current_command_line.HasSwitch(installer::switches::kChromeFrame) &&
      (!check_firefox || current_command_line.HasSwitch(
          installer::switches::kEnableFfCeee))) {
    return true;
  } else {
    return false;
  }
}

bool ShouldRegisterCeee() {
  return ShouldRegisterImpl(false);
}

bool ShouldRegisterFfCeee() {
  return ShouldRegisterImpl(true);
}

}  // namespace ceee_install_utils