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

Side by Side Diff: chrome/install_static/install_util.cc

Issue 2459583002: Use InstallDetails in setup. (Closed)
Patch Set: another doc comment 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
« no previous file with comments | « chrome/install_static/install_util.h ('k') | chrome/install_static/install_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <limits>
13 #include <memory> 14 #include <memory>
14 #include <sstream> 15 #include <sstream>
15 16
16 #include "chrome/install_static/install_details.h" 17 #include "chrome/install_static/install_details.h"
17 #include "chrome/install_static/install_modes.h" 18 #include "chrome/install_static/install_modes.h"
18 #include "chrome/install_static/policy_path_parser.h" 19 #include "chrome/install_static/policy_path_parser.h"
19 #include "chrome/install_static/user_data_dir.h" 20 #include "chrome/install_static/user_data_dir.h"
20 #include "chrome_elf/nt_registry/nt_registry.h" 21 #include "chrome_elf/nt_registry/nt_registry.h"
21 22
22 namespace install_static { 23 namespace install_static {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 std::basic_istringstream<typename StringType::value_type> buffer(str); 253 std::basic_istringstream<typename StringType::value_type> buffer(str);
253 for (StringType token; std::getline(buffer, token, delimiter);) { 254 for (StringType token; std::getline(buffer, token, delimiter);) {
254 if (trim_spaces) 255 if (trim_spaces)
255 TrimT<StringType>(&token); 256 TrimT<StringType>(&token);
256 tokens.push_back(token); 257 tokens.push_back(token);
257 } 258 }
258 return tokens; 259 return tokens;
259 } 260 }
260 261
261 std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, 262 std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
262 bool system_level) { 263 bool system_level,
264 bool from_binaries) {
263 assert(kUseGoogleUpdateIntegration); 265 assert(kUseGoogleUpdateIntegration);
264 // InitChannelInfo in google_update_settings.cc only reports a failure when 266 // InitChannelInfo in google_update_settings.cc only reports a failure when
265 // Chrome's ClientState key exists but that the "ap" value therein cannot be 267 // Chrome's ClientState key exists but that the "ap" value therein cannot be
266 // read due to some reason *other* than it not being present. This should be 268 // read due to some reason *other* than it not being present. This should be
267 // exceedingly rare. For simplicity's sake, use an empty |value| in case of 269 // exceedingly rare. For simplicity's sake, use an empty |value| in case of
268 // any error whatsoever here. 270 // any error whatsoever here.
269 std::wstring value; 271 std::wstring value;
270 nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432, 272 nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432,
271 GetClientStateKeyPath(mode.app_guid).c_str(), kRegValueAp, 273 from_binaries
272 &value); 274 ? GetBinariesClientStateKeyPath().c_str()
275 : GetClientStateKeyPath(mode.app_guid).c_str(),
276 kRegValueAp, &value);
273 277
274 static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*"; 278 static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*";
275 static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*"; 279 static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*";
276 static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*"; 280 static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*";
277 static constexpr wchar_t kChromeChannelDevX64Pattern[] = L"*x64-dev*"; 281 static constexpr wchar_t kChromeChannelDevX64Pattern[] = L"*x64-dev*";
278 282
279 std::transform(value.begin(), value.end(), value.begin(), ::tolower); 283 std::transform(value.begin(), value.end(), value.begin(), ::tolower);
280 284
281 // Empty channel names or those containing "stable" should be reported as 285 // Empty channel names or those containing "stable" should be reported as
282 // an empty string. 286 // an empty string.
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 Trace(L"Failed to create directory %ls, last error is %d\n", 734 Trace(L"Failed to create directory %ls, last error is %d\n",
731 full_path_str, error_code); 735 full_path_str, error_code);
732 return false; 736 return false;
733 } 737 }
734 } 738 }
735 return true; 739 return true;
736 } 740 }
737 741
738 // This function takes these inputs rather than accessing the module's 742 // This function takes these inputs rather than accessing the module's
739 // InstallDetails instance since it is used to bootstrap InstallDetails. 743 // InstallDetails instance since it is used to bootstrap InstallDetails.
740 std::wstring DetermineChannel(const InstallConstants& mode, bool system_level) { 744 std::wstring DetermineChannel(const InstallConstants& mode,
745 bool system_level,
746 bool from_binaries) {
741 if (!kUseGoogleUpdateIntegration) 747 if (!kUseGoogleUpdateIntegration)
742 return std::wstring(); 748 return std::wstring();
743 749
744 switch (mode.channel_strategy) { 750 switch (mode.channel_strategy) {
745 case ChannelStrategy::UNSUPPORTED: 751 case ChannelStrategy::UNSUPPORTED:
746 assert(false); 752 assert(false);
747 break; 753 break;
748 case ChannelStrategy::ADDITIONAL_PARAMETERS: 754 case ChannelStrategy::ADDITIONAL_PARAMETERS:
749 return ChannelFromAdditionalParameters(mode, system_level); 755 return ChannelFromAdditionalParameters(mode, system_level, from_binaries);
750 case ChannelStrategy::FIXED: 756 case ChannelStrategy::FIXED:
751 return mode.default_channel_name; 757 return mode.default_channel_name;
752 } 758 }
753 759
754 return std::wstring(); 760 return std::wstring();
755 } 761 }
756 762
757 } // namespace install_static 763 } // namespace install_static
OLDNEW
« no previous file with comments | « chrome/install_static/install_util.h ('k') | chrome/install_static/install_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698