Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/installer/mini_installer/configuration.cc

Issue 2670133002: Various cleanups. (Closed)
Patch Set: huangs comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/installer/mini_installer/configuration.h" 5 #include "chrome/installer/mini_installer/configuration.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> // NOLINT 8 #include <shellapi.h> // NOLINT
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void Configuration::Clear() { 50 void Configuration::Clear() {
51 if (args_ != NULL) { 51 if (args_ != NULL) {
52 ::LocalFree(args_); 52 ::LocalFree(args_);
53 args_ = NULL; 53 args_ = NULL;
54 } 54 }
55 chrome_app_guid_ = google_update::kAppGuid; 55 chrome_app_guid_ = google_update::kAppGuid;
56 command_line_ = NULL; 56 command_line_ = NULL;
57 operation_ = INSTALL_PRODUCT; 57 operation_ = INSTALL_PRODUCT;
58 argument_count_ = 0; 58 argument_count_ = 0;
59 is_system_level_ = false; 59 is_system_level_ = false;
60 is_side_by_side_ = false;
61 is_updating_multi_chrome_ = false; 60 is_updating_multi_chrome_ = false;
62 has_invalid_switch_ = false; 61 has_invalid_switch_ = false;
63 previous_version_ = NULL; 62 previous_version_ = NULL;
64 } 63 }
65 64
66 // |command_line| is shared with this instance in the sense that this 65 // |command_line| is shared with this instance in the sense that this
67 // instance may refer to it at will throughout its lifetime, yet it will 66 // instance may refer to it at will throughout its lifetime, yet it will
68 // not release it. 67 // not release it.
69 bool Configuration::ParseCommandLine(const wchar_t* command_line) { 68 bool Configuration::ParseCommandLine(const wchar_t* command_line) {
70 command_line_ = command_line; 69 command_line_ = command_line;
71 args_ = ::CommandLineToArgvW(command_line_, &argument_count_); 70 args_ = ::CommandLineToArgvW(command_line_, &argument_count_);
72 if (!args_) 71 if (!args_)
73 return false; 72 return false;
74 73
75 for (int i = 1; i < argument_count_; ++i) { 74 for (int i = 1; i < argument_count_; ++i) {
76 if (0 == ::lstrcmpi(args_[i], L"--system-level")) { 75 if (0 == ::lstrcmpi(args_[i], L"--system-level"))
77 is_system_level_ = true; 76 is_system_level_ = true;
78 #if defined(GOOGLE_CHROME_BUILD) 77 #if defined(GOOGLE_CHROME_BUILD)
79 } else if (0 == ::lstrcmpi(args_[i], L"--chrome-sxs")) { 78 else if (0 == ::lstrcmpi(args_[i], L"--chrome-sxs"))
80 is_side_by_side_ = true;
81 chrome_app_guid_ = google_update::kSxSAppGuid; 79 chrome_app_guid_ = google_update::kSxSAppGuid;
82 #endif 80 #endif
83 } else if (0 == ::lstrcmpi(args_[i], L"--cleanup")) { 81 else if (0 == ::lstrcmpi(args_[i], L"--cleanup"))
84 operation_ = CLEANUP; 82 operation_ = CLEANUP;
85 } else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame")) { 83 else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame"))
86 has_invalid_switch_ = true; 84 has_invalid_switch_ = true;
87 }
88 } 85 }
89 86
90 if (!is_system_level_) 87 if (!is_system_level_)
91 is_system_level_ = GetGoogleUpdateIsMachineEnvVar(); 88 is_system_level_ = GetGoogleUpdateIsMachineEnvVar();
92 89
93 is_updating_multi_chrome_ = IsUpdatingMultiChrome(); 90 is_updating_multi_chrome_ = IsUpdatingMultiChrome();
94 91
95 return true; 92 return true;
96 } 93 }
97 94
(...skipping 21 matching lines...) Expand all
119 116
120 // The string must be terminated. 117 // The string must be terminated.
121 if (version_string[version_len - 1]) 118 if (version_string[version_len - 1])
122 return; 119 return;
123 120
124 previous_version_ = version_string; 121 previous_version_ = version_string;
125 } 122 }
126 123
127 bool Configuration::IsUpdatingMultiChrome() const { 124 bool Configuration::IsUpdatingMultiChrome() const {
128 #if defined(GOOGLE_CHROME_BUILD) 125 #if defined(GOOGLE_CHROME_BUILD)
129 // SxS/canary does not support multi-install. 126 // Only primary Chrome installs supported multi-install (not canary/SxS).
130 if (is_side_by_side_) 127 if (chrome_app_guid_ != google_update::kAppGuid)
131 return false; 128 return false;
132 129
133 // Is Chrome already installed as multi-install? 130 // Is Chrome already installed as multi-install?
134 const HKEY root = is_system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 131 const HKEY root = is_system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
135 StackString<128> value; 132 StackString<128> value;
136 RegKey key; 133 RegKey key;
137 return (OpenClientsKey(root, google_update::kAppGuid, KEY_QUERY_VALUE, 134 return (OpenClientsKey(root, chrome_app_guid_, KEY_QUERY_VALUE, &key) ==
138 &key) == ERROR_SUCCESS && 135 ERROR_SUCCESS &&
139 key.ReadSZValue(kPvRegistryValue, value.get(), value.capacity()) == 136 key.ReadSZValue(kPvRegistryValue, value.get(), value.capacity()) ==
140 ERROR_SUCCESS && 137 ERROR_SUCCESS &&
141 value.length() != 0 && 138 value.length() != 0 &&
142 OpenClientStateKey(root, google_update::kAppGuid, KEY_QUERY_VALUE, 139 OpenClientStateKey(root, chrome_app_guid_, KEY_QUERY_VALUE, &key) ==
143 &key) == ERROR_SUCCESS && 140 ERROR_SUCCESS &&
144 key.ReadSZValue(kUninstallArgumentsRegistryValue, value.get(), 141 key.ReadSZValue(kUninstallArgumentsRegistryValue, value.get(),
145 value.capacity()) == ERROR_SUCCESS && 142 value.capacity()) == ERROR_SUCCESS &&
146 value.findi(L"--multi-install") != nullptr); 143 value.findi(L"--multi-install") != nullptr);
147 #else 144 #else
148 return false; 145 return false;
149 #endif 146 #endif
150 } 147 }
151 148
152 } // namespace mini_installer 149 } // namespace mini_installer
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/configuration.h ('k') | chrome/installer/mini_installer/configuration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698