Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / installer / mini_installer / configuration.cc
blob33551cbebf44e27ac50e1739f4261f436bc42821
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"
7 #include <windows.h>
8 #include <shellapi.h> // NOLINT
10 #include "chrome/installer/mini_installer/appid.h"
12 namespace mini_installer {
14 Configuration::Configuration() : args_(NULL) {
15 Clear();
18 Configuration::~Configuration() {
19 Clear();
22 const wchar_t* Configuration::program() const {
23 return args_ == NULL || argument_count_ < 1 ? NULL : args_[0];
26 void Configuration::Clear() {
27 if (args_ != NULL) {
28 ::LocalFree(args_);
29 args_ = NULL;
31 chrome_app_guid_ = google_update::kAppGuid;
32 command_line_ = NULL;
33 operation_ = INSTALL_PRODUCT;
34 argument_count_ = 0;
35 has_chrome_ = false;
36 has_chrome_frame_ = false;
37 is_multi_install_ = false;
38 is_system_level_ = false;
39 query_component_build_ = false;
42 bool Configuration::Initialize() {
43 return InitializeFromCommandLine(::GetCommandLine());
46 // This is its own function so that unit tests can provide their own command
47 // lines. |command_line| is shared with this instance in the sense that this
48 // instance may refer to it at will throughout its lifetime, yet it will
49 // not release it.
50 bool Configuration::InitializeFromCommandLine(const wchar_t* command_line) {
51 Clear();
53 command_line_ = command_line;
54 args_ = ::CommandLineToArgvW(command_line_, &argument_count_);
55 if (args_ != NULL) {
56 for (int i = 1; i < argument_count_; ++i) {
57 if (0 == ::lstrcmpi(args_[i], L"--chrome-sxs"))
58 chrome_app_guid_ = google_update::kSxSAppGuid;
59 else if (0 == ::lstrcmpi(args_[i], L"--chrome"))
60 has_chrome_ = true;
61 else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame"))
62 has_chrome_frame_ = true;
63 else if (0 == ::lstrcmpi(args_[i], L"--multi-install"))
64 is_multi_install_ = true;
65 else if (0 == ::lstrcmpi(args_[i], L"--system-level"))
66 is_system_level_ = true;
67 else if (0 == ::lstrcmpi(args_[i], L"--cleanup"))
68 operation_ = CLEANUP;
69 else if (0 == ::lstrcmpi(args_[i], L"--query-component-build"))
70 query_component_build_ = true;
73 // Single-install defaults to Chrome.
74 if (!is_multi_install_)
75 has_chrome_ = !has_chrome_frame_;
78 return args_ != NULL;
81 } // namespace mini_installer