OLD | NEW |
---|---|
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 20 matching lines...) Expand all Loading... | |
31 #include "chrome/installer/util/installation_state.h" | 31 #include "chrome/installer/util/installation_state.h" |
32 #include "chrome/installer/util/l10n_string_util.h" | 32 #include "chrome/installer/util/l10n_string_util.h" |
33 #include "chrome/installer/util/util_constants.h" | 33 #include "chrome/installer/util/util_constants.h" |
34 #include "chrome/installer/util/work_item_list.h" | 34 #include "chrome/installer/util/work_item_list.h" |
35 | 35 |
36 using base::win::RegKey; | 36 using base::win::RegKey; |
37 using installer::ProductState; | 37 using installer::ProductState; |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 const wchar_t* kExperimentAppGuids[] = { | |
42 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}", | |
43 L"{8A69D345-D564-463C-AFF1-A69D9E530F96}", | |
44 }; | |
45 | |
46 const wchar_t kExperimentLabels[] = L"experiment_labels"; | |
47 | |
41 const wchar_t kStageBinaryPatching[] = L"binary_patching"; | 48 const wchar_t kStageBinaryPatching[] = L"binary_patching"; |
42 const wchar_t kStageBuilding[] = L"building"; | 49 const wchar_t kStageBuilding[] = L"building"; |
43 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; | 50 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; |
44 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs"; | 51 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs"; |
45 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts"; | 52 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts"; |
46 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching"; | 53 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching"; |
47 const wchar_t kStageExecuting[] = L"executing"; | 54 const wchar_t kStageExecuting[] = L"executing"; |
48 const wchar_t kStageFinishing[] = L"finishing"; | 55 const wchar_t kStageFinishing[] = L"finishing"; |
49 const wchar_t kStagePreconditions[] = L"preconditions"; | 56 const wchar_t kStagePreconditions[] = L"preconditions"; |
50 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy"; | 57 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy"; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 date_str, arraysize(date_str)); | 523 date_str, arraysize(date_str)); |
517 if (len) { | 524 if (len) { |
518 --len; // Subtract terminating \0. | 525 --len; // Subtract terminating \0. |
519 } else { | 526 } else { |
520 PLOG(DFATAL) << "GetDateFormat"; | 527 PLOG(DFATAL) << "GetDateFormat"; |
521 } | 528 } |
522 | 529 |
523 return string16(date_str, len); | 530 return string16(date_str, len); |
524 } | 531 } |
525 | 532 |
533 // static | |
534 bool InstallUtil::SetOmahaExperimentLabel(const string16& experiment_label, | |
grt (UTC plus 2)
2012/11/23 00:09:55
If this is meant to be called from the context of
| |
535 HKEY registry_hive) { | |
536 size_t successful_writes = 0; | |
537 string16 experiment_path; | |
538 for (size_t i = 0; i < arraysize(kExperimentAppGuids); ++i) { | |
539 experiment_path = google_update::kRegPathClientState; | |
540 experiment_path += L"\\"; | |
541 experiment_path += kExperimentAppGuids[i]; | |
542 | |
543 RegKey client_state(registry_hive, experiment_path.c_str(), | |
544 KEY_SET_VALUE); | |
545 if (client_state.WriteValue(kExperimentLabels, | |
546 experiment_label.c_str()) == ERROR_SUCCESS) { | |
547 ++successful_writes; | |
548 } | |
549 } | |
550 | |
551 return (successful_writes == arraysize(kExperimentAppGuids)); | |
552 } | |
553 | |
526 // Open |path| with minimal access to obtain information about it, returning | 554 // Open |path| with minimal access to obtain information about it, returning |
527 // true and populating |handle| on success. | 555 // true and populating |handle| on success. |
528 // static | 556 // static |
529 bool InstallUtil::ProgramCompare::OpenForInfo(const FilePath& path, | 557 bool InstallUtil::ProgramCompare::OpenForInfo(const FilePath& path, |
530 base::win::ScopedHandle* handle) { | 558 base::win::ScopedHandle* handle) { |
531 DCHECK(handle); | 559 DCHECK(handle); |
532 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL, | 560 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL, |
533 NULL)); | 561 NULL)); |
534 return handle->IsValid(); | 562 return handle->IsValid(); |
535 } | 563 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 // Open the program and see if it references the expected file. | 613 // Open the program and see if it references the expected file. |
586 base::win::ScopedHandle handle; | 614 base::win::ScopedHandle handle; |
587 BY_HANDLE_FILE_INFORMATION info = {}; | 615 BY_HANDLE_FILE_INFORMATION info = {}; |
588 | 616 |
589 return (OpenForInfo(program, &handle) && | 617 return (OpenForInfo(program, &handle) && |
590 GetInfo(handle, &info) && | 618 GetInfo(handle, &info) && |
591 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 619 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
592 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 620 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
593 info.nFileIndexLow == file_info_.nFileIndexLow); | 621 info.nFileIndexLow == file_info_.nFileIndexLow); |
594 } | 622 } |
OLD | NEW |