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

Side by Side Diff: chrome/installer/util/install_util.cc

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/installation_validator.h » ('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 (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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } else { 118 } else {
119 NOTREACHED() << "Unable to get default monitor"; 119 NOTREACHED() << "Unable to get default monitor";
120 } 120 }
121 ::SetForegroundWindow(foreground_window); 121 ::SetForegroundWindow(foreground_window);
122 } 122 }
123 return foreground_window; 123 return foreground_window;
124 } 124 }
125 125
126 } // namespace 126 } // namespace
127 127
128 string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { 128 base::string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) {
129 static const wchar_t kInstalledComponentsPath[] = 129 static const wchar_t kInstalledComponentsPath[] =
130 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; 130 L"Software\\Microsoft\\Active Setup\\Installed Components\\";
131 return kInstalledComponentsPath + dist->GetActiveSetupGuid(); 131 return kInstalledComponentsPath + dist->GetActiveSetupGuid();
132 } 132 }
133 133
134 void InstallUtil::TriggerActiveSetupCommand() { 134 void InstallUtil::TriggerActiveSetupCommand() {
135 string16 active_setup_reg( 135 base::string16 active_setup_reg(
136 GetActiveSetupPath(BrowserDistribution::GetDistribution())); 136 GetActiveSetupPath(BrowserDistribution::GetDistribution()));
137 base::win::RegKey active_setup_key( 137 base::win::RegKey active_setup_key(
138 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE); 138 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE);
139 string16 cmd_str; 139 base::string16 cmd_str;
140 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str); 140 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str);
141 if (read_status != ERROR_SUCCESS) { 141 if (read_status != ERROR_SUCCESS) {
142 LOG(ERROR) << active_setup_reg << ", " << read_status; 142 LOG(ERROR) << active_setup_reg << ", " << read_status;
143 // This should never fail if Chrome is registered at system-level, but if it 143 // This should never fail if Chrome is registered at system-level, but if it
144 // does there is not much else to be done. 144 // does there is not much else to be done.
145 return; 145 return;
146 } 146 }
147 147
148 CommandLine cmd(CommandLine::FromString(cmd_str)); 148 CommandLine cmd(CommandLine::FromString(cmd_str));
149 // Force creation of shortcuts as the First Run beacon might land between now 149 // Force creation of shortcuts as the First Run beacon might land between now
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void InstallUtil::GetChromeVersion(BrowserDistribution* dist, 215 void InstallUtil::GetChromeVersion(BrowserDistribution* dist,
216 bool system_install, 216 bool system_install,
217 Version* version) { 217 Version* version) {
218 DCHECK(dist); 218 DCHECK(dist);
219 RegKey key; 219 RegKey key;
220 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 220 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
221 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), 221 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(),
222 KEY_QUERY_VALUE); 222 KEY_QUERY_VALUE);
223 223
224 string16 version_str; 224 base::string16 version_str;
225 if (result == ERROR_SUCCESS) 225 if (result == ERROR_SUCCESS)
226 result = key.ReadValue(google_update::kRegVersionField, &version_str); 226 result = key.ReadValue(google_update::kRegVersionField, &version_str);
227 227
228 *version = Version(); 228 *version = Version();
229 if (result == ERROR_SUCCESS && !version_str.empty()) { 229 if (result == ERROR_SUCCESS && !version_str.empty()) {
230 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " 230 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found "
231 << version_str; 231 << version_str;
232 *version = Version(WideToASCII(version_str)); 232 *version = Version(WideToASCII(version_str));
233 } else { 233 } else {
234 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); 234 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result);
235 VLOG(1) << "No existing " << dist->GetDisplayName() 235 VLOG(1) << "No existing " << dist->GetDisplayName()
236 << " install found."; 236 << " install found.";
237 } 237 }
238 } 238 }
239 239
240 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, 240 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist,
241 bool system_install, 241 bool system_install,
242 Version* version) { 242 Version* version) {
243 DCHECK(dist); 243 DCHECK(dist);
244 RegKey key; 244 RegKey key;
245 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 245 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
246 LONG result = 246 LONG result =
247 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE); 247 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE);
248 248
249 string16 version_str; 249 base::string16 version_str;
250 if (result == ERROR_SUCCESS) 250 if (result == ERROR_SUCCESS)
251 result = key.ReadValue(google_update::kRegCriticalVersionField, 251 result = key.ReadValue(google_update::kRegCriticalVersionField,
252 &version_str); 252 &version_str);
253 253
254 *version = Version(); 254 *version = Version();
255 if (result == ERROR_SUCCESS && !version_str.empty()) { 255 if (result == ERROR_SUCCESS && !version_str.empty()) {
256 VLOG(1) << "Critical Update version for " << dist->GetDisplayName() 256 VLOG(1) << "Critical Update version for " << dist->GetDisplayName()
257 << " found " << version_str; 257 << " found " << version_str;
258 *version = Version(WideToASCII(version_str)); 258 *version = Version(WideToASCII(version_str));
259 } else { 259 } else {
260 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); 260 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result);
261 VLOG(1) << "No existing " << dist->GetDisplayName() 261 VLOG(1) << "No existing " << dist->GetDisplayName()
262 << " install found."; 262 << " install found.";
263 } 263 }
264 } 264 }
265 265
266 bool InstallUtil::IsOSSupported() { 266 bool InstallUtil::IsOSSupported() {
267 // We do not support Win2K or older, or XP without service pack 2. 267 // We do not support Win2K or older, or XP without service pack 2.
268 VLOG(1) << base::SysInfo::OperatingSystemName() << ' ' 268 VLOG(1) << base::SysInfo::OperatingSystemName() << ' '
269 << base::SysInfo::OperatingSystemVersion(); 269 << base::SysInfo::OperatingSystemVersion();
270 base::win::Version version = base::win::GetVersion(); 270 base::win::Version version = base::win::GetVersion();
271 return (version > base::win::VERSION_XP) || 271 return (version > base::win::VERSION_XP) ||
272 ((version == base::win::VERSION_XP) && 272 ((version == base::win::VERSION_XP) &&
273 (base::win::OSInfo::GetInstance()->service_pack().major >= 2)); 273 (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
274 } 274 }
275 275
276 void InstallUtil::AddInstallerResultItems(bool system_install, 276 void InstallUtil::AddInstallerResultItems(
277 const string16& state_key, 277 bool system_install,
278 installer::InstallStatus status, 278 const base::string16& state_key,
279 int string_resource_id, 279 installer::InstallStatus status,
280 const string16* const launch_cmd, 280 int string_resource_id,
281 WorkItemList* install_list) { 281 const base::string16* const launch_cmd,
282 WorkItemList* install_list) {
282 DCHECK(install_list); 283 DCHECK(install_list);
283 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 284 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
284 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; 285 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1;
285 install_list->AddCreateRegKeyWorkItem(root, state_key); 286 install_list->AddCreateRegKeyWorkItem(root, state_key);
286 install_list->AddSetRegValueWorkItem(root, state_key, 287 install_list->AddSetRegValueWorkItem(root, state_key,
287 installer::kInstallerResult, 288 installer::kInstallerResult,
288 installer_result, true); 289 installer_result, true);
289 install_list->AddSetRegValueWorkItem(root, state_key, 290 install_list->AddSetRegValueWorkItem(root, state_key,
290 installer::kInstallerError, 291 installer::kInstallerError,
291 static_cast<DWORD>(status), true); 292 static_cast<DWORD>(status), true);
292 if (string_resource_id != 0) { 293 if (string_resource_id != 0) {
293 string16 msg = installer::GetLocalizedString(string_resource_id); 294 base::string16 msg = installer::GetLocalizedString(string_resource_id);
294 install_list->AddSetRegValueWorkItem(root, state_key, 295 install_list->AddSetRegValueWorkItem(root, state_key,
295 installer::kInstallerResultUIString, msg, true); 296 installer::kInstallerResultUIString, msg, true);
296 } 297 }
297 if (launch_cmd != NULL && !launch_cmd->empty()) { 298 if (launch_cmd != NULL && !launch_cmd->empty()) {
298 install_list->AddSetRegValueWorkItem(root, state_key, 299 install_list->AddSetRegValueWorkItem(root, state_key,
299 installer::kInstallerSuccessLaunchCmdLine, *launch_cmd, true); 300 installer::kInstallerSuccessLaunchCmdLine, *launch_cmd, true);
300 } 301 }
301 } 302 }
302 303
303 void InstallUtil::UpdateInstallerStage(bool system_install, 304 void InstallUtil::UpdateInstallerStage(bool system_install,
304 const string16& state_key_path, 305 const base::string16& state_key_path,
305 installer::InstallerStage stage) { 306 installer::InstallerStage stage) {
306 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); 307 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage);
307 DCHECK_GT(installer::NUM_STAGES, stage); 308 DCHECK_GT(installer::NUM_STAGES, stage);
308 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 309 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
309 RegKey state_key; 310 RegKey state_key;
310 LONG result = state_key.Open(root, state_key_path.c_str(), 311 LONG result = state_key.Open(root, state_key_path.c_str(),
311 KEY_QUERY_VALUE | KEY_SET_VALUE); 312 KEY_QUERY_VALUE | KEY_SET_VALUE);
312 if (result == ERROR_SUCCESS) { 313 if (result == ERROR_SUCCESS) {
313 if (stage == installer::NO_STAGE) { 314 if (stage == installer::NO_STAGE) {
314 result = state_key.DeleteValue(installer::kInstallerExtraCode1); 315 result = state_key.DeleteValue(installer::kInstallerExtraCode1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 bool CheckIsChromeSxSProcess() { 361 bool CheckIsChromeSxSProcess() {
361 CommandLine* command_line = CommandLine::ForCurrentProcess(); 362 CommandLine* command_line = CommandLine::ForCurrentProcess();
362 CHECK(command_line); 363 CHECK(command_line);
363 364
364 if (command_line->HasSwitch(installer::switches::kChromeSxS)) 365 if (command_line->HasSwitch(installer::switches::kChromeSxS))
365 return true; 366 return true;
366 367
367 // Also return true if we are running from Chrome SxS installed path. 368 // Also return true if we are running from Chrome SxS installed path.
368 base::FilePath exe_dir; 369 base::FilePath exe_dir;
369 PathService::Get(base::DIR_EXE, &exe_dir); 370 PathService::Get(base::DIR_EXE, &exe_dir);
370 string16 chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2); 371 base::string16 chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2);
371 chrome_sxs_dir.append(installer::kSxSSuffix); 372 chrome_sxs_dir.append(installer::kSxSSuffix);
372 373
373 // This is SxS if current EXE is in or under (possibly multiple levels under) 374 // This is SxS if current EXE is in or under (possibly multiple levels under)
374 // |chrome_sxs_dir|\|installer::kInstallBinaryDir| 375 // |chrome_sxs_dir|\|installer::kInstallBinaryDir|
375 std::vector<base::FilePath::StringType> components; 376 std::vector<base::FilePath::StringType> components;
376 exe_dir.GetComponents(&components); 377 exe_dir.GetComponents(&components);
377 // We need at least 1 element in the array for the behavior of the following 378 // We need at least 1 element in the array for the behavior of the following
378 // loop to be defined. This should always be true, since we're splitting the 379 // loop to be defined. This should always be true, since we're splitting the
379 // path to our executable and one of the components will be the drive letter. 380 // path to our executable and one of the components will be the drive letter.
380 DCHECK(!components.empty()); 381 DCHECK(!components.empty());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 433 }
433 434
434 *path = path->Append(file); 435 *path = path->Append(file);
435 return true; 436 return true;
436 } 437 }
437 438
438 // This method tries to delete a registry key and logs an error message 439 // This method tries to delete a registry key and logs an error message
439 // in case of failure. It returns true if deletion is successful (or the key did 440 // in case of failure. It returns true if deletion is successful (or the key did
440 // not exist), otherwise false. 441 // not exist), otherwise false.
441 bool InstallUtil::DeleteRegistryKey(HKEY root_key, 442 bool InstallUtil::DeleteRegistryKey(HKEY root_key,
442 const string16& key_path) { 443 const base::string16& key_path) {
443 VLOG(1) << "Deleting registry key " << key_path; 444 VLOG(1) << "Deleting registry key " << key_path;
444 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); 445 LONG result = ::SHDeleteKey(root_key, key_path.c_str());
445 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { 446 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
446 LOG(ERROR) << "Failed to delete registry key: " << key_path 447 LOG(ERROR) << "Failed to delete registry key: " << key_path
447 << " error: " << result; 448 << " error: " << result;
448 return false; 449 return false;
449 } 450 }
450 return true; 451 return true;
451 } 452 }
452 453
453 // This method tries to delete a registry value and logs an error message 454 // This method tries to delete a registry value and logs an error message
454 // in case of failure. It returns true if deletion is successful (or the key did 455 // in case of failure. It returns true if deletion is successful (or the key did
455 // not exist), otherwise false. 456 // not exist), otherwise false.
456 bool InstallUtil::DeleteRegistryValue(HKEY reg_root, 457 bool InstallUtil::DeleteRegistryValue(HKEY reg_root,
457 const string16& key_path, 458 const base::string16& key_path,
458 const string16& value_name) { 459 const base::string16& value_name) {
459 RegKey key; 460 RegKey key;
460 LONG result = key.Open(reg_root, key_path.c_str(), KEY_SET_VALUE); 461 LONG result = key.Open(reg_root, key_path.c_str(), KEY_SET_VALUE);
461 if (result == ERROR_SUCCESS) 462 if (result == ERROR_SUCCESS)
462 result = key.DeleteValue(value_name.c_str()); 463 result = key.DeleteValue(value_name.c_str());
463 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { 464 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
464 LOG(ERROR) << "Failed to delete registry value: " << value_name 465 LOG(ERROR) << "Failed to delete registry value: " << value_name
465 << " error: " << result; 466 << " error: " << result;
466 return false; 467 return false;
467 } 468 }
468 return true; 469 return true;
469 } 470 }
470 471
471 // static 472 // static
472 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryKeyIf( 473 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryKeyIf(
473 HKEY root_key, 474 HKEY root_key,
474 const string16& key_to_delete_path, 475 const base::string16& key_to_delete_path,
475 const string16& key_to_test_path, 476 const base::string16& key_to_test_path,
476 const wchar_t* value_name, 477 const wchar_t* value_name,
477 const RegistryValuePredicate& predicate) { 478 const RegistryValuePredicate& predicate) {
478 DCHECK(root_key); 479 DCHECK(root_key);
479 ConditionalDeleteResult delete_result = NOT_FOUND; 480 ConditionalDeleteResult delete_result = NOT_FOUND;
480 RegKey key; 481 RegKey key;
481 string16 actual_value; 482 base::string16 actual_value;
482 if (key.Open(root_key, key_to_test_path.c_str(), 483 if (key.Open(root_key, key_to_test_path.c_str(),
483 KEY_QUERY_VALUE) == ERROR_SUCCESS && 484 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
484 key.ReadValue(value_name, &actual_value) == ERROR_SUCCESS && 485 key.ReadValue(value_name, &actual_value) == ERROR_SUCCESS &&
485 predicate.Evaluate(actual_value)) { 486 predicate.Evaluate(actual_value)) {
486 key.Close(); 487 key.Close();
487 delete_result = DeleteRegistryKey(root_key, key_to_delete_path) 488 delete_result = DeleteRegistryKey(root_key, key_to_delete_path)
488 ? DELETED : DELETE_FAILED; 489 ? DELETED : DELETE_FAILED;
489 } 490 }
490 return delete_result; 491 return delete_result;
491 } 492 }
492 493
493 // static 494 // static
494 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryValueIf( 495 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryValueIf(
495 HKEY root_key, 496 HKEY root_key,
496 const wchar_t* key_path, 497 const wchar_t* key_path,
497 const wchar_t* value_name, 498 const wchar_t* value_name,
498 const RegistryValuePredicate& predicate) { 499 const RegistryValuePredicate& predicate) {
499 DCHECK(root_key); 500 DCHECK(root_key);
500 DCHECK(key_path); 501 DCHECK(key_path);
501 ConditionalDeleteResult delete_result = NOT_FOUND; 502 ConditionalDeleteResult delete_result = NOT_FOUND;
502 RegKey key; 503 RegKey key;
503 string16 actual_value; 504 base::string16 actual_value;
504 if (key.Open(root_key, key_path, 505 if (key.Open(root_key, key_path,
505 KEY_QUERY_VALUE | KEY_SET_VALUE) == ERROR_SUCCESS && 506 KEY_QUERY_VALUE | KEY_SET_VALUE) == ERROR_SUCCESS &&
506 key.ReadValue(value_name, &actual_value) == ERROR_SUCCESS && 507 key.ReadValue(value_name, &actual_value) == ERROR_SUCCESS &&
507 predicate.Evaluate(actual_value)) { 508 predicate.Evaluate(actual_value)) {
508 LONG result = key.DeleteValue(value_name); 509 LONG result = key.DeleteValue(value_name);
509 if (result != ERROR_SUCCESS) { 510 if (result != ERROR_SUCCESS) {
510 LOG(ERROR) << "Failed to delete registry value: " 511 LOG(ERROR) << "Failed to delete registry value: "
511 << (value_name ? value_name : L"(Default)") 512 << (value_name ? value_name : L"(Default)")
512 << " error: " << result; 513 << " error: " << result;
513 delete_result = DELETE_FAILED; 514 delete_result = DELETE_FAILED;
514 } 515 }
515 delete_result = DELETED; 516 delete_result = DELETED;
516 } 517 }
517 return delete_result; 518 return delete_result;
518 } 519 }
519 520
520 bool InstallUtil::ValueEquals::Evaluate(const string16& value) const { 521 bool InstallUtil::ValueEquals::Evaluate(const base::string16& value) const {
521 return value == value_to_match_; 522 return value == value_to_match_;
522 } 523 }
523 524
524 // static 525 // static
525 int InstallUtil::GetInstallReturnCode(installer::InstallStatus status) { 526 int InstallUtil::GetInstallReturnCode(installer::InstallStatus status) {
526 switch (status) { 527 switch (status) {
527 case installer::FIRST_INSTALL_SUCCESS: 528 case installer::FIRST_INSTALL_SUCCESS:
528 case installer::INSTALL_REPAIRED: 529 case installer::INSTALL_REPAIRED:
529 case installer::NEW_VERSION_UPDATED: 530 case installer::NEW_VERSION_UPDATED:
530 case installer::IN_USE_UPDATED: 531 case installer::IN_USE_UPDATED:
531 case installer::UNUSED_BINARIES_UNINSTALLED: 532 case installer::UNUSED_BINARIES_UNINSTALLED:
532 return 0; 533 return 0;
533 default: 534 default:
534 return status; 535 return status;
535 } 536 }
536 } 537 }
537 538
538 // static 539 // static
539 void InstallUtil::MakeUninstallCommand(const string16& program, 540 void InstallUtil::MakeUninstallCommand(const base::string16& program,
540 const string16& arguments, 541 const base::string16& arguments,
541 CommandLine* command_line) { 542 CommandLine* command_line) {
542 *command_line = CommandLine::FromString(L"\"" + program + L"\" " + arguments); 543 *command_line = CommandLine::FromString(L"\"" + program + L"\" " + arguments);
543 } 544 }
544 545
545 // static 546 // static
546 string16 InstallUtil::GetCurrentDate() { 547 base::string16 InstallUtil::GetCurrentDate() {
547 static const wchar_t kDateFormat[] = L"yyyyMMdd"; 548 static const wchar_t kDateFormat[] = L"yyyyMMdd";
548 wchar_t date_str[arraysize(kDateFormat)] = {0}; 549 wchar_t date_str[arraysize(kDateFormat)] = {0};
549 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, 550 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat,
550 date_str, arraysize(date_str)); 551 date_str, arraysize(date_str));
551 if (len) { 552 if (len) {
552 --len; // Subtract terminating \0. 553 --len; // Subtract terminating \0.
553 } else { 554 } else {
554 PLOG(DFATAL) << "GetDateFormat"; 555 PLOG(DFATAL) << "GetDateFormat";
555 } 556 }
556 557
557 return string16(date_str, len); 558 return base::string16(date_str, len);
558 } 559 }
559 560
560 // Open |path| with minimal access to obtain information about it, returning 561 // Open |path| with minimal access to obtain information about it, returning
561 // true and populating |handle| on success. 562 // true and populating |handle| on success.
562 // static 563 // static
563 bool InstallUtil::ProgramCompare::OpenForInfo(const base::FilePath& path, 564 bool InstallUtil::ProgramCompare::OpenForInfo(const base::FilePath& path,
564 base::win::ScopedHandle* handle) { 565 base::win::ScopedHandle* handle) {
565 DCHECK(handle); 566 DCHECK(handle);
566 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL, 567 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL,
567 NULL)); 568 NULL));
(...skipping 21 matching lines...) Expand all
589 PLOG(WARNING) << "Failed getting information for " 590 PLOG(WARNING) << "Failed getting information for "
590 << path_to_match_.value() 591 << path_to_match_.value()
591 << "; falling back to path string comparisons."; 592 << "; falling back to path string comparisons.";
592 file_handle_.Close(); 593 file_handle_.Close();
593 } 594 }
594 } 595 }
595 596
596 InstallUtil::ProgramCompare::~ProgramCompare() { 597 InstallUtil::ProgramCompare::~ProgramCompare() {
597 } 598 }
598 599
599 bool InstallUtil::ProgramCompare::Evaluate(const string16& value) const { 600 bool InstallUtil::ProgramCompare::Evaluate(const base::string16& value) const {
600 // Suss out the exe portion of the value, which is expected to be a command 601 // Suss out the exe portion of the value, which is expected to be a command
601 // line kinda (or exactly) like: 602 // line kinda (or exactly) like:
602 // "c:\foo\bar\chrome.exe" -- "%1" 603 // "c:\foo\bar\chrome.exe" -- "%1"
603 base::FilePath program(CommandLine::FromString(value).GetProgram()); 604 base::FilePath program(CommandLine::FromString(value).GetProgram());
604 if (program.empty()) { 605 if (program.empty()) {
605 LOG(WARNING) << "Failed to parse an executable name from command line: \"" 606 LOG(WARNING) << "Failed to parse an executable name from command line: \""
606 << value << "\""; 607 << value << "\"";
607 return false; 608 return false;
608 } 609 }
609 610
(...skipping 15 matching lines...) Expand all
625 // Open the program and see if it references the expected file. 626 // Open the program and see if it references the expected file.
626 base::win::ScopedHandle handle; 627 base::win::ScopedHandle handle;
627 BY_HANDLE_FILE_INFORMATION info = {}; 628 BY_HANDLE_FILE_INFORMATION info = {};
628 629
629 return (OpenForInfo(path, &handle) && 630 return (OpenForInfo(path, &handle) &&
630 GetInfo(handle, &info) && 631 GetInfo(handle, &info) &&
631 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && 632 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber &&
632 info.nFileIndexHigh == file_info_.nFileIndexHigh && 633 info.nFileIndexHigh == file_info_.nFileIndexHigh &&
633 info.nFileIndexLow == file_info_.nFileIndexLow); 634 info.nFileIndexLow == file_info_.nFileIndexLow);
634 } 635 }
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/installation_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698