1 // Copyright (c) 2012 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 "chrome/installer/mini_installer/configuration.h"
8 #include <shellapi.h> // NOLINT
10 #include "chrome/installer/mini_installer/appid.h"
12 namespace mini_installer
{
14 Configuration::Configuration() : args_(NULL
) {
18 Configuration::~Configuration() {
22 const wchar_t* Configuration::program() const {
23 return args_
== NULL
|| argument_count_
< 1 ? NULL
: args_
[0];
26 void Configuration::Clear() {
31 chrome_app_guid_
= google_update::kAppGuid
;
33 operation_
= INSTALL_PRODUCT
;
36 has_chrome_frame_
= false;
37 has_app_host_
= false;
38 is_multi_install_
= false;
39 is_system_level_
= false;
40 query_component_build_
= false;
43 bool Configuration::Initialize() {
44 return InitializeFromCommandLine(::GetCommandLine());
47 // This is its own function so that unit tests can provide their own command
48 // lines. |command_line| is shared with this instance in the sense that this
49 // instance may refer to it at will throughout its lifetime, yet it will
51 bool Configuration::InitializeFromCommandLine(const wchar_t* command_line
) {
54 command_line_
= command_line
;
55 args_
= ::CommandLineToArgvW(command_line_
, &argument_count_
);
57 for (int i
= 1; i
< argument_count_
; ++i
) {
58 if (0 == ::lstrcmpi(args_
[i
], L
"--chrome-sxs"))
59 chrome_app_guid_
= google_update::kSxSAppGuid
;
60 else if (0 == ::lstrcmpi(args_
[i
], L
"--chrome"))
62 else if (0 == ::lstrcmpi(args_
[i
], L
"--chrome-frame"))
63 has_chrome_frame_
= true;
64 else if ((0 == ::lstrcmpi(args_
[i
], L
"--app-host")) ||
65 (0 == ::lstrcmpi(args_
[i
], L
"--app-launcher")))
67 else if (0 == ::lstrcmpi(args_
[i
], L
"--multi-install"))
68 is_multi_install_
= true;
69 else if (0 == ::lstrcmpi(args_
[i
], L
"--system-level"))
70 is_system_level_
= true;
71 else if (0 == ::lstrcmpi(args_
[i
], L
"--cleanup"))
73 else if (0 == ::lstrcmpi(args_
[i
], L
"--query-component-build"))
74 query_component_build_
= true;
77 // Single-install defaults to Chrome.
78 if (!is_multi_install_
)
79 has_chrome_
= !(has_chrome_frame_
|| has_app_host_
);
84 } // namespace mini_installer