Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 screen_rect.top + y_offset, | 111 screen_rect.top + y_offset, |
| 112 0, 0, FALSE); | 112 0, 0, FALSE); |
| 113 } else { | 113 } else { |
| 114 NOTREACHED() << "Unable to get default monitor"; | 114 NOTREACHED() << "Unable to get default monitor"; |
| 115 } | 115 } |
| 116 ::SetForegroundWindow(foreground_window); | 116 ::SetForegroundWindow(foreground_window); |
| 117 } | 117 } |
| 118 return foreground_window; | 118 return foreground_window; |
| 119 } | 119 } |
| 120 | 120 |
| 121 const wchar_t kExperimentLabels[] = L"experiment_labels"; | |
| 122 | |
| 123 const wchar_t* kExperimentAppGuids[] = { | |
| 124 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}", | |
| 125 L"{8A69D345-D564-463C-AFF1-A69D9E530F96}", | |
| 126 }; | |
|
robertshield
2012/11/20 15:29:49
move these up next to the other constants
SteveT
2012/11/20 15:45:01
Moved them up in alpha order as well. Thanks. Done
| |
| 127 | |
| 121 } // namespace | 128 } // namespace |
| 122 | 129 |
| 123 string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { | 130 string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { |
| 124 static const wchar_t kInstalledComponentsPath[] = | 131 static const wchar_t kInstalledComponentsPath[] = |
| 125 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; | 132 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; |
| 126 return kInstalledComponentsPath + dist->GetAppGuid(); | 133 return kInstalledComponentsPath + dist->GetAppGuid(); |
| 127 } | 134 } |
| 128 | 135 |
| 129 void InstallUtil::TriggerActiveSetupCommandIfNeeded() { | 136 void InstallUtil::TriggerActiveSetupCommandIfNeeded() { |
| 130 FilePath chrome_exe; | 137 FilePath chrome_exe; |
| (...skipping 385 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, | |
| 535 HKEY registry_hive) { | |
| 536 int successful_writes = 0; | |
| 537 for (int i = 0; i < arraysize(kExperimentAppGuids); ++i) { | |
| 538 string16 experiment_path(google_update::kRegPathClientState); | |
| 539 experiment_path += L"\\"; | |
| 540 experiment_path += kExperimentAppGuids[i]; | |
| 541 | |
| 542 RegKey client_state(registry_hive, experiment_path.c_str(), | |
| 543 KEY_SET_VALUE); | |
| 544 if (client_state.Valid()) { | |
| 545 if (client_state.WriteValue(kExperimentLabels, | |
| 546 experiment_label.c_str()) == ERROR_SUCCESS) { | |
|
robertshield
2012/11/20 15:29:49
nit: collapse this to a single if to reduce indent
SteveT
2012/11/20 15:45:01
Done.
| |
| 547 successful_writes++; | |
| 548 } | |
| 549 } | |
| 550 } | |
| 551 | |
| 552 return (successful_writes == arraysize(kExperimentAppGuids)); | |
| 553 } | |
| 554 | |
| 526 // Open |path| with minimal access to obtain information about it, returning | 555 // Open |path| with minimal access to obtain information about it, returning |
| 527 // true and populating |handle| on success. | 556 // true and populating |handle| on success. |
| 528 // static | 557 // static |
| 529 bool InstallUtil::ProgramCompare::OpenForInfo(const FilePath& path, | 558 bool InstallUtil::ProgramCompare::OpenForInfo(const FilePath& path, |
| 530 base::win::ScopedHandle* handle) { | 559 base::win::ScopedHandle* handle) { |
| 531 DCHECK(handle); | 560 DCHECK(handle); |
| 532 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL, | 561 handle->Set(base::CreatePlatformFile(path, base::PLATFORM_FILE_OPEN, NULL, |
| 533 NULL)); | 562 NULL)); |
| 534 return handle->IsValid(); | 563 return handle->IsValid(); |
| 535 } | 564 } |
| (...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. | 614 // Open the program and see if it references the expected file. |
| 586 base::win::ScopedHandle handle; | 615 base::win::ScopedHandle handle; |
| 587 BY_HANDLE_FILE_INFORMATION info = {}; | 616 BY_HANDLE_FILE_INFORMATION info = {}; |
| 588 | 617 |
| 589 return (OpenForInfo(program, &handle) && | 618 return (OpenForInfo(program, &handle) && |
| 590 GetInfo(handle, &info) && | 619 GetInfo(handle, &info) && |
| 591 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 620 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 592 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 621 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 593 info.nFileIndexLow == file_info_.nFileIndexLow); | 622 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 594 } | 623 } |
| OLD | NEW |